[librsvg] [PATCH 3/3] Refer to parent's font-size if font-size unit is %, em and ex.
- From: Hiroyuki Ikezoe <hiikezoe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] [PATCH 3/3] Refer to parent's font-size if font-size unit is %, em and ex.
- Date: Sun, 2 May 2010 02:58:16 +0000 (UTC)
commit b1240e9fad3413249a4f68dadfda91cc1fc3cc1c
Author: Hiroyuki Ikezoe <hiikezoe gnome org>
Date: Sun May 2 11:56:57 2010 +0900
[PATCH 3/3] Refer to parent's font-size if font-size unit is %, em and ex.
Fix for bug #337979.
rsvg-css.c | 27 +++++++++++++++++++++++++--
rsvg-private.h | 1 +
rsvg-text.c | 9 ++++-----
3 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/rsvg-css.c b/rsvg-css.c
index ff846f4..be9b7fa 100644
--- a/rsvg-css.c
+++ b/rsvg-css.c
@@ -201,6 +201,30 @@ _rsvg_css_parse_length (const char *str)
}
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)
{
if (in->factor == '\0')
@@ -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
diff --git a/rsvg-private.h b/rsvg-private.h
index 04af5eb..c4fed2d 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -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);
diff --git a/rsvg-text.c b/rsvg-text.c
index 85f6c63..6a45e3b 100644
--- a/rsvg-text.c
+++ b/rsvg-text.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]