Commit graph

1578 commits

Author SHA1 Message Date
Rudi Heitbaum
a3c1a452df * src/base/ftstroke.c (ft_stroke_border_get_counts): Remove variable. 2026-03-23 10:44:12 -04:00
Werner Lemberg
0a0221a134 * Version 2.14.3 released.
==========================

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

* docs/VERSION.TXT: Add entry for version 2.14.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.14.2/2.14.3/, s/2142/2143/.

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

* builds/unix/configure.raw (version_info): Set to 26:6:20.
* CMakeLists.txt (VERSION_PATCH): Set to 3.
2026-03-22 16:07:10 +01:00
Werner Lemberg
264b5fbf5b Update all copyright notices. 2026-03-11 17:27:07 +01:00
Alexei Podtelezhnikov
dc17b79e1a [base] Reintroduce overall rendering limits.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Limit absolute
outline coordinnates to prevent integer issues downstream.
2026-03-09 22:53:06 -04:00
Alexei Podtelezhnikov
e7d2cc6466 * src/base/ftglyph.c (FT_Glyph_To_Bitmap): Fix memory leak.
This leak was introduced in 85c8efe0af by overlooking the
direct `ft_bitmap_glyph_init` call (now gone). Fixes #1399,
also reported earlier:
  https://issues.oss-fuzz.com/issues/482909897.
2026-03-09 22:14:01 -04:00
Alexei Podtelezhnikov
bf18015d3a [stroker] Actually validate outlines.
Fixes #1400.

* src/base/ftstroke.c (FT_Glyph_Stroke): Check for `GetCount` error.
(ft_stroke_border_get_counts): Actually return expected error.
(FT_Glyph_Stroke): Minor.
2026-03-09 19:53:30 -04:00
Alexei Podtelezhnikov
6995a34628 [base] Adjust rendering limits.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Check width and
height directly. Fixes #1390.
2026-03-05 19:55:31 -05:00
Werner Lemberg
f4205da148 * Version 2.14.2 released.
==========================

