With this commit, the following warning gets removed.
```
In file included from src/autofit/autofit.c:21:0:
src/autofit/ft-hb.c: In function 'ft_hb_funcs_init':
src/autofit/ft-hb.c:75:35: warning:
variable 'version_atleast' set but not used [-Wunused-but-set-variable]
ft_hb_version_atleast_func_t version_atleast = NULL;
^~~~~~~~~~~~~~~
```
* src/autofit/ft-hb.c (ft_hb_funcs_init): Move `NULL` check of
`version_atleast` out of ifdefs.
* CMakeLists.txt: Set `C_VISIBILITY_PRESET` to hidden for non-Windows only.
Windows handles exports with `DLL_EXPORT` defined, and old MinGW
toolchains emit a lot of warnings about visibility attributes not being
supported in this configuration.
* build/unix/configure.raw: Revise visibility attributes checks by compiling a
better test program with `-Werror` in `CFLAGS` so that warnings correctly
indicate unsupported configurations.
Set `have_harfbuzz*` variables explicitly to dynamic for MinGW, since
Windows uses its own `LoadLibrary` call.
This fixes a MinGW configuration error:
```
checking for HARFBUZZ... no
checking for dlopen in -lc... no
checking for dlopen in -ldl... no
configure: error: harfbuzz support requested but library not found
```
Using `RTLD_DEFAULT` we see whether the process already has HarfBuzz linked
in, and reuse it. If this symbol is not defined it is tempting to use
`RTLD_GLOBAL` instead, which would make the library available to the whole
process. However, without `RTLD_DEFAULT`, we would risk loading a second
HarfBuzz library, and if the linker mixes them up, probably giving symbols
from the new library to other clients, we might get into trouble. For this
reason, we do not pass `RTLD_GLOBAL` to `dlopen`; the default is
`RTLD_LOCAL`, and the rest of the process won't see the loaded HarfBuzz and
hopefully all be happy.
Big win, ~20% in measured mega-var font, HarfBuzz's `benchmark-font`
'glyph_h_advances' benchmark.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Implement it in
loops.
Even if it was explicitly set by either design or normalized APIs.
Also update documentation.
* src/truetype/ttgxvar.c (TT_Set_MM_Blend, TT_Set_Var_Design): Use value -2
of `error` to indicate that we have a non-default instance.
(TT_Set_Named_Instance): Updated.
* src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
FT_Set_Var_Blend_Coordinates): Updated.
Do all math in fixed integer and do a single divide at the end.
Also don't use an array to read deltas; just read them as we go, and skip
(branch-free) when scalar is 0.
30% speedup in measured mega-var font, HarfBuzz's `benchmark-font`
'glyph_h_advances' benchmark.
See the added comment for an explanation.
This partially undoes commit f68733d4a8.
* src/autofit/afadjust.c (af_reverse_character_map_new): Always loop over all
elements of the adjustment database.
(in_range): Removed, no longer needed.
* src/truetype/ttobjs.c (tt_size_run_fpgm): Remove assignment that
is ignored and overridden later in 'Compute_Funcs'.
* src/truetype/ttinterp.c (TT_RunIns): Ditto.
(Ins_MIAP): Formatting.
* src/autofit/afadjust.c (af_get_glyph_alternates): Move creation and
deletion of the `helper_result` set to...
(af_reverse_character_map_new): ...this function.
Gain for `arial.ttf` version 7.00: approx. 1%.
This commit, together with the previous one, makes the startup of the
auto-hinter much faster.
Note, though, that the startup time for handling the diacritic database is
still rather large. For example, loading `arial.ttf` version 7.00 followed
by auto-hinting a first Latin glyph is still approx. three times slower
than before the introduction of the database (this is because function
`hb_ot_layout_lookup_get_glyph_alternates` is called very often).
* src/autofit/afshaper.c (scripts): Rename this array to...
(af_hb_scripts): ...this and export it.
(af_shaper_get_coverage_hb): Updated.
* src/autofit/afshaper.h: Updated.
* src/autofit/afadjust.c (af_reverse_character_map_new): Pass the current
script to `hb_ot_layout_collect_lookups` to make HarfBuzz check less
lookups while searching for glyph alternates.
Build reverse cmap for characters of the current script style only.
* src/autofit/afadjust.c (in_range): New function.
(af_reverse_character_map_new): Pass `AF_StyleMetrics` instead of
`AF_FaceGlobals` so that we can access the current script style.
Use `in_range` to limit tested code points.
* src/autofit/afadjust.h: Updated.
* src/autofit/aflatin.c (af_latin_metrics_init): Updated.
* src/autofit/afglobal.h (AF_HAS_CMAP_ENTRY): New flag.
(AF_STYLE_MASK): Update value.
* src/autofit/afglobal.c (af_face_globals_compute_style_coverage): Set
`AF_HAS_CMAP_ENTRY`.
* src/autofit/afadjust.c (af_reverse_character_map_new): For the creation of
the reverse map, change code to handle glyphs with cmap entries before
glyphs without cmap entries. Doing so avoids some code redundancy and
reduces the number of hash lookups.
This is the clean-up from the previous commit.
* src/autofit/afadjust.c (af_reverse_character_map_entry_compare,
af_reverse_character_map_lookup, af_reverse_character_map_expand):
Removed.
* src/autofit/afadjust.h: Updated.
* src/autofit/aftypes.h (AF_ReverseMapEntry, AF_ReverseCharacterMap):
Removed.
This greatly simplifies the code.
* src/autofit/afadjust.c (af_reverse_character_map_new): Implement it.
(af_reverse_character_map_done): Updated.
* src/autofit/afadjust.h: Updated.
* src/autofit/aflatin.c
(af_glyph_hints_apply_vertical_separation_adjustments): Updated.
* src/autofit/aftypes.h: Include `fthash.h`.
(AF_StyleMetrics): Change type of `reverse_charmap` to `FT_Hash`.
If user explicitly sets variations to `NULL` after it being set to something
else, `face->blend` will still be non-`NULL`. The intention here however is
correctly captured by `FT_IS_VARIATION`.
* src/sfnt/ttmtx.c (tt_face_get_metrics): Use `FT_IS_VARIATION`.
I found that in hb-ft I need to sometime reset the face to the default
instance. However, calling `FT_Set_Var_Design_Coordinates` with no coords
was still slowing down at least the glyph-advance code by processing
variations.
Perhaps there's a better fix, but this handles the easy cases.
* src/base/ftmm.c (FT_Set_Var_Design_Coordinates): Implement it.