From 412572d95d05230144ebe543e81755b77cf70a9b Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 1 Mar 2016 15:55:47 +0100 Subject: Use FT_Get_Advance in when loading simple font widths in ft_width. --- source/pdf/pdf-font.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/pdf') diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index a5dadbbf..f45f71c6 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -2,6 +2,7 @@ #include #include FT_FREETYPE_H +#include FT_ADVANCES_H #include FT_FONT_FORMATS_H #include FT_TRUETYPE_TABLES_H @@ -181,17 +182,18 @@ pdf_font_cid_to_gid(fz_context *ctx, pdf_font_desc *fontdesc, int cid) static int ft_width(fz_context *ctx, pdf_font_desc *fontdesc, int cid) { + int mask = FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM; int gid = ft_cid_to_gid(fontdesc, cid); int fterr; + FT_Fixed adv; - fterr = FT_Load_Glyph(fontdesc->font->ft_face, gid, - FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM); + fterr = FT_Get_Advance(fontdesc->font->ft_face, gid, mask, &adv); if (fterr) { - fz_warn(ctx, "freetype load glyph (gid %d): %s", gid, ft_error_string(fterr)); + fz_warn(ctx, "freetype advance glyph (gid %d): %s", gid, ft_error_string(fterr)); return 0; } - return ((FT_Face)fontdesc->font->ft_face)->glyph->advance.x; + return adv * 1000 / ((FT_Face)fontdesc->font->ft_face)->units_per_EM; } static int lookup_mre_code(char *name) -- cgit v1.2.3