This removes the next set of macros remaining from the PIC support.
* include/freetype/internal/ftobjs.h (FT_DECLARE_GLYPH, FT_DEFINE_GLYPH):
Removed.
* include/freetype/ftglyph.h (FT_Glyph_Class): Make const always.
* src/*: Update all users.
These macros were relics of PIC code removed some time ago. They only hid
the class initializations. We make those explicit again.
* include/freetype/internal/ftobjs.h (FT_DECLARE_MODULE, FT_DEFINE_MODULE,
FT_DECLARE_RENDERER, FT_DEFINE_RENDERER): Removed.
* include/freetype/internal/ftdrv.h (FT_DECLARE_DRIVER, FT_DEFINE_DRIVER):
Removed.
* src/*: Updated all former users.
This is done for consistency with FT_Module_Class and FT_Renderer_Class.
All of these classes are constant and used similarly. The 'Rec' suffix
suggests that these classes are modifiable, when they are not. The old
alias is deprecated.
* include/freetype/internal/ftdrv.h: Do it.
* builds/*, include/*, src/*: Update all users.
All uses of FT_Module_Class are decorated with const now. Therefore,
it make sense to declare it as such to begin with.
* include/freetype/ftmodapi.h (FT_Module_Class): Decorate with const.
* include/freetype/internal/ftobjs.h (FT_Module): Updated.
* src/*: Update all other users.
This is intended to warn against modifying any fields in the class,
at compile-time and avoid crashes at run-time.
* include/freetype/internal/ftobjs.h (FT_ModuleRec): Do it.
* src/base/ftobjs.c (Destroy_Module, FT_Add_Module): Updated.
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.