Commit Graph

8043 Commits

Author SHA1 Message Date
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 (Алексей Подтележников) a498873652 * .gitlab-ci.yml: Disable UWP compilation. 2024-05-23 03:05:59 +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 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 cdd3572e52 * builds/windows/ftsystem.c: Use _WINRT_DLL to check for UWP.
Fixes compilation using Windows GDK, reported by Erin Melucci.
2024-05-17 22:25:00 -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 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 e834786b34 * docs/CHANGES: Mention the last commit. 2024-05-11 23:25:37 -04: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
Alexei Podtelezhnikov b875924a6f * src/pshinter/pshrec.c (ps_hints_stem): Correct argument. 2024-05-10 23:01:23 -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
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
Werner Lemberg 2240e21cf5 .mailmap: Fix entry for Ben Wagner. 2024-05-06 21:53:24 +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
Alexei Podtelezhnikov 2c9691e7c1 * docs/CHANGES: Updated. 2024-04-30 12:59:52 +00:00
Alexei Podtelezhnikov 5962d3c1b9 * src/cache/ftccache.c (FTC_Cache_RemoveFaceID): Remove nodes instantly. 2024-04-29 22:34:09 -04:00
Alexei Podtelezhnikov a209e1adcd [cache] Remove unused `node_reset`.
* src/cache/ftcmru.h (FTC_MruListClassRec): Remove `node_reset` field.
* src/cache/ftcbasic.c (ftc_basic_{image,sbit}_family_class): Ditto.
* src/cache/ftcmanag.c (ftc_face_list_class): Ditto.
(ftc_size_node_reset): Remove function.
* src/cache/ftcglyph.h: Fix comment.
2024-04-29 17:54:30 -04:00
Alexei Podtelezhnikov f8f0d1a1d9 * src/cache/ftcmru.c (FTC_MruList_New): Do not reset nodes.
Resetting of the size nodes can crash, if a parent face purge happens
simultaneously and destroys the node. It is safer to create a new node.
Fixes #1270, reopened with a separate issue.
2024-04-29 16:58:59 -04:00
Alexei Podtelezhnikov 1168b1b5b0 * src/cache/ftcimage.c (ftc_inode_weight): Formatting. 2024-04-27 20:44:01 -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 982bc83849 [cache] Minor tweaks.
* src/cache/ftcimage.c (ftc_inode_free): Remove unnecessary check.
* src/cache/ftcmanag.c (FTC_Manager_Done): Do not zero before freeing.
2024-04-21 15:53:05 -04:00
Alexei Podtelezhnikov 5a3bfa92d9 * src/cache/ftcbasic.c: Cosmetic harmonization. 2024-04-20 23:28:17 -04:00
Alexei Podtelezhnikov 23e1d64556 [cache] Reduce type mismatches.
* src/cache/ftcbasic.c (FTC_BasicAttrRec): Match type of `load_flags`
to its main purpose in `FT_Load_Glyph`.
(FTC_ImageCache_Lookup{,Scaler},FTC_SBitCache_Lookup{,Scaler}): Updated.
2024-04-20 12:01:58 -04:00
Alexei Podtelezhnikov 9a2d6d97b2 * src/cache/{ftcbasic.c,ftccmap.c}: Use FTC_INLINE. 2024-04-19 14:45:39 -04:00
Alexei Podtelezhnikov dbdcd75889 [cache] Tweak headers.
* src/cache/ftccback.h: Include less and move `ftc_node_destroy`...
* src/cache/ftccache.h: ... to here.
* src/cache/ftcmanag.c: Include less.
2024-04-19 14:02:43 -04:00
Alexei Podtelezhnikov db83e9c0ec * src/cache/ftcglyph.c [!FTC_INLINE]: Fix compilation. 2024-04-18 23:23:13 -04:00
Alexei Podtelezhnikov 12adfc212b [cache] Improve MRU list management.
* src/cache/ftcmru.c (FTC_MruList_Remove): Cosmetic.
(FTC_MruList_New): Accept only valid changes.
* src/cache/ftcmanag.c (ftc_size_node_done):  Simplify.
2024-04-17 15:07:23 +00:00
Alexei Podtelezhnikov d091bca546 [cache] Fix error handling.
Manipulate the cache after a face is requested or a size is looked up
successfully. Fixes #1270.

* src/cache/ftcmanag.c (ftc_size_node_init, ftc_size_node_reset,
ftc_face_node_init): Check for errors before accepting a change.
* src/cache/ftcmru.c (FTC_MruList_New): Do nothing if reset fails.
2024-04-17 00:33:14 -04:00
Alexei Podtelezhnikov b3a6a20a80 [smooth] Switch to vertical bisections.
With horizontal bisections, the smallest section is a whole single
scanline. Almost horizontal lines or other complex scanlines can
easily overflow the rendering pool. Switching to vertical bisections
splits the scanlines and should rule out the overflows.  Fixes #1269.

* src/smooth/ftgrays.c (gray_convert_glyph): Bisect vertically.
2024-04-14 15:37:57 -04:00