Tag sources with `VER-2-14-2'.

* docs/VERSION.TXT: Add entry for version 2.14.2.
* 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.14.1/2.14.2/, s/2141/2142/.

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

* builds/unix/configure.raw (version_info): Set to 26:5:20.
* CMakeLists.txt (VERSION_PATCH): Set to 2.
2026-03-01 14:55:17 +01:00
Alexei Podtelezhnikov
c111f0713c * src/base/ftbitmap.c (FT_Bitmap_Blend): Use FT_ALLOC_MULT.
This call is fortified with builtin overflow checks.
2026-02-20 23:48:14 -05:00
Alexei Podtelezhnikov
be8e126ae0 [base] Clean up bitmap allocations.
* src/base/src/base/ftobjs.c (ft_glyphslot_alloc_bitmap): Use preset
dimensions and call FT_MEM_ALLOC_MULT.
* include/freetype/internal/ftobjs.h (ft_glyphslot_alloc_bitmap):
Updated signature...
* src/*: ... and all callers.
2026-02-20 22:50:50 -05:00
Alexei Podtelezhnikov
85c8efe0af * src/base/ftglyph.c (ft_bitmap_glyph_init): Always copy in full.
Other glyph formats never perform lazy copy.  Fixes #1385.
2026-02-07 19:20:05 -05:00
Alexei Podtelezhnikov
7cc8f37b9a [base, smooth] Implement direct LCD filtering.
Applying an LCD filter to spans rather than the entire image improves
the performance of ClearType-like rendering by about 40% at 32 ppem
and much more at larger sizes.  Small rounding differences are expected.

* src/smooth/ftsmooth.c (ft_smooth_raster_lcd, ft_smooth_lcd_spans,
ft_smooth_raster_lcdv, ft_smooth_lcdv_spans, TOrigin): Implement it.
* include/freetype/internal/ftobjs.h (FT_LibraryRec): lcd_filter_func gone.
* src/base/ftlcdfil.c (ft_lcd_filter_fir): Removed.
(ft_lcd_padding): Use padding sufficient for any 5-tap filter.
(FT_Library_SetLcdFilterWeights, FT_Library_SetLcdFilter): Updated.
* docs/CHANGES: Updated.
2026-01-26 12:43:28 -05:00
Alexei Podtelezhnikov
e8f0969dcf [base, smooth] Remove LCD filter from face properties.
This removes the internal face property that sets the filtering weights.
The global filtering algorithms and weights are now optimized to work
well under all conditions.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Do it.
* include/freetype/freetype.h (FT_Face_Properties): Revised docs.
* include/freetype/ftparams.h (FT_PARAM_TAG_LCD_FILTER_WEIGHTS): Ditto.
* src/base/ftlcdfil.c (ft_lcd_padding): Updated.
* src/base/ftobjs.c (ft_open_face_internal, FT_Face_Properties): Ditto.
* src/smooth/ftsmooth.c (ft_smooth_render): Ditto.
* docs/CHANGES: Updated.
2026-01-25 15:00:08 -05:00
Alexei Podtelezhnikov
084bf2898b [base] Remove legacy LCD filter.
* src/base/ftlcdfil.c (_ft_lcd_filter_legacy): Removed.
(FT_Library_SetLcdFilter): Updated.
* include/freetype/ftlcdfil.h (FT_LcdFilter): Updated.
* doc/CHANGES: Updated.
2026-01-25 14:51:59 -05:00
Alexei Podtelezhnikov
ef04e4eb20 [base, smooth] Fortify direct rendering.
This is a better fix for #1384, which is rather about signed overflow.

* include/freetype/ftimage.h (FT_Span): Use unsigned position.
* src/smooth/ftgrays.c (gray_sweep_direct): Sync with FT_Span.
* src/smooth/ftsmooth.c (ft_smooth_render): Remove redundant shift.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Readjust limits.
2026-01-17 22:55:16 -05:00
Alexei Podtelezhnikov
dad4640660 [base] Maintain overall rendering limits.
Reject rendering of outlines that stretch beyond 32767 pixels from
the origin,  which is further restricted to 10922 horizontal pixels
for LCD rendering with ClearType-like algorithms. 16-bit FT_Span is
one of the reasons to have this limit imposed, fixes #1384.

* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Impose global
rendering limits.
2026-01-15 21:09:56 -05:00
Alexei Podtelezhnikov
341049a95b [base] Set ppem-based rendering limits.
Many rendering timeouts occur when the outline stretches far beyond
the Em size.  Limiting the bounding box to 10 Em should reject such
requests.  It is still to possible scribble excessively within the set
limits.  At least, the memory usage will be curtained.

* src/base/ftobjs.c (ft_glyphslot_free_bitmap): Revise limits based
on ppem when available.
2026-01-09 18:22:15 -05:00
Celeste Liu
914b474030 [base] Fix support for format 13 charmaps.
According to the OpenType specification of the 'cmap' table, the pair (0,6)
for platform and encoding IDs is used for format 13 charmap tables.  Commit
ba6f3e18 (from 2017-01-17) introduced the `TT_APPLE_ID_FULL_UNICODE` macro
(i.e., encoding_id == 6, added to OpenType 1.8); however, the corresponding
cmap selection code wasn't updated.

Unicode's Last Resort font (https://github.com/unicode-org/last-resort-font)
can be used to test a format 13 charmap.

Fixes issue #1383.

* src/base/ftobjc.s (find_unicode_charmap): Support
  `TT_APPLE_ID_FULL_UNICODE`.

Signed-off-by: Celeste Liu <uwu@coelacanthus.name>
2026-01-04 07:13:27 +01:00
Alexei Podtelezhnikov
e63975ca64 * src/base/ftutil.c (FT_List_Finalize): Delay reading 'data'.
Fixes #1376.
2025-11-29 11:29:44 -05:00
Alexei Podtelezhnikov
ae63cc0d13 * src/base/ftadvanc.c (ft_face_scale_advances_): Adjust scaling.
This is safe because advances are short originally.
2025-10-26 13:55:40 -04:00
Alexei Podtelezhnikov
0d410eb9aa [base] Refactor obtaining advances.
* src/base/ftadvanc.c (ft_load_advances): New separate function to
handle slow advances.
(FT_Get_Advance, FT_Get_Advances): Updated.
2025-10-26 13:28:32 -04:00
Werner Lemberg
526ec5c47b * Version 2.14.1 released.
==========================

Tag sources with `VER-2-14-1'.

* docs/VERSION.TXT: Add entry for version 2.14.1.
* 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.14.0/2.14.1/, s/2140/2141/.

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

* builds/unix/configure.raw (version_info): Set to 26:4:20.
* CMakeLists.txt (VERSION_PATCH): Set to 1.
2025-09-11 13:16:53 +02:00
Behdad Esfahbod
566f8805f3 [base] Fix return values of two Font Variation functions.
* src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
  FT_Set_Var_Blend_Coordinates): Do it.

Fixes issue #1355.
2025-09-10 14:22:49 +02:00
Werner Lemberg
007c46ebbf * Version 2.14.0 released.
==========================

