Commit Graph

5844 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov
d2612e1c3f * src/sfnt/ttcmap.c (tt_cmap*_get_info): Remove casting. 2024-08-26 07:01:19 -04: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
6b992aaaf2 * src/*/*: Fix C++ compilation; fix clang warnings. 2024-08-12 12:34:28 +02:00
Werner Lemberg
ed8b82ba94 Various minor documentation or formatting fixes. 2024-08-12 12:34:28 +02:00
Alexei Podtelezhnikov
1f72a120a9 * src/truetype/ttgxvar.c (ft_var_readpacked*): Minor. 2024-08-05 13:05:51 +00:00
Alexei Podtelezhnikov
e181911d87 * src/base/ftstream.c (FT_Stream_ReadFields): Switch to FT_Offset. 2024-08-05 13:02:04 +00:00
Alexei Podtelezhnikov
a48cdddef3 * src/winfonts/winfnt.c (fnt_face_get_dll_font): Unwrap arithmetic. 2024-08-01 21:15:46 -04:00
Alexei Podtelezhnikov
72e199e8d3 * src/base/ftstream.c (FT_Stream_ReadFields): Update condition. 2024-08-01 21:12:41 -04:00
Alexei Podtelezhnikov
7c75b8a7bd [truetype/GX] Use more robust conditions.
* src/truetype/ttgxvar.c (ft_var_readpacked{points,deltas}): Rewrite
conditions to avoid undefined behavior.
2024-08-01 19:14:44 -04:00
Alexei Podtelezhnikov
5e116bb0dc [truetype/GX] Read points and deltas more carefully.
Hopefully fixes newly introduced buffer overflows:
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=70807
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=70809

* src/truetype/ttgxvar.c (ft_var_readpacked{points,deltas}): Explicitly
check stream frame limits and modify run counting.
2024-07-30 21:51:51 -04:00
Alexei Podtelezhnikov
104f85448d [truetype/GX] Read stream more aggressively.
With ample checks against the table size, we should be able to use
macros without the limit checks and functional calls.

* src/truetype/ttgxvar.c (ft_var_readpacked{points,deltas}):
Use FT_NEXT_* instead of FT_GET_*.
2024-07-29 20:26:00 -04:00
Alexei Podtelezhnikov
3f8edd234d * src/sfnt/ttload.c (tt_face_load_name): Shorten dereference. 2024-07-28 20:56:07 -04:00
Alexei Podtelezhnikov
d42bffd4a0 * src/autofit/afmodule.c (af_autofitter_load_glyph): Shorten deref. 2024-07-28 20:32:41 -04: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
Werner Lemberg
1452355de9 * src/truetype/ttobjs.c (tt_size_run_prep): Correct scaling of CVT values.
This reverts the scaling behaviour introduced in commit 37580053.

Fixes issue #1005.
2024-07-19 22:35:37 +02:00
Philip Race
37cefe33b2 * psobjs.c (ps_table_add): Check length before calling FT_MEM_CPY.
Fixes issue #1280.
2024-06-29 05:17:14 +02:00
Werner Lemberg
bab9564a97 Make 'multi' build work again.
* src/psaux/psobjs.c: Include `psft.h`.

* src/sfnt/rules.mk (SFNT_DRV_SRC): Add `ttgpos.c`.

Fixes issue #1284.
2024-06-26 05:41:36 +02:00
Alexei Podtelezhnikov
73720c7c99 * src/truetype/ttgload.c (load_truetype_glyph): Unsigned fix. 2024-06-23 10:58:00 -04: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
Ben Wagner
b1cbcb2045 [ttgxvar] Avoid "applying zero offset to null pointer"
In C it is undefined behavior to do arithmetic on a null pointer, including
adding zero. When using NotoSansKhmer[wdth,wght].ttf UBSAN produces a report
like

ttgxvar.c:1052:31: runtime error: applying zero offset to null pointer

when adding zero to `varData->deltaSet` (which is null) to produce `bytes`.
Protect against all the potential issues of this kind by returning early if
`varData->regionIdxCount == 0`.

* src/truetype/ttgxvar.c (tt_var_get_item_delta): early return on no regions
2024-06-21 01:41:40 +00: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
2b9fdec5fa * src/pfr/pfrgload.c (pfr_glyph_curve_to): Avoid casting. 2024-06-19 21:38:58 -04:00
Alexei Podtelezhnikov
7a753c9653 * src/base/ftgloadr.c (FT_GlyphLoader_Prepare): Minor refactoring. 2024-06-18 21:14:58 -04:00
Alexei Podtelezhnikov
93a067e312 [base, autofit, psaux] Remove unnecessary casting.
* src/autofit/afhints.c (af_glyph_hints_reload): Remove (short) casting.
* src/base/ftgloadr.c (FT_GlyphLoader_Add): Ditto.
* src/psaux/psobjs.c ({t1,cff,ps}_builder_{add,close}_contour): Ditto.
2024-06-18 17:48:41 +00:00
Ben Wagner
d41a855aab [ttgxvar] Replace tabs with spaces
Also clarify comments around conversion and clamping.

* src/truetype/ttgxvar.c (ft_var_to_normalized): doit
2024-05-29 17:01:29 -04:00
Alexei Podtelezhnikov
7ff43d3e9f [truetype/GX] Consolidate memory allocations.
* src/truetype/ttgxvar.c (tt_face_vary_cvt, TT_Vary_Apply_Glyph_Deltas):
Allocate and split bigger memory blocks, avoid unnecessary zeroing,
do not copy shared tuples, revise error exit paths.
2024-05-26 19:40:20 -04:00
Alexei Podtelezhnikov
3416ac16d0 Whitespace. 2024-05-26 08:10:21 -04:00
Alexei Podtelezhnikov
b6dbbd9630 * src/truetype/ttgxvar.c (ft_var_apply_tuple): Reduce checks. 2024-05-24 17:38:14 +00:00
Alexei Podtelezhnikov
70299c924f Revert "[truetype] Reduce allocation scope."
This reverts commit 9ff4153cbf.
2024-05-23 22:50:32 -04:00
Alexei Podtelezhnikov
9ff4153cbf [truetype] Reduce allocation scope.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Reduce scope
of `points_org` and 'points_out`.
2024-05-22 23:38:34 -04:00
Alexei Podtelezhnikov
5f131cfd20 [cff, truetype] Validate variation axes immediately.
Instead of validating variation axes in every access, OpenType specs
suggest that peak = 0 be used to tag invalid ranges.  This implements
just that once during loading.

* src/cff/cffload.c (cff_blend_build_vector): Move the range checks...
(cff_vstore_load): ... here.
* src/truetype/ttgxvar.c (tt_var_get_item_delta): Ditto...
(tt_var_load_item_variation_store): ... ditto.
2024-05-21 16:24:43 -04:00
Alexei Podtelezhnikov
99be2b3154 [cff, truetype] Rearrange variation range checks.
This should achieve quicker results for common cases.

* src/cff/cffload.c (cff_blend_build_vector): Rearrange conditionals.
* src/truetype/ttgxvar.c (tt_var_get_item_delta): Ditto.
2024-05-21 18:26:09 +00:00
Alexei Podtelezhnikov
347276c1f6 * src/truetype/ttgxvar.c (tt_var_get_item_delta): Align with specs. 2024-05-21 13:12:45 +00:00
Alexei Podtelezhnikov
39f2fbf80c * src/truetype/ttgxvar.c (tt_var_get_item_delta): Minor refactoring. 2024-05-20 22:47:14 -04:00
Alexei Podtelezhnikov
4ccdc9f982 [cff] Optimize the blend vector computations.
* src/cff/cffload.c (cff_blend_build_vector): Use FT_MulDiv and skip
multiplying by 1.
2024-05-20 18:53:57 -04:00
Alexei Podtelezhnikov
b25265fe55 [bdf] Use concise macros.
* src/bdf/bdflib.c (bdf_create_property): Use FT_STRDUP.
(bdf_parse_glyphs_, bdf_parse_start_): Use FT_DUP for brevity.
2024-05-19 22:58:23 -04:00
Alexei Podtelezhnikov
026fd5d4f0 [cache] Use FT_DUP to duplicate data.
* src/cache/ftcsbits.c (ftc_sbit_copy_bitmap): Use concise FT_MEM_DUP.
2024-05-19 22:54:57 -04:00
Alexei Podtelezhnikov
d7cf931ac6 [truetype, type1] Use FT_DUP to duplicate data.
* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Use concise FT_DUP.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): Ditto.
* src/type1/t1load.c (parse_subrs): Ditto.
2024-05-19 22:48:13 -04:00
Alexei Podtelezhnikov
b8db819768 [type1/MM] Safer handle arrays of different types.
* src/type1/t1load.c (parse_blend_design_map): Separately allocate...
(T1_Done_Blend): ... and free `design_points` and `blend_points`.
2024-05-12 22:38:38 -04:00
Alexei Podtelezhnikov
5b1cde804d * src/type1/t1load.c (parse_blend_design_map): Add risky cast. 2024-05-11 23:27:34 -04:00
Alexei Podtelezhnikov
b875924a6f * src/pshinter/pshrec.c (ps_hints_stem): Correct argument. 2024-05-10 23:01:23 -04:00
Ben Wagner
5858fa16ca [colr] Avoid overflow in range checks
In 32 bit builds `FT_ULong` is 32 bits and can silently overflow when a
large number is read into one and then it is summed or multiplied with
another number.  Checks for range overflow must be written so that they
themselves do not overflow.  Also ensure that the table_size is always the
first part of the range check and consistently use `<` or `<=`.

* src/sfnt/ttcolr.c (tt_face_load_colr): Avoid overflow.
(find_base_glyph_v1_record): Remove old work-around.

Bug: https://issues.chromium.org/issues/41495455
Bug: https://issues.chromium.org/issues/40945818
2024-05-08 05:01:16 +02:00
Alexei Podtelezhnikov
d0e3239f32 [sdf, bsdf] Use shared FT_SqrtFixed.
FT_SqrtFixed (95b0fe2a6d) is faster and does not overflow.

* src/sdf/ftsdfcommin.h (square_root): Replace with a macro.
* src/sdf/ftsdfcommin.c (square_root): Remove function.
2024-05-06 13:39:06 +00:00
Alexei Podtelezhnikov
2edfd7e168 * src/autofit/aflatin.c (af_latin_metrics_scale_dim): Remove FT_ABS.
See
    https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68679
2024-05-04 16:42:47 -04:00
Alexei Podtelezhnikov
7bd887f177 * src/sfnt/sfwoff2.c (woff2_open_font): Fix copy-paste typo. 2024-05-03 16:04:35 +00:00
Alexei Podtelezhnikov
3f28a6b6af [woff,woff2] Limit the number of tables and use FT_MSB.
The upper limit of 4095 is implied by the SFNT header format
where the multiplication by 16 would overflow without it.

* src/sfnt/sfwoff.c (woff_open_font): Updated.
* src/sfnt/sfwoff2.c (woff2_open_font): Ditto.
2024-05-03 15:44:57 +00:00
Ben Wanger
13d1180f45 [woff2] Disallow zero table font entries
The existing code already disallows zero table woff2 overall, but still
allows for individual CollectionFontEntry to create font instances with
zero tables. Such fonts are not useful so error early.

This also fixes an MSAN discovered issue where if a CollectionFontEntry
numTables is zero then the sfnt_header was not fully initialized.

* src/sfnt/sfwoff2.c (woff2_open_font): error on zero tables, always
initalize sfnt_header

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68384
2024-05-02 15:00:27 -04:00
Alexei Podtelezhnikov
4d50468478 [sfnt] Use faster macros in checksums.
* src/truetype/ttobjs.c (tt_synth_sfnt_checksum): Use FT_NEXT_XXX.
* src/sfnt/sfwoff2.c (compute_ULong_sum): Use macros.
2024-05-01 23:19:31 -04:00
Alexei Podtelezhnikov
13da904267 * src/sfnt/sfwoff2.c (compute_ULong_sum): Clean up. 2024-05-01 00:34:21 -04:00