Commit b1240e9f authored by Hiroyuki Ikezoe's avatar Hiroyuki Ikezoe
Browse files

[PATCH 3/3] Refer to parent's font-size if font-size unit is %, em and ex.

Fix for bug #337979.
parent bb0e9316
......@@ -200,6 +200,30 @@ _rsvg_css_parse_length (const char *str)
return out;
}
double
_rsvg_css_normalize_font_size (RsvgState * state, RsvgDrawingCtx * ctx)
{
RsvgState *parent;
switch (state->font_size.factor) {
case 'p':
case 'm':
case 'x':
parent= rsvg_state_parent (state);
if (parent) {
double parent_size;
parent_size = _rsvg_css_normalize_font_size (parent, ctx);
return state->font_size.length * parent_size;
}
break;
default:
return _rsvg_css_normalize_length (&state->font_size, ctx, 'v');
break;
}
return 12.;
}
double
_rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx, char dir)
{
......@@ -213,8 +237,7 @@ _rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx, char di
if (dir == 'o')
return in->length * rsvg_viewport_percentage (ctx->vb.w, ctx->vb.h);
} else if (in->factor == 'm' || in->factor == 'x') {
double font = _rsvg_css_hand_normalize_length (&rsvg_current_state (ctx)->font_size,
ctx->dpi_y, ctx->vb.h, 1);
double font = _rsvg_css_normalize_font_size (rsvg_current_state (ctx), ctx);
if (in->factor == 'm')
return in->length * font;
else
......
......@@ -344,6 +344,7 @@ void rsvg_bbox_clip (RsvgBbox * dst, RsvgBbox * src);
double _rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx, char dir);
double _rsvg_css_hand_normalize_length (const RsvgLength * in, gdouble pixels_per_inch,
gdouble width_or_height, gdouble font_size);
double _rsvg_css_normalize_font_size (RsvgState * state, RsvgDrawingCtx * ctx);
RsvgLength _rsvg_css_parse_length (const char *str);
......
......@@ -541,17 +541,16 @@ rsvg_text_create_layout (RsvgDrawingCtx * ctx,
pango_font_description_set_weight (font_desc, state->font_weight);
pango_font_description_set_stretch (font_desc, state->font_stretch);
pango_font_description_set_size (font_desc,
_rsvg_css_normalize_length (&state->font_size, ctx,
'v') * PANGO_SCALE / ctx->dpi_y *
72);
_rsvg_css_normalize_font_size (state, ctx) *
PANGO_SCALE / ctx->dpi_y * 72);
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, font_desc);
pango_font_description_free (font_desc);
attr_list = pango_attr_list_new ();
attribute = pango_attr_letter_spacing_new ( _rsvg_css_normalize_length (&state->letter_spacing,
ctx, 'h') * PANGO_SCALE);
attribute = pango_attr_letter_spacing_new (_rsvg_css_normalize_length (&state->letter_spacing,
ctx, 'h') * PANGO_SCALE);
attribute->start_index = 0;
attribute->end_index = G_MAXINT;
pango_attr_list_insert (attr_list, attribute);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment