Commit Graph

109 Commits

Author SHA1 Message Date
David Turner a212668c9f Remove obsolete AF_Angle type and related sources.
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.
2021-07-12 09:25:39 +02:00
David Turner 2f11522a2a Remove experimental auto-hinting 'warp' mode.
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.
2021-07-12 09:25:22 +02:00
Werner Lemberg b6e8a71266 Update all copyright notices. 2021-01-17 07:18:48 +01:00
David Turner e13391333f Make macros for header file names optional.
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.
2020-06-08 13:31:55 +02:00
Werner Lemberg e5038be704 Update all copyright notices. 2020-01-19 17:05:19 +01:00
Werner Lemberg 7585997024 Update all copyright notices. 2019-02-23 10:07:09 +01:00
Werner Lemberg f686ad46a3 Update copyright years. 2019-01-22 20:31:44 +01:00
Werner Lemberg a9af691481 Fix handing of `FT_Bool'.
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.
2018-09-25 09:10:09 +02:00
Werner Lemberg 0d4ca13865 * src/autofit/afhints.c (af_glyph_hints_reload): Add initialization. 2018-08-31 06:53:52 +02:00
Werner Lemberg c0ccf75012 [autofit] Trace `before' and `after' edges of strong points.
* 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.
2018-08-30 09:56:09 +02:00
Werner Lemberg a0dd16fb3d Don't use `trace_' prefix for FT_COMPONENT arguments.
* include/freetype/internal/ftdebug.h (FT_TRACE_COMP,
FT_TRACE_COMP_): New auxiliary macros to add `trace_' prefix.
(FT_TRACE): Use `FT_TRACE_COMP'.

