summaryrefslogtreecommitdiff
path: root/fitz/res_font.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-15 11:29:02 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-15 11:33:53 +0200
commit68ddf2e5505b3b6295f2373fdac8a5b296bb441c (patch)
treed8890ffad8dd2cc82ac898e377af82fb052eff15 /fitz/res_font.c
parent33a189cce63587e52d76bffadcd547a55818cf92 (diff)
downloadmupdf-68ddf2e5505b3b6295f2373fdac8a5b296bb441c.tar.xz
Use artificial italics and emboldening for substitute font.
Diffstat (limited to 'fitz/res_font.c')
-rw-r--r--fitz/res_font.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/fitz/res_font.c b/fitz/res_font.c
index b564b45b..e255c406 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -13,7 +13,11 @@ fz_new_font(char *name)
font = fz_malloc(sizeof(fz_font));
font->refs = 1;
- fz_strlcpy(font->name, name, sizeof font->name);
+
+ if (name)
+ fz_strlcpy(font->name, name, sizeof font->name);
+ else
+ fz_strlcpy(font->name, "(null)", sizeof font->name);
font->ft_face = NULL;
font->ft_substitute = 0;
@@ -316,6 +320,9 @@ fz_render_ft_glyph(fz_font *font, int gid, fz_matrix trm)
trm = fz_adjust_ft_glyph_width(font, gid, trm);
+ if (font->ft_italic)
+ trm = fz_concat(fz_shear(0.3f, 0), trm);
+
/*
Freetype mutilates complex glyphs if they are loaded
with FT_Set_Char_Size 1.0. it rounds the coordinates
@@ -378,6 +385,13 @@ fz_render_ft_glyph(fz_font *font, int gid, fz_matrix trm)
}
}
+ if (font->ft_bold)
+ {
+ float strength = fz_matrix_expansion(trm) * 0.04f;
+ FT_Outline_Embolden(&face->glyph->outline, strength * 64);
+ FT_Outline_Translate(&face->glyph->outline, -strength * 32, -strength * 32);
+ }
+
fterr = FT_Render_Glyph(face->glyph, fz_get_aa_level() > 0 ? ft_render_mode_normal : ft_render_mode_mono);
if (fterr)
{
@@ -404,6 +418,9 @@ fz_render_ft_stroked_glyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm,
trm = fz_adjust_ft_glyph_width(font, gid, trm);
+ if (font->ft_italic)
+ trm = fz_concat(fz_shear(0.3f, 0), trm);
+
m.xx = trm.a * 64; /* should be 65536 */
m.yx = trm.b * 64;
m.xy = trm.c * 64;