diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-03 17:49:32 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-03 17:49:32 +0200 |
commit | a85b58e0548fb4e45f35bcbb7d0ee6e35bde35b4 (patch) | |
tree | 5edf7dc19d85531d7f681fbc81772f123a33ad9e /fitz/res_font.c | |
parent | cb1f58e1e204eab0995b57d1a973714f024e70ad (diff) | |
download | mupdf-a85b58e0548fb4e45f35bcbb7d0ee6e35bde35b4.tar.xz |
xps: Fix bugs uncovered by QualityLogicMinBar tests.
Diffstat (limited to 'fitz/res_font.c')
-rw-r--r-- | fitz/res_font.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/fitz/res_font.c b/fitz/res_font.c index 1df8b2e6..44046451 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -176,6 +176,7 @@ fz_finalizefreetype(void) fz_error fz_newfontfromfile(fz_font **fontp, char *path, int index) { + FT_Face face; fz_error error; fz_font *font; int fterr; @@ -184,14 +185,16 @@ fz_newfontfromfile(fz_font **fontp, char *path, int index) if (error) return fz_rethrow(error, "cannot init freetype library"); - font = fz_newfont(); - - fterr = FT_New_Face(fz_ftlib, path, index, (FT_Face*)&font->ftface); + fterr = FT_New_Face(fz_ftlib, path, index, &face); if (fterr) - { - fz_free(font); return fz_throw("freetype: cannot load font: %s", ft_errorstring(fterr)); - } + + font = fz_newfont(); + font->ftface = face; + font->bbox.x0 = face->bbox.xMin * 1000 / face->units_per_EM; + font->bbox.y0 = face->bbox.yMin * 1000 / face->units_per_EM; + font->bbox.x1 = face->bbox.xMax * 1000 / face->units_per_EM; + font->bbox.y1 = face->bbox.yMax * 1000 / face->units_per_EM; *fontp = font; return fz_okay; @@ -200,6 +203,7 @@ fz_newfontfromfile(fz_font **fontp, char *path, int index) fz_error fz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index) { + FT_Face face; fz_error error; fz_font *font; int fterr; @@ -210,12 +214,16 @@ fz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index) font = fz_newfont(); - fterr = FT_New_Memory_Face(fz_ftlib, data, len, index, (FT_Face*)&font->ftface); + fterr = FT_New_Memory_Face(fz_ftlib, data, len, index, &face); if (fterr) - { - fz_free(font); return fz_throw("freetype: cannot load font: %s", ft_errorstring(fterr)); - } + + font = fz_newfont(); + font->ftface = face; + font->bbox.x0 = face->bbox.xMin * 1000 / face->units_per_EM; + font->bbox.y0 = face->bbox.yMin * 1000 / face->units_per_EM; + font->bbox.x1 = face->bbox.xMax * 1000 / face->units_per_EM; + font->bbox.y1 = face->bbox.yMax * 1000 / face->units_per_EM; *fontp = font; return fz_okay; |