*/* (FT_COMPONENT): Updated.
2018-08-15 18:13:17 +02:00
Werner Lemberg 9ac9060df0 [GSoC] src/*.*: Convert block comments to `light' style.
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.
2018-06-03 09:08:41 +02:00
Werner Lemberg 0a0c22569d Update copyright year. 2018-01-02 09:33:57 +01:00
Werner Lemberg 8768536c89 [autofit] Better visualize table tracing in source code. 2017-10-12 00:13:51 +02:00
Werner Lemberg 0ab2b62d3f [autofit] Improve communication with ftgrid.
* src/autofit/afhints.c (af_glyph_hints_get_segment_offset):
Provide values in font units.
2017-09-09 08:08:47 +02:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 4441f7b246 Replace `foo == NULL' and `foo != NULL' with `!foo' and `foo', resp.
Other minor formatting.
2016-12-26 17:08:17 +01:00
Werner Lemberg 1831e6f068 [autofit] Update and improve segment and edge tracing.
* 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.
2016-07-15 10:35:32 +02:00
Werner Lemberg 614a8f17c7 * src/autofit/afhints.c (af_glyph_hints_reload): Thinko.
This fixes the previous commit to this file.
2016-03-21 19:39:14 +01:00
Werner Lemberg 709486db7f [autofit] Show `near' points in tracing.
* src/autofit/afhints.h (AF_FLAG_NEAR): New macro.

* src/autofit/afhints.c (af_glyph_hints_dump_points): Implement it.
(af_glyph_hints_reload): Handle AF_FLAG_NEAR.
2016-03-20 22:20:32 +01:00
Werner Lemberg baa41ff204 [autofit] Minor tracing improvement.
* src/autofit/afhints.c (af_glyph_hints_dump_points): Insert newline
at the start of a new contour.
2016-01-30 07:44:30 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg 2e09812c51 [autofit] Make top-to-bottom hinting work in latin auto-hinter.
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.
2015-12-25 08:05:30 +01:00
Werner Lemberg 68fb4789a5 * src/autofit/afhints.c (af_get_segment_index): Fix it.
The old code was too simple, returning invalid values in most cases
where a segment crosses the contour start.
2015-11-15 13:06:48 +01:00
Werner Lemberg 02cfd71498 * src/autofit/afhints.c (af_glyph_hints_dump_points): Minor. 2015-10-29 20:50:57 +01:00
Werner Lemberg 7f00fa6462 [autofit] Improve tracing.
* 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.
2015-10-25 10:59:59 +01:00
Werner Lemberg a678560dc2 Minor. 2015-05-28 17:31:15 +02:00
Alexei Podtelezhnikov 4091495271 [autofit] Speed up IUP.
* src/autofit/afhints.c (af_iup_interp): Separate trivial snapping to
the same position from true interpolation, use `scale' to reduce divisions.
2015-04-29 21:57:30 -04:00
Alexei Podtelezhnikov 67b912d2fa * src/autofit/afhints.c (af_glyph_hints_reload): Use do-while loop. 2015-04-03 22:38:11 -04:00
Alexei Podtelezhnikov 886f4d0493 [autofit] Finish the thought.
* src/autofit/afhints.c (af_direction_compute): make sure the long arm
is never negative so that its `FT_ABS' is not necessary.
2015-04-01 22:57:43 -04:00
Werner Lemberg a2fa657a03 [autofit] Call dumper functions for tracing.
* src/autofit/afcjk.c (af_cjk_hints_apply): Remove dead code.
* src/autofit/afhints.c (af_glyph_hints_dump_points): Minor
improvement.
* src/autofit/afmodule.c (af_autofitter_load_glyph): Implement it.
2015-04-01 15:55:41 +02:00
Werner Lemberg 16217e5f22 * src/autofit/afhints.c (af_glyph_hints_done): Fix minor thinko. 2015-04-01 13:13:56 +02:00
Werner Lemberg b57bb11ad0 [autofit] Fix signedness issues.
* src/autofit/afangles.c, src/autofit/afcjk.c,
src/autofit/afglobal.c, src/autofit/afhints.c,
src/autofit/aflatin.c, src/autofit/aflatin2.c, src/autofit/afwarp.c,
src/autofit/hbshim.c: Apply.
2015-02-19 10:44:18 +01:00
Werner Lemberg 81e5ff53a8 [autofit] Use macros for (unsigned) flags, not enumerations.
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.
2015-02-19 09:46:48 +01:00
Werner Lemberg b6cb4997e8 [autofit] Fix potential memory leak.
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.
2015-02-06 08:46:06 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Behdad Esfahbod 56ddafa01c [autofit] Add embedded array of segments and edges.
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.
2015-01-14 19:36:02 +01:00
Behdad Esfahbod 6f16b10019 [autofit] Add embedded arrays for points and contours.
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.
2015-01-14 19:26:49 +01:00
Werner Lemberg a632b5f406 [autofit] Better fix for conversion specifiers in debug messages.
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'.
2014-12-03 19:30:44 +01:00
suzuki toshiya 9ee6a0a085 Fix compiler warning to conversion specifiers in debug messages.
* src/autofit/afhints.c (af_glyph_hints_dump_points): Add length
modifier to dump long integers.  (af_glyph_hints_dump_segments,
af_glyph_hints_dump_edges): Ditto.
2014-11-28 11:14:18 +09:00
Werner Lemberg 5b68e4fb60 [autofit] Minor clean-ups.
* src/autofit/afhints.c (AF_FLAGS): Remove obsolete values.

* src/autofit/afhints.c (af_glyph_hints_dump_points,
af_glyph_hints_align_strong_points): Updated.

* src/autofit/aflatin.c (af_latin_hints_link_segments,
af_latin_hints_compute_segments), src/autofit/afcjk.c
(af_cjk_hints_link_segments), src/autofit/aflatin2.c
(af_latin2_hints_link_segments, af_latin2_hints_compute_segments):
There are no longer fake segments since more than 10 years...
2014-09-24 19:06:13 +02:00
Werner Lemberg 387a9fe73d [autofit] Minor code streamlining.
* src/autofit/afhints.c (af_axis_hints_new_edge): Remove redundant
initialization.
2014-09-22 06:42:24 +02:00
Werner Lemberg faa21472b7 [autofit] Fix variable initializations.
* src/autofit/afhints.c (af_glyph_hints_reload): Assign default
values to `in_dir' and `out_dir' for all points.
2014-05-11 12:44:00 +02:00
Werner Lemberg 07e7b8affe [autofit] Fix crash with font `CabinSketch-Bold.ttf'.
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.
2014-05-11 08:00:25 +02:00
Werner Lemberg 8a94b1efd6 [autofit] Redesign the recognition algorithm of strong points.
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'.
2014-04-12 20:44:33 +02:00
Werner Lemberg 7ac76b50da Fix several clang static analyzer dead store warnings.
* src/autofit/afhints.c (af_glyph_hints_reload,
af_glyph_hints_align_weak_points): Remove unnecessary assignments.

* src/bdf/bdflib.c (bdf_font_load): Ditto.

* src/pshinter/pshalgo.c (psh_glyph_compute_extrema,
psh_glyph_interpolate_other_points): Ditto.

* src/type1/t1load.c (T1_Set_MM_Blend): Ditto.
2014-03-04 04:29:17 +01:00
Sean McBride 7be2a94a50 Fix clang static analyzer and compiler warnings.
* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c
(FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style),
src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c
(cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load),
src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c
(sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next,
tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead
code.

* src/autofit/afmodule.c (af_property_get_face_globals,
af_property_set, af_property_get), src/base/ftbitmap.c
(ft_gray_for_premultiplied_srgb_bgra): Make functions static.

* src/base/ftobjs.c (ft_remove_renderer): Protect against
library == NULL.
(ft_property_do): Make function static.

* src/base/ftrfork.c: Include `ftbase.h'.

* src/sfnt/ttsbit.c (tt_face_load_sbix_image)
[!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c
(T1_Compute_Max_Advance): Avoid compiler warning.

* src/truetype/ttinterp.c (TT_New_Context): Reduce scope of
variable.
2014-02-08 13:55:38 +01:00
Werner Lemberg 5c7f5500e8 [autofit] Better ftgrid support.
* src/autofit/afhints.c (af_glyph_hints_get_segment_offset): Add
parameters `is_blue' and `blue_offset'.
2014-01-03 10:48:26 +01:00
Werner Lemberg 3f91cb338b [autofit] s/ScriptMetrics/StyleMetrics/. 2013-12-18 12:59:35 +01:00
Werner Lemberg 52166ab0a7 [autofit] Fix use of dumping functions in `ftgrid' demo program.
* src/autofit/afhints.c (AF_DUMP) [FT_DEBUG_AUTOFIT]: New macro.
(af_glyph_hints_dump_points, af_glyph_hints_dump_segments,
af_glyph_hints_dump_edges) [FT_DEBUG_AUTOFIT]: Add parameter to
handle output to stdout.
Use AF_DUMP.
(af_glyph_hints_dump_points, af_glyph_hints_dump_segments,
af_glyph_hints_dump_edges) [!FT_DEBUG_AUTOFIT]: Removed.
2013-11-27 10:10:16 +01:00