summaryrefslogtreecommitdiff
path: root/source/fitz/font.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-03-01 17:55:24 +0800
committerSebastian Rasmussen <sebras@gmail.com>2018-03-16 03:43:36 +0800
commitace9e69017c08e1e4ce5912014177414c0382004 (patch)
tree1aed3f5c9aa7ecfcc0262ec174f1c120bc696fe7 /source/fitz/font.c
parentc273fe1bda43197882adbd4fef4f417323131b53 (diff)
downloadmupdf-ace9e69017c08e1e4ce5912014177414c0382004.tar.xz
Fix 699086: Handle freetype not returning glyph advance.
Diffstat (limited to 'source/fitz/font.c')
-rw-r--r--source/fitz/font.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/fitz/font.c b/source/fitz/font.c
index 54378e55..1e0bd0eb 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -641,13 +641,16 @@ 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->flags.ft_stretch && font->width_table /* && font->wmode == 0 */)
{
- FT_Fixed adv;
+ FT_Error fterr;
+ FT_Fixed adv = 0;
float subw;
float realw;
fz_lock(ctx, FZ_LOCK_FREETYPE);
- FT_Get_Advance(font->ft_face, gid, FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | FT_LOAD_IGNORE_TRANSFORM, &adv);
+ fterr = FT_Get_Advance(font->ft_face, gid, FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | FT_LOAD_IGNORE_TRANSFORM, &adv);
fz_unlock(ctx, FZ_LOCK_FREETYPE);
+ if (fterr)
+ fz_warn(ctx, "freetype getting character advance: %s", ft_error_string(fterr));
realw = adv * 1000.0f / ((FT_Face)font->ft_face)->units_per_EM;
if (gid < font->width_count)
@@ -1513,7 +1516,8 @@ int fz_glyph_cacheable(fz_context *ctx, fz_font *font, int gid)
static float
fz_advance_ft_glyph(fz_context *ctx, fz_font *font, int gid, int wmode)
{
- FT_Fixed adv;
+ FT_Error fterr;
+ FT_Fixed adv = 0;
int mask;
/* Substitute font widths. */
@@ -1528,8 +1532,10 @@ fz_advance_ft_glyph(fz_context *ctx, fz_font *font, int gid, int wmode)
if (wmode)
mask |= FT_LOAD_VERTICAL_LAYOUT;
fz_lock(ctx, FZ_LOCK_FREETYPE);
- FT_Get_Advance(font->ft_face, gid, mask, &adv);
+ fterr = FT_Get_Advance(font->ft_face, gid, mask, &adv);
fz_unlock(ctx, FZ_LOCK_FREETYPE);
+ if (fterr)
+ fz_warn(ctx, "freetype getting character advance: %s", ft_error_string(fterr));
return (float) adv / ((FT_Face)font->ft_face)->units_per_EM;
}