summaryrefslogtreecommitdiff
path: root/pango/pangocairo-fcfont.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-04-30 23:09:47 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-04-30 23:09:47 +0000
commitbd7f0529df20a3268815da365944979af441cd3a (patch)
treefb8ed8d2a77ed919f180f7197f89695b6fd8af84 /pango/pangocairo-fcfont.c
parent69bcc7f2e5ca2c7135e7ba558c85fffbce2426cb (diff)
downloadpango-bd7f0529df20a3268815da365944979af441cd3a.tar.gz
Move PANGO_UNITS_ROUND here... ...from here.
2007-04-30 Behdad Esfahbod <behdad@gnome.org> * pango/pango-types.h: Move PANGO_UNITS_ROUND here... * pango/pangofc-private.h: ...from here. * pango/pango-gravity.c: Document that pango_gravity_to_rotation() returns angle in radians but pango_matrix_rotate() takes degrees. * pango/pango-layout.c (pango_layout_run_get_extents): * pango/pango-renderer.c (pango_renderer_draw_layout_line): Retain metrics hinting when centering baseline (used for Latin, etc in vertical mode). * pango/pangocairo-fcfont.c (pango_cairo_fc_font_get_metrics), (pango_cairo_fc_font_glyph_extents_cache_init): Respect metrics hinting setting when moving glyphs around for vertical writing. * pango/pangocairo-fcfont.c (_pango_cairo_fc_font_new): Apply the gravity rotation before the pattern's matrix, such that vertical text gets correct italic direction. * pango/pangocairo-font.c (_pango_cairo_font_get_hex_box_info): Make hexbox font inherit most properties from the current font. That is, bold hexbox digits for a bold font, etc. svn path=/trunk/; revision=2238
Diffstat (limited to 'pango/pangocairo-fcfont.c')
-rw-r--r--pango/pangocairo-fcfont.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index 65b9e038..8c44b2a0 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -245,11 +245,14 @@ pango_cairo_fc_font_get_metrics (PangoFont *font,
break;
case PANGO_GRAVITY_EAST:
case PANGO_GRAVITY_WEST:
- info->metrics->ascent = height / 2;
+ {
+ int ascent = height / 2;
+ if (fcfont->is_hinted)
+ ascent = PANGO_UNITS_ROUND (ascent);
+ info->metrics->ascent = ascent;
+ }
}
shift = (height - info->metrics->ascent) - info->metrics->descent;
- if (fcfont->is_hinted)
- shift &= ~(PANGO_SCALE - 1);
info->metrics->descent += shift;
info->metrics->underline_position -= shift;
info->metrics->strikethrough_position -= shift;
@@ -307,7 +310,13 @@ pango_cairo_fc_font_glyph_extents_cache_init (PangoCairoFcFont *cffont)
break;
case PANGO_GRAVITY_EAST:
case PANGO_GRAVITY_WEST:
- cffont->font_extents.y = - pango_units_from_double ((font_extents.ascent + font_extents.descent) * 0.5);
+ {
+ PangoFcFont *fcfont = (PangoFcFont *) (cffont);
+ int ascent = pango_units_from_double (font_extents.ascent + font_extents.descent) / 2;
+ if (fcfont->is_hinted)
+ ascent = PANGO_UNITS_ROUND (ascent);
+ cffont->font_extents.y = - ascent;
+ }
}
cffont->glyph_extents_cache = g_new0 (GlyphExtentsCacheEntry, GLYPH_CACHE_NUM_ENTRIES);
@@ -507,21 +516,29 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap,
cffont->gravity = pango_font_description_get_gravity (desc);
+ /* first apply gravity rotation, then pattern matrix, such that
+ * vertical italic text comes out "correct". we don't do anything
+ * like baseline adjustment etc though. should be specially
+ * handled when we support italic correction. */
+ cairo_matrix_init_rotate(&cffont->font_matrix,
+ pango_gravity_to_rotation (cffont->gravity));
+
if (FcPatternGetMatrix (pattern,
FC_MATRIX, 0, &fc_matrix) == FcResultMatch)
{
- cairo_matrix_init (&cffont->font_matrix,
+ cairo_matrix_t matrix;
+
+ cairo_matrix_init (&matrix,
fc_matrix->xx,
- fc_matrix->yx,
- fc_matrix->xy,
fc_matrix->yy,
0., 0.);
- }
- else
- cairo_matrix_init_identity (&cffont->font_matrix);
- cairo_matrix_rotate(&cffont->font_matrix,
- pango_gravity_to_rotation (cffont->gravity));
+ cairo_matrix_multiply (&cffont->font_matrix,
+ &matrix,
+ &cffont->font_matrix);
+ }
pango_ctm = pango_context_get_matrix (context);