After FreeType switched type1 and t1cid drivers to the Adobe engine
a while ago, we could flag them as DRIVER_HINTS_LIGHTLY. We do it now
explicitly in the driver_init and the property_set functions as a
future reminder. This simplifies the conditions for autohinting.
* src/base/ftobjs.c (FT_Load_Glyph): Rely only on !DRIVER_HINTS_LIGHTLY
when selecting the autohinter for the LIGHT mode.
* src/cff/cffdrivr.c (cff_driver_class): Move the flag from here...
* src/cff/cffobjs.c (cff_driver_init): ... to here, explicitly.
* src/cid/cidobjs.c (sid_driver_init): Set it explicitly.
* src/type1/t1objs.c (T1_Driver_Init): Set it explicitly.
* src/base/ftpsprop.c (ps_property_set): Sync the flags when switching.
Fixes#1351 and various warnings about unused variables.
* src/truetype/ttinterp.c: Put the entire body under #ifdef.
* src/truetype/ttgload.c (TT_Process_Composite_Glyph): Relocate
some declarations.
* src/truetype/ttinterp.h: Remove some #ifdef conditions.
* src/truetype/ttobjs.c (tt_size_done): Modified.
For example, with `GoogleSansFlex-Regular.ttf` at ROND=100, the 'Q' glyph
was misrendering.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Reset `tupleScalars`
earlier.
* include/freetype/internal/ftcalc.h [__VMS]: Undefine `FT_MulFix`.
* src/base/ftcalc.c [vms_auto64_source]: Define `FT_MulFix`.
* vms_make.com: Also create 32bit version of the FreeType library.
Call T1_Set_MM_WeightVector, which actually sets default weights,
instead of TT_Set_MM_Blend, which just centers the axes.
* src/type1/t1load.c (T1_Reset_MM_Blend): Do it.
* include/freetype/internal/services/svmetric.h (FT_Size_Reset_Func):
Update typedef, do not return error.
* src/truetype/ttobjs.c (tt_size_reset_height): Move the PPem error
handling from here...
(tt_size_reset): ... to here to improve readability.
src/truetype/ttobjs.h (tt_size_reset_height): Update prototype.
It is possible to have a fractional part after rounding when rounding
to half-grid or super-rounding. The specs call to ignore the fractional
part in that case.
^ src/truetype/ttinterp.c (Ins_EVEN, Ins_ODD): Fix mask.
The rounding color compensation, which is not used by FreeType, belongs
to GS. This is a more logical place for it, next to round_state.
* src/truetype/ttobjs.h (TT_GraphicsState): Move compensations here...
(TT_Size_Metrics): ... from here.
* src/truetype/ttobjs.c (tt_size_init_bytecode): Updated.
* src/truetype/ttinterp.c (tt_default_graphics_state): Updated.
(Ins_ROUND,NROUND,EVEN,ODD): Updated.
(Round_*): Updated.
To support WASM targets with slow or unsupported setjmp and longjmp,
we eliminate these calls in favor of an error propagation model.
When gray_set_cell is out of cells, it raises an exception which is
later handled in gray_convert_glyph_inner.
This is a less invasive alternative to !385.
* src/smooth/ftgrays.c (gray_set_cell): Raise the overflow exception
and redirect all work to `cell_null`.
(gray_move,line,conic,cubic_to): Return the exception.
(gray_convert_glyph, gray_convert_glyph_inner): Handle the exception.
The previous code had a fundamental flaw: it didn't validate the necessary
parts of the 'GPOS' table before accessing it, causing crashes with
malformed data (since `TT_CONFIG_OPTION_GPOS_KERNING` is off by default,
standard fuzzers don't catch these problems). Additionally, it did a lot of
parsing while accessing kerning data, making it rather slow.
The new implementation fixes this. After validation, offsets to the 'GPOS'
lookup subtables used in the 'kern' feature that correspond to 'simple'
kerning (i.e., similar to 'kern' table kerning) are stored in `TT_Face`;
this greatly simplifies and accelerates access to the kerning data.
Testing with font `SF-Pro.ttf` version '1.00', the validation time for the
'GPOS' table increases the start-up time of `FT_New_Face` by less than 1%,
while calls to `FT_Get_Kerning` become about 3.5 times faster.
* include/freetype/internal (gpos_kerning_available): Replace with...
(gpos_lookups_kerning, num_gpos_lookups_kerning): ... these new fields.
Update callers.
* src/ttgpos.c [TT_CONFIG_OPTION_GPOS_KERNING]: A new implementation.
Given that we also support (limited) 'GPOS' table kerning if
`TT_CONFIG_OPTION_GPOS_KERNING` is defined, the name of this macro is
misleading since it only is true for 'kern' table kerning.
* src/sfnt/sfobjs.c (sfn_load_face): Replace `TT_FACE_HAS_KERNING` with
plain code.
We completely validate the accessed data from the 'GSUB' table, making this
field unnecessary.
* src/autofit/afglobal.h (AF_FaceGlobalsRec): Remove `gsub_length` field.
* src/autofit/afglobal.c (af_face_globals_new), src/autofit/afgsub.c
(af_parse_gsub): Updated.
As reported by clang 19.
* src/autofit/afadjust.c (add_substitute): Make first argument unsigned.
Update all callers.
Other minor signedness fixes.
(af_reverse_character_map_new): Minor signedness fixes.
* src/autofit/afgsub.c (af_hash_insert): Minor signedness fixes.
* src/autofit/aflatin.c
(af_glyph_hints_apply_vertical_separation_adjustments): Make third
argument unsigned.
Update all callers.
Other minor signedness fixes.
(af_latin_hints_apply): Minor signedness fixes.
* src/bdf/bdflib.c (bdf_parse_bitmap_): Minor signedness fix.
* src/truetype/ttobjs.c (tt_size_init_bytecode): Minor signedness fix.
Due to the new GSUB parsing we no longer need
`hb_ot_layout_lookup_get_glyph_alternates`.
This partially reverts commit 5d2fd7608a.
* CMakeLists.txt (HARFBUZZ_MIN_VERSION), meson.build (harfbuzz_dep),
builds/unix/configure.raw (harfbuzz_pkg): Set version to 2.0.0.
* src/autofit/ft-hb-decls.h: Remove entry for
`hb_ot_layout_lookup_get_glyph_alternates`.
With this commit, the start-up time for creating the reverse character map
gets reduced from more than 300% to about 25% (as tested with `arial.ttf`
version 7.00).
* src/autofit/afadjust.c [FT_CONFIG_OPTION_USE_HARFBUZZ]: Include
`afgsub.h`.
(add_substitute): New auxiliary function to recursively add elements to
the reverse cmap.
(af_reverse_character_map_new): New code that replaces the old code
removed in the previous commit.
Rip out some HarfBuzz code of `af_reverse_character_map_new`. The new code
comes immediately in a follow-up commit, making it easier to follow the
changes.
* src/autofit/afadjust.c (af_get_glyph_alternates_helper,
af_get_glyph_alternates): Remove.
(af_reverse_character_map_new): Remove code to create the `*map` hash.
Create an array of GSUB lookup indices for `SingleSubst` and
`AlternateSubst` lookup types to exit early if we have different types.
Also improve tracing.
* src/autofit/afglobal.h (AF_FaceGlobals) [FT_CONFIG_OPTION_USE_HARFBUZZ]:
New fields `gsub_length`, `gsub`, and `gsub_lookups_single_alternate`.
* src/autofit/afglobal.c [FT_CONFIG_OPTION_USE_HARFBUZZ]: Include
`afgsub.h`.
(af_face_globals_new) [FT_CONFIG_OPTION_USE_HARFBUZZ]: Call
`af_parse_gsub` to fill `gsub_lookups_single_alternate`.
(af_face_globals_free): Updated.
* src/autofit/afadjust.c (af_get_glyph_alternates_helper): Exit early if we
possible.
(af_reverse_character_map_new): Trace GSUB lookup indices to be checked.
Using HarfBuzz's API functions to construct the reverse map is too slow; we
have to call `hb_ot_layout_lookup_get_glyph_alternates` far too often
because it can only handle a single glyph at a time. For this reason we are
going to parse the GSUB table by ourselves.
The new non-local functions are `af_parse_gsub` and `af_map_lookup`.
* src/autofit/afgsub.c, src/autofit/afgsub.h: New files for parsing,
validating, and mapping the `SingleSubst` and `AlternateSubst` subtable
types of a GSUB table.
* src/autofit/autofit.c, src/autofit/rules.mk (AUTOF_DRV_SRC): Updated.
According to specifications, CVT and storage area may or may not be
persistent after modifications by a glyf program. FreeType had always
reset them, which was broken by the last commit.
* src/truetype/ttinterp.c (TT_Load_Context): Set CVT and storage here.
* src/truetype.ttobjs.c (tt_size_run_prep): Prioritize TT_Load_Context.
(tt_size_init_bytecode): Allocate but not set CVT and storage area.
To avoid repeated synchronization, some TT_Size allocations are moved
TT_ExecContext for good. The memory blocks are also consolidated.
* src/truetype/ttinterp.c (TT_{Load,Save,Done}_Context): Remove
synchronization and stack management.
* src/truetype/ttobjs.c (tt_size_{init,done}_bytecode): Manage allocations
and assign them to the execution context.
(tt_size_run_prep): Updated.