Tag sources with `VER-2-14-0'.

* docs/VERSION.TXT: Add entry for version 2.14.0.
* 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.3/2.14.0/, s/2133/2140/.

* include/freetype/freetype.h (FREETYPE_MINOR): Set to 14.
(FREETYPE_PATCH): Set to 0.

* builds/unix/configure.raw (version_info): Set to 26:3:20.
* CMakeLists.txt (VERSION_MINOR): Set to 14.
(VERSION_PATCH): Set to 0.
2025-09-06 16:47:31 +02:00
Werner Lemberg
32cb53904c Update all copyright notices. 2025-09-06 06:14:03 +02:00
Jouk Jansen
ba7eb5bed7 Clean up OpenVMS support.
This avoids cluttering the source code with VMS-specific changes.

* include/freetype/internal/ftcalc.h [__VMS], src/base/ftcalc.c
  [vms_auto64_source]: Remove.

* builds/vms/patch_ftcalc.sed: New file.

* vms_make.com: Change macro definitions while this script is running; we
  use `GNU sed` to inject the necessary preprocessor code on the fly.
2025-09-05 17:58:54 +00:00
Alexei Podtelezhnikov
61a4234260 [base] Use const FT_Module_Class.
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.
2025-08-29 16:59:50 -04:00
Alexei Podtelezhnikov
48f91b5331 * src/base/ftobjs.c (FT_Load_Glyph): Reduces scope of 'ttface'. 2025-08-27 11:16:07 -04:00
Jouk Jansen
aa2ee67b3d Improvements to OpenVMS support.
* 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.
2025-08-05 17:40:45 +02:00
Werner Lemberg
01695ea72a Various minor fixes.
As reported by clang 19.

* src/autofit/afadjust.c (adjustment_database): Make it static.

* src/base/ftdbgmem.c (FT_MEM_SIZE_MIN): Remove unused macro.

* src/psaux/psobjs.c (skip_procedure), src/truetype/ttinterp.c (Ins_IF,
  Ins_ELSE, Ins_FDEF, Ins_IDEF): Add `default` clause.
2025-07-01 18:06:17 +02:00
Werner Lemberg
8d82c9fa4d */*: Fix trivial signedness issues with format strings in trace messages.
As reported with clang 19's `-Wformat` option.
2025-07-01 17:08:37 +02:00
Werner Lemberg
346d8fae7a Fix make multi.
Reported as

  https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/381#note_2984253

* src/base/fthash.c: Include `ftobjs.h`.
* src/autofit/afgsub.c: Include `afglobal.h`.
2025-07-01 05:18:47 +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
04f68052f0 * src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Remove check.
The highest (sign) attribute bit is reserved and should be zero.
It is harmless to omit this check however. Fixes #1342.
2025-06-12 21:02:57 -04: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
Vítor Ramos
202297eb5c * src/base/ftobjs.c (FT_Load_Glyph): Loosen auto-hinting constraints.
Fixes issue #1320.
2025-05-27 13:57:05 +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
Behdad Esfahbod
42a649be49 [mm] Short-circuit setting face to default instance if already is so.
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.
2025-05-22 05:12:07 +02:00
Werner Lemberg
15b7e8c3a9 Whitespace, formatting, minor spelling fix. 2025-05-14 10:20:04 +02:00
Alexei Podtelezhnikov
4fad257a7e * src/base/ftcalc.c (ft_corner_orientation) [!FT_INT32]: Fix up. 2025-04-17 22:32:21 -04:00
Alexei Podtelezhnikov
0a650e8c52 * src/base/ftcalc.c: Miscellaneous cleanups. 2025-04-16 22:54:54 -04: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
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
Behdad Esfahbod
d0c905c62a [sfnt/CPAL] Return early if user requested currently-set palette
Before, we were loading a palette (again and again) even if the
same was requested. Even if the font only had one palette...

For a font like NotoColorEmoji that has over 5000 colors in its
palette, this was dominating the COLRv1 loading times for HarfBuzz
(and I believe all other clients) because they have to set the
palette to get access to the colors.

* src/base/ftcolor.c (FT_Palette_Select): Check the current palette.
2025-02-24 19:13:39 -05:00
Ben Wagner
38272bf853 [ftstroke] Fix invalid pointer assignement to arc
In `FT_Stroker_ConicTo` and `FT_Stroker_CubicTo` there is a `bez_stack`.
`arc` is initialized with `arc = bez_stack` and is never set to point
into any different object. The main loop looks like `while ( arc >=
bez_stack )` which is depending on a later `arc -= 2` (or `arc -= 3`) to
make `arc` point to before `bez_stack`. However, using pointer
subtraction to make `arc` point outside the array is undefined behavior,
and attempting to use the value in the loop predicate is "very"
undefined behavior. (C99 "Additive operators" 6.5.6.8.)

This particular undefined behavior was discovered as either hangs or
MemorySantizer issues after "[InstCombine] Infer nuw for gep inbounds
from base of object" [0]. With this change, clang can infer that `arc`
must always point into the `bez_stack` object and therefore cannot be at
a "negative index" so the predicate is always true.

[0] e21ab4d16b

* src/base/ftstroke.c (FT_Stroker_ConicTo, FT_Stroker_CubicTo): test
loop exit condition (there are no more arcs to process) before
decrementing `arc`

Fixes: #1307
2024-12-16 14:39:10 -05:00
Behdad Esfahbod
1394436633 Move generic destroy to later in the face and size destruction.
* src/base/ftobjs.c (destroy_size, destroy_face): This is such that the
  generic destroy can be used to call `FT_Done_Library`.  For that to work,
  it needs to call it *after* having removed the face from the respective
  module.
2024-10-16 05:08:22 +02:00