diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-03-01 15:55:47 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-03-01 20:51:45 +0100 |
commit | 412572d95d05230144ebe543e81755b77cf70a9b (patch) | |
tree | fa55885ba55a2d490981a980b61f46aa5d562b38 | |
parent | 3cf7524de67c850997bb2d56fb2a4871caac0d8a (diff) | |
download | mupdf-412572d95d05230144ebe543e81755b77cf70a9b.tar.xz |
Use FT_Get_Advance in when loading simple font widths in ft_width.
-rw-r--r-- | source/pdf/pdf-font.c | 10 |
1 files changed, 6 insertions, 4 deletions
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 <ft2build.h> #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) |