summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-05-24 17:15:19 +0000
committerMatthias Clasen <mclasen@redhat.com>2019-07-18 12:47:53 -0700
commit2b3e2ba724667b457ab7024a6546d84111329f69 (patch)
treef1ca2ad7f8e304b2c09bb4fbd38fdec770137a19 /pango
parent50d4f9afe67371c96ca7aaef5571fd44abb450d9 (diff)
downloadpango-2b3e2ba724667b457ab7024a6546d84111329f69.tar.gz
fc: Use harfbuzz for glyph extents
Harfbuzz has the api, no need to use freetype.
Diffstat (limited to 'pango')
-rw-r--r--pango/pangofc-font.c91
1 files changed, 28 insertions, 63 deletions
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index c0f9d9e7..2eba92b6 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -800,23 +800,6 @@ _pango_fc_font_set_font_key (PangoFcFont *fcfont,
priv->key = key;
}
-static FT_Glyph_Metrics *
-get_per_char (FT_Face face,
- FT_Int32 load_flags,
- PangoGlyph glyph)
-{
- FT_Error error;
- FT_Glyph_Metrics *result;
-
- error = FT_Load_Glyph (face, glyph, load_flags);
- if (error == FT_Err_Ok)
- result = &face->glyph->metrics;
- else
- result = NULL;
-
- return result;
-}
-
/**
* pango_fc_font_get_raw_extents:
* @fcfont: a #PangoFcFont
@@ -846,76 +829,58 @@ pango_fc_font_get_raw_extents (PangoFcFont *fcfont,
PangoRectangle *ink_rect,
PangoRectangle *logical_rect)
{
- FT_Glyph_Metrics *gm;
- FT_Face face;
-
g_return_if_fail (PANGO_IS_FC_FONT (fcfont));
- face = PANGO_FC_FONT_LOCK_FACE (fcfont);
- if (G_UNLIKELY (!face))
- {
- /* Get generic unknown-glyph extents. */
- pango_font_get_glyph_extents (NULL, glyph, ink_rect, logical_rect);
- return;
- }
-
if (glyph == PANGO_GLYPH_EMPTY)
- gm = NULL;
- else
- gm = get_per_char (face, load_flags, glyph);
-
- if (gm)
{
if (ink_rect)
{
- ink_rect->x = PANGO_UNITS_26_6 (gm->horiBearingX);
- ink_rect->width = PANGO_UNITS_26_6 (gm->width);
- ink_rect->y = -PANGO_UNITS_26_6 (gm->horiBearingY);
- ink_rect->height = PANGO_UNITS_26_6 (gm->height);
+ ink_rect->x = 0;
+ ink_rect->width = 0;
+ ink_rect->y = 0;
+ ink_rect->height = 0;
}
if (logical_rect)
{
logical_rect->x = 0;
- logical_rect->width = PANGO_UNITS_26_6 (gm->horiAdvance);
- if (fcfont->is_hinted ||
- (face->face_flags & FT_FACE_FLAG_SCALABLE) == 0)
- {
- logical_rect->y = - PANGO_UNITS_26_6 (face->size->metrics.ascender);
- logical_rect->height = PANGO_UNITS_26_6 (face->size->metrics.ascender - face->size->metrics.descender);
- }
- else
- {
- FT_Fixed ascender, descender;
-
- ascender = FT_MulFix (face->ascender, face->size->metrics.y_scale);
- descender = FT_MulFix (face->descender, face->size->metrics.y_scale);
-
- logical_rect->y = - PANGO_UNITS_26_6 (ascender);
- logical_rect->height = PANGO_UNITS_26_6 (ascender - descender);
- }
+ logical_rect->width = 0;
+ logical_rect->y = 0;
+ logical_rect->height = 0;
}
}
else
{
+ hb_font_t *hb_font = pango_font_get_hb_font (PANGO_FONT (fcfont));
+ hb_glyph_extents_t extents;
+ hb_font_extents_t font_extents;
+
+ hb_font_get_glyph_extents (hb_font, glyph, &extents);
+ hb_font_get_extents_for_direction (hb_font, HB_DIRECTION_LTR, &font_extents);
+
if (ink_rect)
{
- ink_rect->x = 0;
- ink_rect->width = 0;
- ink_rect->y = 0;
- ink_rect->height = 0;
+ ink_rect->x = extents.x_bearing;
+ ink_rect->width = extents.width;
+ ink_rect->y = -extents.y_bearing;
+ ink_rect->height = extents.height;
}
if (logical_rect)
{
+ hb_position_t x, y;
+
+ hb_font_get_glyph_advance_for_direction (hb_font,
+ glyph,
+ HB_DIRECTION_LTR,
+ &x, &y);
+
logical_rect->x = 0;
- logical_rect->width = 0;
- logical_rect->y = 0;
- logical_rect->height = 0;
+ logical_rect->width = x;
+ logical_rect->y = - font_extents.ascender;
+ logical_rect->height = font_extents.ascender - font_extents.descender;
}
}
-
- PANGO_FC_FONT_UNLOCK_FACE (fcfont);
}
static void