diff options
author | Tor Andersson <tor@ghostscript.com> | 2011-02-17 16:22:26 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2011-02-17 16:22:26 +0000 |
commit | 0468489e6eb608262b0dc6749e76ed147d99784e (patch) | |
tree | 6d243003f9f7f745e4045e09a65eadca7d94185d /fitz/res_font.c | |
parent | dae9729e880ef633bde1cbfa5c565e5114410cf1 (diff) | |
download | mupdf-0468489e6eb608262b0dc6749e76ed147d99784e.tar.xz |
Stretch glyphs for substituted fonts when stroking the same as when filling.
Diffstat (limited to 'fitz/res_font.c')
-rw-r--r-- | fitz/res_font.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/fitz/res_font.c b/fitz/res_font.c index a30bbf8b..1df8b2e6 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -221,25 +221,19 @@ fz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index) return fz_okay; } -fz_pixmap * -fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) +static fz_matrix +fz_adjustftglyphwidth(fz_font *font, int gid, fz_matrix trm) { - FT_Face face = font->ftface; - FT_Matrix m; - FT_Vector v; - FT_Error fterr; - fz_pixmap *glyph; - int y; - /* Fudge the font matrix to stretch the glyph if we've substituted the font. */ if (font->ftsubstitute && gid < font->widthcount) { + FT_Error fterr; int subw; int realw; float scale; /* TODO: use FT_Get_Advance */ - fterr = FT_Set_Char_Size(face, 1000, 1000, 72, 72); + fterr = FT_Set_Char_Size(font->ftface, 1000, 1000, 72, 72); if (fterr) fz_warn("freetype setting character size: %s", ft_errorstring(fterr)); @@ -255,9 +249,24 @@ fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) else scale = 1; - trm = fz_concat(fz_scale(scale, 1), trm); + return fz_concat(fz_scale(scale, 1), trm); } + return trm; +} + +fz_pixmap * +fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) +{ + FT_Face face = font->ftface; + FT_Matrix m; + FT_Vector v; + FT_Error fterr; + fz_pixmap *glyph; + int y; + + trm = fz_adjustftglyphwidth(font, gid, trm); + /* Freetype mutilates complex glyphs if they are loaded with FT_Set_Char_Size 1.0. it rounds the coordinates @@ -354,6 +363,8 @@ fz_renderftstrokedglyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz fz_pixmap *pix; int y; + trm = fz_adjustftglyphwidth(font, gid, trm); + m.xx = trm.a * 64; /* should be 65536 */ m.yx = trm.b * 64; m.xy = trm.c * 64; |