summaryrefslogtreecommitdiff
path: root/fitz/base_geometry.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/base_geometry.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/base_geometry.c')
-rw-r--r--fitz/base_geometry.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fitz/base_geometry.c b/fitz/base_geometry.c
index 3269605d..e8d9032f 100644
--- a/fitz/base_geometry.c
+++ b/fitz/base_geometry.c
@@ -121,6 +121,22 @@ fz_matrix_expansion(fz_matrix m)
return sqrtf(fabsf(m.a * m.d - m.b * m.c));
}
+float
+fz_matrix_max_expansion(fz_matrix m)
+{
+ float max = fabsf(m.a);
+ float x = fabsf(m.b);
+ if (max < x)
+ max = x;
+ x = fabsf(m.c);
+ if (max < x)
+ max = x;
+ x = fabsf(m.d);
+ if (max < x)
+ max = x;
+ return max;
+}
+
fz_point
fz_transform_point(fz_matrix m, fz_point p)
{