Commit graph

2050 commits

Author SHA1 Message Date
Werner Lemberg
b04db3872c [sfnt] Rewrite GPOS kerning support. (2/2)
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.
2025-07-05 14:51:40 +02:00
Werner Lemberg
d7e640b9c6 [doc] Revise font variation API. 2025-06-29 16:14:57 +02:00
Werner Lemberg
636aede94b [doc] Use 'Adobe MM', 'TrueType GX', and 'OpenType Font Variations'. 2025-06-29 06:23:38 +02:00
Werner Lemberg
2ab0357d38 [base] Add no-overwrite hash insert functions.
* src/base/fthash.c (ft_hash_num_insert_no_overwrite,
  ft_hash_str_insert_no_overwrite): New functions.
* include/freetype/internal/fthash.h: Updated.
2025-06-26 05:46:58 +02:00
Werner Lemberg
820df38734 [base] Add iterators for FT_Hash.
* src/base/fthash.c (ft_hash_num_iterator, ft_hash_str_iterator): New
  functions.
* include/freetype/internal/fthash.h: Updated.
2025-06-26 05:46:58 +02:00
Alexei Podtelezhnikov
2041c65cd2 [truetype] Simplify twilight zone management.
* include/freetype/internal/tttypes.h (TT_GlyphZone): Remove 'memory'.
* src/truetype/ttobjs.c (tt_glyphzone_done): Use 'memory' as argument.
(tt_glyphzone_new, tt_glyphzone_done): Allocate/free as a single block.
(tt_size_init_bytecode, tt_size_done_bytecode): Updated.
* src/truetype/ttobjs.h (tt_glyphzone_done): Updated signature.
2025-06-20 20:20:54 -04:00
Alexei Podtelezhnikov
3c14c52523 [truetype] Clean up TT_GlyphZone.
* include/freetype/internal/tttypes.h (TT_GlyphZone): Delete fields.
* src/truetype/ttobjs.c (tt_glyphzone_new, tt_glyphzone_done,
tt_size_init_bytecode): Updated.
2025-06-11 15:32:11 -04:00
Alexei Podtelezhnikov
68c62e193f [truetype] Relocate the interpreter pointer.
This reduces dereferencing when calling the interpreter.

* include/freetype/internal/tttypes.h (TT_Face): Move it from here...
* src/truetype/ttinterp.h (TT_ExecContext): ... to here.
* src/truetype/ttobjs.c (tt_size_init_bytecode):  Move its initialization
* src/truetype/ttinterp.c (TT_New_Context): ... to here.
(TT_Run_Context): Updated.
2025-06-11 07:58:51 -04:00
Alexei Podtelezhnikov
ecfefd8ccd [truetype] Clean up the loader initiation.
* include/freetype/internal/tttypes.h (TT_LoaderRec): Remove unused field.
* src/truetype/ttgload.c (tt_loader_init): Refactor.
2025-06-11 07:58:51 -04:00
Werner Lemberg
d736e74177 Two more link fixes. 2025-06-10 05:29:47 +02:00
Werner Lemberg
7f559fbe9a Update links.
Found with `linkchecker --check-extern index.html` running locally in the
'freetype-web' repository.
2025-06-10 04:56:50 +02:00
Werner Lemberg
2adb53616a Replace 'www.freetype.org' with 'freetype.org'. 2025-06-03 10:35:16 +02:00
Werner Lemberg
5a07f41d0e [sfnt] FT_Load_Sfnt_Table can now also load a font's table directory.
Closes issue #1263.

* src/sfnt/ttload.c (tt_face_load_any): Implement it.
2025-05-28 09:52:44 +02:00
Behdad Esfahbod
fa412cf5c5 [mm/gxvar] Always detect default instance and use optimized codepath.
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.
2025-05-27 07:00:08 +02:00
Werner Lemberg
e07e56c7f1 [gxvar] Speed up handling of deltas in ItemVariationStore. (3/3)
* src/base/ftcalc.c (FT_MulAddFix): Removed, no longer needed.
* include/freetype/internal/ftcalc.h: Updated.
2025-05-26 17:22:13 +02:00
Behdad Esfahbod
8eae039923 Lift FT_Int64 type to global (internal) FreeType use.
* src/base/ftcalc.c (FT_Int64) [!FT_INT64]: Move declaration to...
* include/freetype/config/integer-types.h: ... this file.
  (FT_UInt64) [!FT_INT64]: New structure.
  (FT_INT64_ZERO): New macro.
2025-05-26 08:24:21 +02:00
Werner Lemberg
04455084cf * include/freetype/ttnameid.h (TT_UCR_*): Define with unsigned long.
(TT_UCR_PHAGSPA): Fix definition.

Fixes issue #1300.
2025-05-08 07:49:10 +02:00
Werner Lemberg
c2789e7558 [doc] Mention that there is no rendering support for 'COLR' v1 tables.
Handles issue #1319.
2025-05-08 07:03:31 +02:00
Carlo Bramini
c26c150cf2 Fix Cygwin visibility attributes.
Reported as compilation warnings in #1329.

