summaryrefslogtreecommitdiff
path: root/fitz/res_font.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-01-12 15:34:30 +0000
committerRobin Watts <robin.watts@artifex.com>2012-01-12 20:15:09 +0000
commitf0d427993c1b9b40f1bc0b77ed9c0433099f2a5d (patch)
treec89144197a2aafec4dac4a05506dad93e098ebdc /fitz/res_font.c
parent269a44d92e2fc15631b86cc0c7135baf2023f312 (diff)
downloadmupdf-f0d427993c1b9b40f1bc0b77ed9c0433099f2a5d.tar.xz
Support proper XPS mitering. (And stroke fixes).
XPS differs from PS/PDF/etc in the way it handles miters; rather than simply converting a miter that's overly long to a bevel, it truncates it at the miter limit. As such it needs to be handled correctly. For clarity, expose new enumerated types for linejoins and linecaps, and use these throughout code. When we upgrade our freetype, we can move to using proper xps mitering in that too. Add new fz_matrix_max_expansion function to return a safer expansion value that works in the case where we scale up in one direction and down in another. In the xps path drawing code, avoid generating unnecessary linetos. Thanks to Zeniko for spotting these and providing implementations.
Diffstat (limited to 'fitz/res_font.c')
-rw-r--r--fitz/res_font.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/fitz/res_font.c b/fitz/res_font.c
index c3e2e0bd..4a1c9dfa 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -449,6 +449,7 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix tr
FT_Glyph glyph;
FT_BitmapGlyph bitmap;
fz_pixmap *pixmap;
+ FT_Stroker_LineJoin line_join;
trm = fz_adjust_ft_glyph_width(ctx, font, gid, trm);
@@ -485,7 +486,19 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix tr
return NULL;
}
- FT_Stroker_Set(stroker, linewidth, state->start_cap, state->linejoin, state->miterlimit * 65536);
+#if 0
+ line_join = state->linejoin == FZ_LINEJOIN_MITER ? FT_STROKER_LINEJOIN_MITER_FIXED :
+ state->linejoin == FZ_LINEJOIN_ROUND ? FT_STROKER_LINEJOIN_ROUND :
+ state->linejoin == FZ_LINEJOIN_BEVEL ? FT_STROKER_LINEJOIN_BEVEL :
+ FT_STROKER_LINEJOIN_MITER_VARIABLE;
+#else
+ /* Until we upgrade freetype */
+ line_join = state->linejoin == FZ_LINEJOIN_MITER ? FT_STROKER_LINEJOIN_MITER :
+ state->linejoin == FZ_LINEJOIN_ROUND ? FT_STROKER_LINEJOIN_ROUND :
+ state->linejoin == FZ_LINEJOIN_BEVEL ? FT_STROKER_LINEJOIN_BEVEL :
+ FT_STROKER_LINEJOIN_MITER;
+#endif
+ FT_Stroker_Set(stroker, linewidth, state->start_cap, line_join, state->miterlimit * 65536);
fterr = FT_Get_Glyph(face->glyph, &glyph);
if (fterr)