Move the af_sort_xxx() functions from afangles.c to afhints.c
in order to get rid of the obsolete angle-related types,
macros and function definitions.
This feature was always experimental, and probably nevery worked
properly. This patch completely removes it from the source code,
except for a documentation block describing it for historical
purpose.
We no longer have to take care of the 8.3 file name limit; this
allows us (a) to introduce longer, meaningful file names, and (b) to
avoid macro names in `#include' lines altogether since some
compilers (most notably Visual C++) doesn't support this properly.
*/*: Replace
#include FOO_H
with
#include <freetype/foo.h>
or something similar. Also update the documentation.
Before this commit we had code like
(FT_Bool)( globals->glyph_styles[gindex] & 0x8000)
Since `FT_Bool' is defined to be an `unsigned char', the code
evaluated to something like
(unsigned char)( 0x8532 & 0x8000)
which in turn expanded to
(unsigned char)( 0x8000)
and finally yielded 0x00 – i.e., false – not as expected.
Problem reported and analyzed by Tony Smith <tony.smith@macro4.com>.
* include/freetype/fttypes.h (FT_BOOL): Add a comparison against
zero so that we always have a Boolean expression.
*/*: Replace castings to `FT_Bool' with calls to `FT_BOOL' where
possible.
* src/autofit/afhints.h (AF_PointRec) [FT_DEBUG_AUTOFIT]: New arrays
`before' and `after'.
* src/autofit/afhints.c (af_get_strong_edge_index): New auxiliary
function.
(af_glyph_hints_dump_points): Trace `before' and `after' edges.
(af_glyph_hints_align_strong_points) [FT_DEBUG_AUTOFIT]: Set
`before' and `after' information.
This monster commit was created by applying Nikhil's scripts
`docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.
No change in functionality, of course.
I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
* src/autofit/afhints.c (af_glyph_hints_dump_segments): Trace
`delta' also.
Don't show first point of segment as a replacement for `pos'; this
is (a) misleading, since the difference to `pos' can be almost
arbitrarily large in corner cases, and (b) it is better to have all
segment data in font units instead of a single value given in output
space coordinates.
Improve layout.
(af_glyph_hints_dump_edges): Show px->units and units->px conversion
values for convenience.
Improve layout.
This improves rendering of scripts like Bengali or Devanagari.
* src/autofit/afhints.c (af_axis_hints_new_edge): Add parameter to
pass top-to-bottom hinting flag. This makes the function sort edges
in descending vertical position.
* src/autofit/afhints.c: Updated.
* src/autofit/aflatin.c (af_latin_hints_compute_edges,
af_latin_hint_edges): Use `top_to_bottom_hinting' flag.
* src/autofit/afcjk.c (af_cjk_hints_compute_edges),
src/autofit/aflatin2.c (af_latin2_hints_compute_edges): Updated.
* src/autofit/afhints.c (af_print_idx, af_get_segment_index,
af_get_edge_index): New functions.
(af_glyph_hints_dump_points): Remove unnecessary `|', `[', and `]'.
Add segment and edge index for each point.
Slightly change printing order of some elements.
Don't print `-1' but `--' for missing elements.
(af_glyph_hints_dump_segments, af_glyph_hints_dump_edges): Remove
unnecessary `|', `[', and `]'.
Don't print `-1' but `--' for missing elements.
This harmonizes with other code in FreeType (and reduces the number
of necessary casts to avoid compiler warnings).
* src/autofit/afblue.hin: Make flag macros unsigned.
* src/autofit/afblue.h: Regenerated.
* src/autofit/afcjk.h: Replace flag enumeration with macros.
* src/autofit/afcjk.c: Updated.
* src/autofit/afhints.h (AF_Flags, AF_Edge_Flags): Replace with
macros.
* src/autofit/afhints.c: Updated.
* src/autofit/aflatin.h: Replace flag enumerations with macros.
* src/autofit/aflatin.c, src/autofit/aflatin2.c: Updated.
* src/autofit/aftypes.h (AF_ScalerFlags): Replace with macros.
While this doesn't show up with FreeType, exactly the same code
leaks with ttfautohint's modified auto-hinter code (which gets used
in a slightly different way).
It certainly doesn't harm since it is similar to already existing
checks in the code for embedded arrays.
* src/autofit/afhints.c (af_glyph_hints_reload): Set `max_contours'
and `max_points' for all cases.
Avoids multiple mallocs per typical glyphs.
With this and recent changes to avoid mallocs, the thread-safe
stack-based loader is now as fast as the previous model that had one
cached singleton.
* src/autofit/afhints.h (AF_SEGMENTS_EMBEDDED, AF_EDGES_EMBEDDED):
New macros.
(AF_AxisHintsRec): Add two arrays for segments and edges.
* src/autofit/afhints.c (af_axis_hints_new_segment): Only allocate
data if number of segments exceeds given threshold value.
(af_axis_hints_new_edge): Only allocate data if number of edges
exceeds given threshold value.
(af_glyph_hints_done): Updated.
This avoids at least two malloc calls for typical glyphs.
* src/autofit/afhints.h (AF_POINTS_EMBEDDED, AF_CONTOURS_EMBEDDED):
New macros.
(AF_GlyphHintsRec): Add two arrays for contours and points.
* src/autofit/afhints.c (af_glyph_hints_init, af_glyph_hints_done):
Updated.
(af_glyph_hints_reload): Only allocate data if number of contours or
points exceeds given threshold values.
Using `%ld' for pointer differences causes warnings on 32bit
platforms. The correct type would be (the relatively new) `%td',
however, this is missing on some important platforms.
This patch improves the change from 2014-11-28.
* src/autofit/afhints.c (AF_INDEX_NUM): Use `int' typecast. Our
pointer differences are always sufficiently small.
(af_glyph_hints_dump_points, af_glyph_hints_dump_segments,
af_glyph_hints_dump_edge): Revert to `%d' and use `AF_INDEX_NUM'.
Problem reported by Ralf S. Engelschall <rse@engelschall.com>.
* src/autofit/afhints.c (af_glyph_hints_reload): Fix threshold for
finding first non-near point.
Properly initialize non-near point deltas.
In particular, local extrema without horizontal or vertical segments
are better recognized:
+ A + D
\ /
\ /
\ /
\ /
\ + C
\ /
B +/
If the distances AB and CD are large, point B wasn't previously
detected as an extremum since the `ft_corner_is_flat' function
`swallowed' BC regardless of its direction, tagging point B as weak.
The next iteration started at B and made `ft_corner_is_flat' swallow
point C, tagging it as weak also, et voilà.
To improve that, another pass gets now performed before calling
`ft_corner_is_flat' to improve the `topology' of an outline: A
sequence of non-horizontal or non-vertical vectors that point into
the same quadrant are handled as a single, large vector.
Additionally, distances of near points are now accumulated, which
makes the auto-hinter handle them as if they were prepended to the
next non-near vector.
This generally improves the auto-hinter's rendering results.
* src/autofit/afhints.c (af_glyph_hints_reload): Implement it.
* src/autofit/afhints.h (AF_FLAGS): Remove no longer used flag
`AF_FLAG_NEAR'.