* include/freetype/config/public-macros.h: Check __CYGWIN__.
* include/freetype/internal/compiler-macros.h: Ditto.
2025-05-04 07:22:46 -04:00
Behdad Esfahbod (بهداد اسفهبد)
5d2fd7608a Provide configuration option to dynamically load the HarfBuzz library.
We now request HarfBuzz version 2.6.8 (published in June 2020) or newer to
simplify the setup; this version introduced function
`hb_ot_layout_lookup_get_glyph_alternates`, which we need for the adjustment
database of the auto-hinter.

No CMake support yet for dynamic loading.

* include/freetype/config/ftoption.h, devel/ftoption.h
  (FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC): New configuration macro.

* builds/unix/configure.raw: Implement `--with-harfbuzz=dynamic`.
  This gets tested automatically if we can't link with `libharfbuzz`.
  (ft_option_set, ft_option_unset): Refine.
  Require at least HarfBuzz version 2.6.8.

* meson.build: Do the same as `configure.raw`.
* meson_options.txt: Updated.

* CMakeLists.txt: Require at least HarfBuzz version 2.6.8.
2025-04-29 19:18:12 +00:00
Alexei Podtelezhnikov
3467c2177c * include/freetype/internal/ftcalc.h (FT_MulFix_64): Silence UBSAN. 2025-04-25 08:09:48 -04:00
Alexei Podtelezhnikov
6ed79d5b7a * include/freetype/internal/ftcalc.h: Fix fringe compilation. 2025-04-17 22:46:06 -04:00
Alexei Podtelezhnikov
ccabe7ac02 [base, truetype] Silence UBSAN (cont'd).
* src/truetype/ttinterp.c (TT_MulFix14, TT_DotFix14): Use MUL_INT64.
* include/freetype/internal/ftcalc.c (FT_MulFix): Ditto.
2025-04-15 18:49:36 +00:00
Craig White
c46ebd7650 [autofit] Add adjustment database.
* src/autofit/afadjust.c, src/autofit/afadjust.h: New files.

* include/freetype/internal/fttrace.h: Add 'afadjust' component.

* src/autofit/autofit.c: Include `afadjust.c`.

* src/autofit/rules.mk (AUTOF_DRV_SRC): Add `afadjust.c`.
2025-04-14 06:50:00 +02:00
Craig White
f0660df3a9 [base] Make find_unicode_charmap a base function.
This is needed for forthcoming changes in the auto-hinter.

* include/freetype/internal/ftobjs.h, src/base/ftobjs.c: Updated.
2025-04-14 06:50:00 +02:00
Alexei Podtelezhnikov
5416689d95 * include/freetype/internal/ftcalc.h (FT_MSB) [__CC_ARM]: Added. 2025-04-12 12:38:01 -04:00
Alexei Podtelezhnikov
58b3598c2a Typos in macros.
* include/freetype/internal/ftcalc.h: s/_M_X86/_M_IX86/.
* src/truetype/ttinterp.c: s/_M_X86/_M_IX86/.
2025-04-12 09:18:16 -04:00
Alexei Podtelezhnikov
c88bf8a216 [base, truetype] Silence UBSAN.
* src/truetype/ttinterp.c (TT_MulFix14_64): Use unsigned multiplication.
* include/freetype/internal/ftcalc.h (FT_MulFix_64): Ditto.
2025-04-11 22:58:26 -04:00
Alexei Podtelezhnikov
fb99fd63ec [base, truetype] Synchronize MulFix assembly.
* include/freetype/internal/ftcalc.h (FT_MulFix_*),
src/truetype/ttinterp.c (TT_MulFix14_*): Synchronize routines.
2025-04-11 22:57:27 -04:00
Alexei Podtelezhnikov
8f67545d72 [base] Update FT_MulFix inlining.
Resolves inconsistencies in 64-bit multiplication discussed in !355.                                                    Importantly, FT_MulFix arguments and return value is FT_Long,                                                           whatever sizeof FT_Long is on 64-bit platforms: 8 bytes on Linux or                                                     4 bytes on Windows.                                                                                                                                                                                                                             * include/freetype/internal/ftcalc.h (FT_MulFix_x86_64): Removed.                                                       (FT_MulFix_64): Generalize and prioritize the inline implementation
for all 64-bit platforms ifdef FT_INT64.                                                                                * src/base/ftcalc.c (FT_MulFix)[FT_INT64]: Call 'FT_MulFix_64'.                                                         * src/base/ftbase.c: Include 'ftcalc.c' after the FT_MulFix callers                                                     to enable its inlining.
2025-04-09 13:37:23 +00:00
Graham Asher
fc67794e15 Missing header wrappers.
* include/freetype/config/integer-types.h, src/smooth/ftgrays.h:
Add missing FT_BEGIN_HEADER and FT_END_HEADER.
* src/smooth/ftgrays.c: Cosmetics.
2025-04-04 19:54:50 -04:00
Alexei Podtelezhnikov
4f00846dde * include/freetype/ftimage.h (FT_Bitmap): Describe empty bitmap. 2024-08-25 18:13:10 +00:00
luz paz
f92c96550a Fix various typos. 2024-08-13 23:29:13 -04:00
Werner Lemberg
42608f77f2 * Version 2.13.3 released.
==========================

Tag sources with `VER-2-13-3'.

* docs/VERSION.TXT: Add entry for version 2.13.3.
* docs/CHANGES: Updated.
* docs/release, docs/README, builds/macs/README: Updated.

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html, builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html, builds/wince/vc2008-ce/index.html,
docs/freetype-config.1: s/2.13.2/2.13.3/, s/2132/2133/.

* include/freetype/freetype.h (FREETYPE_PATCH): Set to 3.

* builds/unix/configure.raw (version_info): Set to 26:2:20.
* CMakeLists.txt (VERSION_PATCH): Set to 3.
2024-08-12 12:50:14 +02:00
Werner Lemberg
ed8b82ba94 Various minor documentation or formatting fixes. 2024-08-12 12:34:28 +02:00
Werner Lemberg
ec378cecaf tttables.h (FT_Get_CMap_Format): Minor documentation improvement. 2024-08-07 21:23:44 +02:00
Alexei Podtelezhnikov
2488854056 [bdf,pcf,winfonts,sfnt] Remove barely used marcros.
* include/freetype/internal/ftobjs.h (FT_FACE_SIZE, FT_SIZE_FACE):
Removed.
* src/bdf/bdfdrivr.c (BDF_Glyph_Load): Updated.
* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Ditto.
* src/winfonts/winfnt.c (FNT_Load_Glyph): Ditto
* src/sfnt/ttbdf.c (tt_face_find_bdf_prop): Ditto.
2024-07-28 19:42:49 -04:00
Dan Rosser
97069edd16 * include/freetype/internal/ftcalc.h (FT_MSB)[_M_ARM64EC]: Added. 2024-07-27 20:41:25 +00:00
Alexei Podtelezhnikov
044d142be7 Use unsigned tags FT_Outline.
This change comes along with 2a7bb4596f ans is only meant to reduce
pointer casting in the code.

* include/freetype/ftimage.h (FT_Outline): Do it.
* src/*: Update `FT_Outline` users.
2024-06-20 22:16:51 -04:00
Alexei Podtelezhnikov
2a7bb4596f Use unsigned point and contour indexing in FT_Outline.
This doubles the number or allowed points, see
    https://github.com/harfbuzz/harfbuzz/issues/4752

Although it is hardly practical to use more than 32767 points,
other font engines seem to support it.

* docs/CHANGES: Announce it.
* include/freetype/ftimage.h (FT_Outline): Do it and update limits.
* src/*: Update `FT_Outline` users.
2024-06-20 20:49:56 -04:00
Alexei Podtelezhnikov
deba7feb57 * include/freetype/ftimage.h: Explain standard types. 2024-06-18 14:01:58 +00:00
Alexei Podtelezhnikov
42d406ab04 * include/freetype/internal/ftmemory.h (FT_MEM_DUP): Fix g++ error. 2024-05-22 21:08:34 -04:00
Alexei Podtelezhnikov
68399b4244 * include/freetype/ftmm.h: Include freetype.h.
Reported by Ben Wagner, see !326.
2024-05-13 16:57:35 +00:00
Alexei Podtelezhnikov
4a85db7e31 [type1/MM] Tighten headers.
* include/freetype/internal/t1types.h: Host PS_DesignMap and PS_Blend.
* include/freetype/ftmm.h: Host and document TT_MAX_MM_XXX.
* include/freetype/t1tables.h: Remove them from here.
2024-05-11 22:19:25 -04:00
Ben Wagner
a46424228f [psaux] Fix location and type order in initializer
`T1_FIELD_ZERO` is used to zero initialize a `T1_FieldRec`.
`T1_FIELD_ZERO` is currently initilizing `T1_FieldRec::location` with a
`T1_FieldType` and `T1_FieldRec::type` with a `T1_FieldLocation`. This
was detected with `-Wenum-conversion`.

* include/freetype/internal/psaux.h (T1_FIELD_ZERO): correct order of
initalizers
2024-05-08 11:36:18 -04:00
Alexei Podtelezhnikov
1264b84c08 * include/freetype/internal/psaux.h: Fix g++ warning.
Reported by Hin-Tak Leung.
2024-05-07 23:35:59 -04:00
Alexei Podtelezhnikov
4e079f6357 Document the SDF spread further. 2024-04-27 20:07:36 -04:00
Alexei Podtelezhnikov
e2bcca40ca * include/freetype/ftdriver.h: s/truncated/clamped/. 2024-04-22 22:43:41 -04:00
Alexei Podtelezhnikov
ec46a50dac Improve SDF documentation. 2024-04-22 21:21:12 -04:00
Alexei Podtelezhnikov
47574f7ea4 Update all copyright notices. 2024-01-27 11:11:22 -05:00