summaryrefslogtreecommitdiff
path: root/include/freetype/ftstroke.h
diff options
context:
space:
mode:
authorDavid Bevan <david.bevan@pb.com>2011-07-02 12:09:52 +0200
committerWerner Lemberg <wl@gnu.org>2011-07-02 12:09:52 +0200
commitaecbfe1ba775d683f3395f0f9214a394feb8b63b (patch)
treec8870b8f5e9901e2304a836f317d6c59a055d490 /include/freetype/ftstroke.h
parentee5d3b5947618c603353752e39b610e91ee2cb4c (diff)
downloadfreetype2-aecbfe1ba775d683f3395f0f9214a394feb8b63b.tar.gz
[ftstroke] Major revision.
The main problems ----------------- o If FT_STROKER_LINEJOIN_BEVEL was specified, unlimited miter joins (not bevel joins) were generated. Indeed, the meanings of `miter' and `bevel' were incorrectly reversed (consistently) in both the code and comments. o The way bevel joins were constructed (whether specified explicitly, or created as a result of exceeding the miter limit) did not match what is required for stroked text in PostScript or PDF. The main fixes -------------- o The behaviour of FT_STROKER_LINEJOIN_BEVEL has been corrected. o A new line join style, FT_STROKER_LINEJOIN_MITER_FIXED, has been introduced to support PostScript and PDF miter joins. o FT_STROKER_LINEJOIN_MITER_VARIABLE has been introduced as an alias for FT_STROKER_LINEJOIN_MITER. Additionally, a variety of stroking errors have been fixed. These would cause various artifacts (including points `at infinity'), especially when stroking poor quality fonts. See http://lists.gnu.org/archive/html/freetype-devel/2011-07/msg00001.html for example documents. The FreeType stroker now produces results very similar to that produced by GhostScript and Distiller for these fonts. Other problems -------------- The following problems have been resolved: o Inside corners could be generated incorrectly. Intersecting the inside corner could cause a missing triangular area and other effects. The intersection point can only be used if the join is between two lines and both lines are long enough. The `optimization' condition in `ft_stroker_inside' has been corrected; this requires the line length to be passed into various functions and stored in `FT_StrokerRec'. o Incorrect cubic curves could be generated. The angle calculations in `FT_Stroker_CubicTo' have been corrected to handle the case of the curve crossing the +/-PI direction. o If the border radius was greater than the radius of curvature of a curve, then the negative sector would end up outside (not inside) the border. This situation is now recognized and the negative sector is circumnavigated in the opposite direction. (If round line joins are being used, this code is disabled because the line join will always cover the negative sector.) o When a curve is split, the arcs may not join smoothly (especially if the curve turns sharply back on itself). Changes in direction between adjacent arcs were not handled. A round corner is now added if the deviation from one arc to the next is greater than a suitable threshold. o The current direction wasn't retained if a the outline contained a zero length lineto or a curve that was determined to be `basically a point'. This could cause a spurious join to be added. o Cubics with close control points could be mishandled. All eight cases are now distinguished correctly. Other improvements ------------------ o Borders for cubic curves could be too `flat'. FT_SMALL_CUBIC_THRESHOLD has been reduced a little to prevent this. o The handling and use of movable points has been simplified a little. o Various values are now computed only if the results are actually needed. o The directions of the outer and inner borders have been swapped, as recommended by Graham Asher. * src/base/ftstroke.c: Revised. * include/freetype/ftstroke.h: Updated.
Diffstat (limited to 'include/freetype/ftstroke.h')
-rw-r--r--include/freetype/ftstroke.h49
1 files changed, 37 insertions, 12 deletions
diff --git a/include/freetype/ftstroke.h b/include/freetype/ftstroke.h
index 3afb87df8..dbda6d23d 100644
--- a/include/freetype/ftstroke.h
+++ b/include/freetype/ftstroke.h
@@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (specification). */
/* */
-/* Copyright 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */
+/* Copyright 2002-2006, 2008, 2009, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -75,20 +75,44 @@ FT_BEGIN_HEADER
* to join two lines smoothly.
*
* FT_STROKER_LINEJOIN_BEVEL ::
- * Used to render beveled line joins; i.e., the two joining lines
- * are extended until they intersect.
- *
+ * Used to render beveled line joins. The outer corner of
+ * the joined lines is filled by enclosing the triangular
+ * region of the corner with a straight line between the
+ * outer corners of each stroke.
+ *
+ * FT_STROKER_LINEJOIN_MITER_FIXED ::
+ * Used to render mitered line joins, with fixed bevels if the
+ * miter limit is exceeded. The outer edges of the strokes
+ * for the two segments are extended until they meet at an
+ * angle. If the segments meet at too sharp an angle (such
+ * that the miter would extend from the intersection of the
+ * segments a distance greater than the product of the miter
+ * limit value and the border radius), then a bevel join (see
+ * above) is used instead. This prevents long spikes being
+ * created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter
+ * line join as used in PostScript and PDF.
+ *
+ * FT_STROKER_LINEJOIN_MITER_VARIABLE ::
* FT_STROKER_LINEJOIN_MITER ::
- * Same as beveled rendering, except that an additional line
- * break is added if the angle between the two joining lines
- * is too closed (this is useful to avoid unpleasant spikes
- * in beveled rendering).
+ * Used to render mitered line joins, with variable bevels if
+ * the miter limit is exceeded. The intersection of the
+ * strokes is clipped at a line perpendicular to the bisector
+ * of the angle between the strokes, at the distance from the
+ * intersection of the segments equal to the product of the
+ * miter limit value and the border radius. This prevents
+ * long spikes being created.
+ * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line
+ * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias
+ * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for
+ * backwards compatibility.
*/
typedef enum FT_Stroker_LineJoin_
{
- FT_STROKER_LINEJOIN_ROUND = 0,
- FT_STROKER_LINEJOIN_BEVEL,
- FT_STROKER_LINEJOIN_MITER
+ FT_STROKER_LINEJOIN_ROUND = 0,
+ FT_STROKER_LINEJOIN_BEVEL = 1,
+ FT_STROKER_LINEJOIN_MITER_VARIABLE = 2,
+ FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE,
+ FT_STROKER_LINEJOIN_MITER_FIXED = 3
} FT_Stroker_LineJoin;
@@ -245,7 +269,8 @@ FT_BEGIN_HEADER
* The line join style.
*
* miter_limit ::
- * The miter limit for the FT_STROKER_LINEJOIN_MITER style,
+ * The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and
+ * FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles,
* expressed as 16.16 fixed point value.
*
* @note: