This reverts 67cf7a88 to unsigned refcounts, with conditional decrements.
* include/freetype/internal/ftobjs.c (FT_Face_InternalRec,
FT_LibraryRec): Make `refcount' unsigned.
* src/base/ftobjs.c (FT_New_Library, ft_open_face_internal): Keep it zero.
(FT_Done_Library, FT_Done_Face): ... and decrement it conditionally.
Despite its name, this option only gated 'avar' version 2 support.
FreeType 2.15.0 includes the complete boring-expansion set of proposals,
now released as ISO Open Font Format, fifth edition
(ISO/IEC 14496-22:2026). Gating just avar2 no longer makes sense,
especially since it has also been shipping on Apple platforms for
four years.
* include/freetype/config/ftoption.h, devel/ftoption.h
(TT_CONFIG_OPTION_NO_BORING_EXPANSION): Remove.
* src/truetype/ttgxvar.c (ft_var_load_avar): Remove configuration guards.
* docs/CHANGES: Updated.
All five Meson regression tests pass with the removed macro still
defined. avar1 and avar2 coordinate mapping agrees with FontTools.
Assisted-by: OpenAI Codex
==========================
Tag sources with `VER-2-15-0'.
* docs/VERSION.TXT: Add entry for version 2.15.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.14.3/2.15.0/, s/2143/2150/.
* include/freetype/freetype.h (FREETYPE_MINOR): Set to 15.
(FREETYPE_PATCH): Set to 0.
* builds/unix/configure.raw (version_info): Set to 26:7:20.
* CMakeLists.txt (VERSION_MINOR): Set to 15.
(VERSION_PATCH): Set to 0.
Preserve the cubic flag while loading extended simple glyphs, including
on-curve points whose state can be changed by TrueType instructions.
Teach outline decomposition, stroking, and rasterization to handle cubic
contours with implied on-curve points, including contours with no explicit
on-curve points. Continue to ignore the reserved flag in the classic 'glyf'
table.
Tested with a synthetic font with a 'GLYF' table covering all-off contours,
implied cubic endpoints, gray and monochrome rendering, and stroking. The
full Meson test suite also passes.
Assisted-by: OpenAI Codex <noreply@openai.com>
* include/freetype/ftimage.h (FT_CURVE_TAG): Extended for use with 'GLYF'
table data.
* src/base/ftoutln.c (FT_Outline_Decompose), src/base/ftstroke.c
(FT_Stroker_ParseOutline), src/raster/ftraster.c (Decompose_Curve),
src/smooth/ftgrays.c (FT_Outline_Decompose) [STANDALONE_]: Extend parsing
code to handle 'GLYF' cubic data.
* src/truetype/ttgload.c (CUBIC_FLAG): New flag macro.
(TT_Load_Simple_Glyph): Check new flag.
Parse the optional, cmap-shaped delta map and apply its mappings before the
corresponding 'cmap' mappings. Preserve sparse fallback for nominal
characters and variation sequences, including the variant-list APIs.
Also keep variation-only subtables from becoming the active Unicode
charmap when DMAP supplies the only nominal Unicode mapping.
Tested with the Meson test suite and synthetic fonts covering nominal
and UVS precedence, fallback, iteration, DMAP-only subtables, and
extended glyph IDs.
Assisted-by: OpenAI Codex <noreply@openai.com>
* include/freetype/internal/tttypes.h (TT_Face): New fields `dmap_table`,
`dmap_size`, `dmap_charmaps`, `num_dmap_charmaps`, `dmap_results`,
`dmap_max_results`.
* include/freetype/tttags.h (TTAG_DMAP): New macro.
* src/sfnt/sfobjs.c (sfnt_init_face, sfnt_done_face): Handle 'DMAP' table.
* src/sfnt/ttcmap.h (TT_CMap): Add fields `cmap_class` and `dmap`.
Update function declarations.
* src/sfnt/ttcmap.c (tt_cmap14_is_extended, tt_cmap14_get_info): Updated.
(tt_cmap_free, tt_cmap_new, tt_face_add_dmap, tt_cmap_is_variation,
tt_face_find_unicode_dmap, tt_face_find_dmap, tt_cmap_dmap_done,
tt_cmap_dmap_char_index, tt_cmap_dmap_char_next,
tt_cmap_dmap_char_var_index, tt_cmap_dmap_char_var_isdefault,
tt_cmap_dmap_merge, tt_cmap_dmap_variants, tt_cmap_dmap_char_variants,
tt_cmap_dmap_variant_chars, tt_cmap_dmap_get_info): New functions for
'DMAP' support.
(tt_cmap_dmap_class_rec): New cmap class.
(tt_face_build_cmaps): Rename to...
(tt_face_build_cmaps_from_table): ... this and handle both cmap and dmap
data.
(tt_face_build_cmaps, tt_face_expose_dmap, tt_face_build_dmaps,
tt_face_done_dmaps): New functions.
* src/sfnt/ttload.c (tt_face_load_cmap): Also handle 'DMAP' table.
Read the 24-bit glyph count in the uppercase header and the 24-bit data
offset in each glyph variation record. Prefer 'GVAR' for 'GLYF' outlines
while preserving 'gvar' behavior.
Assisted-by: OpenAI Codex <noreply@openai.com>
* include/freetype/tttags.h (TTAG_GVAR): New macro.
* src/truetype/ttgxvar.h (GX_BlendRec): New field `gvar_is_extended`.
* src/truetype/ttgxvar.c (GX_GVar_Head): Use `FT_UInt32` for `glyphCount`.
(ft_var_load_gvar): Handle 'GVAR' table.
(TT_Vary_Apply_Glyph_Deltas): Updated.
Also check `dataSize`.
Read the 32-bit metric counts in 'HHEA' and 'VHEA', and use their 'HMTX'
and 'VMTX' companions. Keep the wide counts internally while saturating
the legacy public header fields.
Assisted-by: OpenAI Codex <noreply@openai.com>
* include/freetype/internal/tttypes.h (TT_Face): New fields
`horz_metrics_count`, `horz_metrics_is_extended`, `vert_metrics_count`,
`vert_metrics_is_extended`.
* include/freetype/tttags.h (TTAG_HHEA, TTAG_HMTX, TTAG_VHEA, TTAG_VMTX):
New macros.
* src/sfnt/sfobjc.c (sfnt_load_face): Updated.
* src/sfnt/ttload.c (check_table_dir, tt_face_load_font_dir): Updated.
* src/sfnt/ttmtx.c (tt_face_load_hmtx): Updated.
(tt_face_load_hhea): Handle 'HHEA' and 'VHEA' tables.
(tt_face_get_metrics): Updated.
Prefer 'GLYF' and its 'LOCA' companion over the 'glyf' and 'local' tables.
Allow the extended location table to describe more than 65535 glyphs.
Assisted-by: OpenAI Codex <noreply@openai.com>
* include/freetype/internal/tttypes.h (TT_Face): New field `is_extend_glyf`.
* include/freeetype/tttags.h (TTAG_GLYF, TTAG_LOCA): New macros.
* src/sfnt/sfobjs.c (sfnt_init_face): Prefer 'GLYF' over 'glyf' table.
(sfnt_load_face): Updated.
* src/truetype/ttpload.c (tt_face_load_loca): Allow 'GLYF' table.
FT_ABS() can overflow for INT_MIN and LONG_MIN, reported as
https://issues.chromium.org/issues/563962723
We introduce and use ULABS() nd UABS() to avoid that.
* include/freetype/internal/ftcalc.h: Add ULABS and UABS.
* src/base/ftcalc.c (FT_Matrix_Check, ft_corner_orientation): Updated.
The VARC draft permits static fonts without a 'fvar' table to retain 'gvar'
or 'CFF2' variation data for component-internal coordinates. Initialize a
private blend from the relevant variation store without exposing those axes
through the public MM API.
Also add TrueType and CFF2 regression fonts.
* src/truetype/ttvarc.c (tt_face_init_varc_axes): New function.
(tt_face_load_varc_glyph): Handle static VARC fonts.
* src/tyuetype/ttvarc.h: Updated.
* src/cff/cffdrivr.c (cff_varc_init_axes): New function.
(cff_varc_load_glyph): Use it.
(cff_service_varc): Updated.
* src/truetype/ttgxvar.c (ft_var_load_gvar, TT_Get_MM_Var): Handle static
VARC fonts.
(tt_var_init_gvar, tt_var_init_blend): New functions.
(tt_done_blend): Updated.
* src/truetype/ttgxvar.h: Updated.
* src/truetype/ttdriver.c (tt_service_varc): Updated.
* include/freetype/internal/services/svvarc.h (FT_VARC_Init_Axes_Func): New
typedef.
(FT_ServiceVARC): Updated.
* tests/data/varc-static-gvar.ttf, tests/data/varc-static-cff2.otf: New test
fonts.
* tests/varc/main.c: Updated.
The Variable Composites ('VARC' table) technology allows font glyphs to
reuse variants of other glyph shapes as their components. This is similar
to a feature that some font design tools already provide to designers, for
example, Glyphs calls this 'Smart Components'. The 'VARC' table allows us
carrying that design all the into the font binary file.
This enables significant file size saving in CJK fonts, for example, up
to 90% savings for simple Hangul shapes.
The 'VARC' table is part of the ISO Open Font Format version 5, and is
implemented and enabled by default in HarfBuzz since 12.0.0 (Sep 2025) and
FontTools.
For test fonts, see
https://github.com/notofonts/noto-cjk-varco/releases
* include/freetype/config/ftoption.h, devel/ftoption.h
(TT_CONFIG_OPTION_VARC): New macro.
* include/freetype/tttags.h (TTAG_VARC): New macro.
* include/freetype/internal/ftserv.h (FT_DEFINE_SERVICEDESCREC11): New macro.
* include/freetype/internal/fttrace.h (ttvarc): New macro.
* include/freetype/internal/tttypes.h (TT_FaceRec) [TT_CONFIG_OPTION_VARC]:
New fields `tt_varc`, `face_varc`, `varc`, `varc_context`, and
`varc_loading_components`.
* src/base/ftobjs.c [TT_CONFIG_OPTION_VARC]: Include `svvarc.h`.
(FT_Load_Glyph) [TT_CONFIG_OPTION_VARC]: Don't use auto-hinting for VARC
glyphs.
* include/freetype/internal/services/svvarc.h, src/truetype/ttvarc.c,
src/truetype/ttvarc.h: New files.
* src/truetype/rules.mk (TT_DRV_SRC): Add `ttvarc.c`.
* src/truetype/truetype.c: Include `ttvarc.c`.
* src/truetype/ttdriver.c [TT_CONFIG_OPTION_VARC]: Include `svvarc.h` and
`ttvarc.h`.
(tt_service_varc, tt_services) [TT_CONFIG_OPTION_VARC]: New structures.
* src/truetype/ttgload.c [TT_CONFIG_OPTION_VARC]: Include `ttvarc.h`.
(TT_Load_Glyph) [TT_CONFIG_OPTION_VARC]: Handle VARC glyphs.
* src/cff/cffdrivr.c [TT_CONFIG_OPTION_VAR]: Include `svvarc.h`.
(cff_varc_load, cff_varc_done, cff_varc_has_glyph, cff_varc_load_glyph,
cff_service_varc) [TT_CONFIG_OPTION_VAR]: New wrapper functions and
structure to provide the VARC service.
(cff_services): Updated.
* src/cff/cffgload.c [TT_CONFIG_OPTION_VARC]: Include `svvarc.h`.
(cff_slot_load) [TT_CONFIG_OPTION_VARC]: Handle VARC glyphs.
* src/sfnt/sfobjs.c [TT_CONFIG_OPTION_VARC]: Include `svvarc.h`.
(sfnt_init_face) [TT_CONFIG_OPTION_VARC]: Load the VARC service.
(sfnt_load_face) [TT_CONFIG_OPTION_VARC]: Try to load the 'VARC' table.
(sfnt_done_face) [TT_CONFIG_OPTION_VARC}: Clean up VARC handling.
In Meson, the default for `b_ndebug` is `is-release`, which will enable it
when in release mode. Additionally, in `dlg`, the default log level is
`warn` if `NDEBUG` is set or `trace` otherwise. Because `FT_LOG` uses the
`trace` level always, all debug logging will be disabled if `b_ndebug` is
set (or in release mode).
Using `NDEBUG` is not documented anywhere to toggle debug logging. We thus
define `DLG_LOG_LEVEL` so that `trace` level is always output by `dlg`.
FreeType's other (runtime or otherwise) configuration remains as it is to
toggle logging per-component.
`tt_var_get_item_delta` (used, e.g., for 'HVAR' advance adjustment, called
once per glyph during glyph loading) recomputed `tt_calculate_scalar`
for every region on every call, although the result depends only on the
normalized coordinates -- which stay constant while glyphs are loaded.
Cache the per-region scalars in the item variation store and recompute
them only when the coordinates change, detected by comparing against a
stored snapshot. The snapshot check also transparently handles the
temporary coordinate swap performed during 'avar2' processing. Output
(outlines and advances) is bit-identical; ~4% faster (1.58 -> 1.51 ms).
* include/freetype/internal/ftmmtypes.h (GX_ItemVarStoreRec): New fields
`regionScalars` and `cachedCoords`.
* src/truetype/ttgxvar.c (tt_var_get_item_delta): (Re)compute and cache
all region scalars when the coordinates differ from the cached snapshot,
then index the cache instead of recomputing per region; fall back to
direct computation if the cache cannot be allocated.
(tt_var_done_item_variation_store): Free the new fields.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
In the context of FT_Outline_Render, the outline can be placed
arbitrarily and the resulting spans should be signed. This partially
reverts ef04e4eb20 and fixes#1410. However, for internal use,
when outlines are placed in the first quadrant, we still can interpret
positions as unsigned.
* include/freetype/ftimage.h (FT_Span): Use signed position again.
* src/smooth/ftgrays.c (gray_sweep_direct): Sync with FT_Span.
* src/smooth/ftsmooth.c (ft_smooth_lcd_spans, ft_smooth_lcdv_spans,
ft_smooth_overlap_spans): Prevent sign extension.
Use pool allocation strategy similar to that of the smooth rasterizer.
This is beneficial at sizes larger than 100 ppem.
* src/raster/ftraster.c (Render_Single_Pass): Move pool allocation...
(ft_black_render): ... here. Allocate larger pools dynamically.
* include/freetype/config/ftoption.h: Update comment.
* devel/ftoption.h: Ditto.
The fixed pool allocation on stack is very fast and works very well
for rendering glyphs smaller than 40 pixels. Larger glyphs have to be
split and rendered piecewise, which is slower. This commit introduces
dynamic pool allocation for larger glyphs. Complex large glyphs are
now rendered about 2x faster.
* src/smooth/ftgrays.c (gray_convert_glyph): Use simpler banding schema
in case of rendering emergency.
(gray_raster_render): Allocate larger pools dynamically.
* include/freetype/config/ftoption.h: Explain the render pool size.
* devel/ftoption.h: Ditto.
The new 'hvf' module is a thin wrapper around 'libhvf' with the necessary
boilerplate stuff to integrate it into FreeType. Note that this currently
works on macOS >= 15.4 and iOS >= 18.4 only.
* include/freetype/tttags.h (TTAG_hvgl, TTAG_hvpm): New macros.
* include/freetype/config/ftmodule.h: Add `hvf_driver_class`.
* include/freetype/internal/fttrace.h: Add tracing tags `hvfdrv`, `hvfobjs`,
and `hvfload`
* include/freetype/internal/services/svfntfmt.h (FT_FONT_FORMAT_HVF): New
macro.
* modules.cfg (FONT_MODULES): Add `hvf` module.
* src/sfnt/sfobjc.s (sfnt_init_face): Handle 'hvgl' table.
* src/hvf/*: New files.
This flag is going to be used to conditionally compile support for Apple's
Hierarchical Variable Font (HVF) format.
* devel/ftoption.h, include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_HVF): New flag.
==========================
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.
==========================
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.
* 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.
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.
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.
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.
This is done for consistency with Type 1 fonts.
* include/freetype/internal/cfftypes.h (CFF_FontRecDic): Change
the variable types.
* include/cff/cfftoken.h (CFF_FontRecDic): Change the parsing macros.
* src/cff/cffobjs.c (cff_face_init), src/cff/cffload.c (cff_subfont_load),
src/cff/cffdrivr.c (cff_ps_get_font_info): Update users.
The italic angle is commonly specified in fractional degrees in
Type 1 fonts and its derivatives. This change clarifies and fixes
these values. Note that CFF fonts has always reported them as such,
but truncated the underline position and thickness. Fixes#1367.
* include/freetype/t1tables.h (PS_FontInfoRec):
Use FT_Fixed for italic_angle.
* src/cid/cidtoken.h, src/type1/t1tokens.h, src/type42/t42parse.c:
Modify the italic_angle token.
* src/cff/cffdrivr.c (cff_ps_get_font_info): Fix the underline
position and thickness.
* docs/CHANGES: Note this change.
==========================
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.
==========================
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.
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.
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.
* 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.
* 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.
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.