diff options
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/base_geometry.c | 10 | ||||
-rw-r--r-- | fitz/fitz.h | 1 | ||||
-rw-r--r-- | fitz/res_font.c | 19 |
3 files changed, 29 insertions, 1 deletions
diff --git a/fitz/base_geometry.c b/fitz/base_geometry.c index bd333dfa..302ef966 100644 --- a/fitz/base_geometry.c +++ b/fitz/base_geometry.c @@ -31,6 +31,16 @@ fz_scale(float sx, float sy) } fz_matrix +fz_shear(float h, float v) +{ + fz_matrix m; + m.a = 1; m.b = v; + m.c = h; m.d = 1; + m.e = 0; m.f = 0; + return m; +} + +fz_matrix fz_rotate(float theta) { fz_matrix m; diff --git a/fitz/fitz.h b/fitz/fitz.h index 3e08a680..9ba9d0b1 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -252,6 +252,7 @@ extern const fz_matrix fz_identity; fz_matrix fz_concat(fz_matrix one, fz_matrix two); fz_matrix fz_scale(float sx, float sy); +fz_matrix fz_shear(float sx, float sy); fz_matrix fz_rotate(float theta); fz_matrix fz_translate(float tx, float ty); fz_matrix fz_invert_matrix(fz_matrix m); 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; |