From d47fae804572cd0a6cc78e60020e65334a088c0b Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 6 Apr 2015 15:54:30 +0100 Subject: Use fz_advance_glyph rather than direct FT calls during PDF layout. --- source/fitz/font.c | 9 +++++++-- source/fitz/stext-device.c | 21 +-------------------- 2 files changed, 8 insertions(+), 22 deletions(-) (limited to 'source') diff --git a/source/fitz/font.c b/source/fitz/font.c index 64cea107..6d703659 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -410,7 +410,7 @@ static fz_matrix * fz_adjust_ft_glyph_width(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm) { /* Fudge the font matrix to stretch the glyph if we've substituted the font. */ - if (font->ft_substitute && font->width_table && gid < font->width_count) + if (font->ft_substitute && font->width_table && gid < font->width_count /* && font->wmode == 0 */) { FT_Error fterr; int subw; @@ -1298,12 +1298,17 @@ static float fz_advance_ft_glyph(fz_context *ctx, fz_font *font, int gid) { FT_Fixed adv; - int mask = FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM; + int mask; if (font->ft_substitute && font->width_table && gid < font->width_count) return font->width_table[gid]; + mask = FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | FT_LOAD_IGNORE_TRANSFORM; + /* if (font->wmode) + mask |= FT_LOAD_VERTICAL_LAYOUT; */ + fz_lock(ctx, FZ_LOCK_FREETYPE); FT_Get_Advance(font->ft_face, gid, mask, &adv); + fz_unlock(ctx, FZ_LOCK_FREETYPE); return (float) adv / ((FT_Face)font->ft_face)->units_per_EM; } diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index da8a63f0..3ecc3302 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -744,26 +744,7 @@ fz_text_extract(fz_context *ctx, fz_text_device *dev, fz_text *text, const fz_ma fz_concat(&trm, &tm, ctm); /* Calculate bounding box and new pen position based on font metrics */ - if (font->ft_face) - { - FT_Fixed ftadv = 0; - int mask = FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING | FT_LOAD_IGNORE_TRANSFORM; - - /* TODO: freetype returns broken vertical metrics */ - /* if (text->wmode) mask |= FT_LOAD_VERTICAL_LAYOUT; */ - - fz_lock(ctx, FZ_LOCK_FREETYPE); - err = FT_Set_Char_Size(font->ft_face, 64, 64, 72, 72); - if (err) - fz_warn(ctx, "freetype set character size: %s", ft_error_string(err)); - FT_Get_Advance(font->ft_face, text->items[i].gid, mask, &ftadv); - adv = ftadv / 65536.0f; - fz_unlock(ctx, FZ_LOCK_FREETYPE); - } - else - { - adv = font->t3widths[text->items[i].gid]; - } + adv = fz_advance_glyph(ctx, font, text->items[i].gid); /* Check for one glyph to many char mapping */ for (j = i + 1; j < text->len; j++) -- cgit v1.2.3