Commit graph

8162 commits

Author SHA1 Message Date
Craig White
17ef1ccccd [autofit] fix edge case in tilde measurement code
* src/autofit/aflatin.c (af_latin_stretch_tildes)
  Fix edge case where no measurements can be taken.
2025-03-08 13:27:53 -06:00
Craig White
73ee8e119b [autofit] Fix bugs in tilde handling code
* src/autofit/aflatin.c (af_latin_stretch_tildes)
  Fix 2 uninitialized stack variables
  Make a narrowing cast explicit

* src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments)
  Remove redundant variable declaration
2025-03-05 16:50:59 -06:00
Craig White
323a8a2163 [autofit] Fix and improve tilde centering
* src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments)
  Fix bug causing incorrect contour height calculation.  Change centering
  formula to be consistent with the one in af_latin_align_tildes.
2025-01-29 14:29:27 -05:00
Craig White
65d517dace Merge branch 'adjust' of https://gitlab.freedesktop.org/freetype/freetype into adjust 2025-01-29 00:09:30 -05:00
Craig White
cb432ad21e [autofit] fix vertical separation bug and improve style
* src/autofit/afadjust.c (af_glyph_hints_apply_vertical_separation_adjustments)
 improve code formatting, remove redundant trace calls,
 fix bug causing vertical separation to fail for some small sizes.

 (af_latin_hints_apply) make numbering of trace calls more logical.
2025-01-29 01:48:56 +00:00
Craig White
bc28bd77fc Rework autofitter to center tildes if they are small. 2025-01-29 01:48:56 +00:00
Werner Lemberg
e8e944f5db * docs/CHANGES: Mention Craig's GSoC 2023 project. 2025-01-29 01:48:56 +00:00
Craig White
2073452c43 [autofit] Add GSUB table handling to reverse character map generation.
If HarfBuzz is enabled, the reverse character map generation now considers
GSUB entries when looking for glyphs that correspond to a code point.

* src/autofit/afadjust.c (af_all_glyph_variants_helper,
af_all_glyph_variants) [FT_CONFIG_OPTION_USE_HARFBUZZ]: New functions.

(af_reverse_character_map_new) [FT_CONFIG_OPTION_USE_HARFBUZZ]: Call new
code.
2025-01-29 01:48:56 +00:00
Craig White
aaf61efd2b [autofit] Add tilde-unflattening algorithm.
* src/autofit/aflatin.c (af_find_highest_contour,
af_remove_segments_containing_point,
af_latin_remove_tilde_points_from_edges, af_latin_stretch_tildes,
af_latin_align_tildes): New functions.
(af_latin_hints_apply): Call tilde-unflatting code if necessary.
2025-01-29 01:48:56 +00:00
Craig White
03759a157a [autofit] Implement vertical separation adjustment.
* src/autofit/aflatin.c: Include `afadjust.h`.
(af_latin_metrics_init): Call `af_reverse_character_map_new`.
(af_latin_metrics_done): New function.

(af_move_contour_vertically, af_check_contour_horizontal_overlap,
af_glyph_hints_apply_vertical_separation_adjustments): New functions.

(af_latin_hints_apply): Call
`af_glyph_hints_apply_vertical_separation_adjustments`.

(af_latin_writing_system_class): Updated.

* src/autofit/aftypes.h (AF_StyleMetricsRec): Add `reverse_charmap` field.
2025-01-29 01:48:56 +00:00
Craig White
36275cd1cd [autofit] Add code for reverse charmaps and adjustment database lookup.
* src/autofit/aftypes.h (AF_ReverseMapEntry, AF_ReverseCharacterMap): New
structures.

* src/autofit/afadjust.c (af_adjustment_database_lookup,
af_reverse_character_map_entry_compare, af_reverse_character_map_lookup,
af_lookup_vertical_separation_type, af_lookup_tilde_correction_type,
af_reverse_character_map_expand, af_reverse_character_map_new,
af_reverse_character_map_done): New functions.

* src/autofit/afadjust.c: Updated.
2025-01-29 01:48:56 +00:00
Craig White
abf35d5c67 [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-01-29 01:48:56 +00:00
Craig White
aaa0b7881b [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-01-29 01:48:56 +00:00
Craig White
74e456d4f0 [autofit] fix vertical separation bug and improve style
* src/autofit/afadjust.c (af_glyph_hints_apply_vertical_separation_adjustments)
 improve code formatting, remove redundant trace calls,
 fix bug causing vertical separation to fail for some small sizes.

 (af_latin_hints_apply) make numbering of trace calls more logical.
2025-01-27 04:54:58 -05:00
Alexei Podtelezhnikov
00a1567a13 [bdf] Treat all comments uniformly.
* src/bdf/bdflib.c (bdf_parse_start_): Reject fonts with initial
COMMENTs.
(bdf_parse_properties_): Skip COMMENTs so that...
(bdf_add_property_): Do not make exception for COMMENT.
(bdf_parse_glyphs_, bdf_add_comments): Updated.
2025-01-24 22:36:56 -05:00
Alexei Podtelezhnikov
fdae51ccb0 * src/bdf/bdflib.c (BDF_SWIDTH_ADJ_): Remove clashing flag and update. 2025-01-24 22:03:00 -05:00
Alexei Podtelezhnikov
bfe793ccec * src/bdf/bdflib.c (bdf_atous_): Remove unnecessary checks. 2025-01-22 21:17:57 -05:00
Alexei Podtelezhnikov
40a7458500 * src/bdf/bdflib.c (bdf_ato{i.ul.s.us}_]): Remove uncecessary checks. 2025-01-22 21:05:22 -05:00
Alexei Podtelezhnikov
56131e4216 [bdf] Postpone font default char handling.
* src/bdf/bdflib.c (bdf_parse_start_, bdf_add_property_): Delay handling
of the default char until...
* src/bdf/bdfdrivr.c (BDF_Face_Init): ... handles all other properties.
2025-01-22 20:47:56 -05:00
Alexei Podtelezhnikov
8bae87065a [bdf] Postpone font spacing handling.
* src/bdf/bdf.h (bdf_font_t): Remove `monowidth`.
* src/bdf/bdflib.c (bdf_parse_start_, bdf_add_property_): Delay handling
of the font spacing until...
* src/bdf/bdfdrivr.c (BDF_Face_Init): ... handles all other properties.
2025-01-22 20:46:43 -05:00
Alexei Podtelezhnikov
c0a7839e7d [bdf] Postpone font ascent and descent handling.
* src/bdf/bdflib.c (bdf_parse_start_, bdf_add_property_): Delay handling
of the font ascent and descent until...
* src/bdf/bdfdrivr.c (BDF_Face_Init): ... handles all other properties.
2025-01-22 19:11:47 -05:00
Alexei Podtelezhnikov
c33da8fbbd * src/bdf/bdflib.c (bdf_parse_start_): Relax the header order.
We now check that the header is complete in no specific order.
2025-01-22 16:59:44 -05:00
Chad Brokaw
a059b237bb * src/truetype/ttgxvar.c (tt_face_vary_cvt): Fix all shared values.
Applying cvar deltas to all shared points was incorrectly omitted.
Fixes #1314.
2025-01-19 22:39:17 -05:00
Alexei Podtelezhnikov
b9e09e33fe * src/bdf/bdflib.c (bdf_parse_glyphs_): Fix tracing. 2025-01-19 12:35:13 -05:00
Alexei Podtelezhnikov
01c22b3668 [bdf] Tokenize input instead of listing.
Instead of cumbersome field list mamangement, we will tokenize input
using custom `bdf_strtok_`.

* src/bdf/bdflib.c (bdf_list_t_, bdf_list_init_, bdf_list_ensure_,
bdf_list_shift_, bdf_list_join_, bdf_list_split_,
bdf_set_default_spacing_): Removed.
(bdf_strtok_): New function which NUL-terminates the first token at
the delimiter position and returns the next token that follows
consequtive delimiters.
(bdf_parse_*_, bdf_load_font): Updated.

* docs/CHANGES: Claim overall 75% performance improvement.
2025-01-19 11:19:10 -05:00
Alexei Podtelezhnikov
ad7dce7751 * src/bdf/bdflib.c (bdf_parse_start_): Prevent another STARTPROPERTIES.
Only one STARTPROPERTIES was permitted in the old flow preventing
leaks and overflows.

See https://issues.oss-fuzz.com/issues/389968131
    https://issues.oss-fuzz.com/issues/390464875
2025-01-17 20:54:14 -05:00
Alexei Podtelezhnikov
e3a3b39dd0 * src/bdf/bdflib.c (bdf_parse_start_): Do not overwrite flags. 2025-01-16 23:25:08 +00:00
Alexei Podtelezhnikov
d4631a2eb3 * src/bdf/bdflib.c (bdf_readstream_): Skip all control characters.
This agrees with specifications and makes the code a lot simpler.
2025-01-16 20:54:33 +00:00
Alexei Podtelezhnikov
02953326d4 * src/bdf/bdflib.c (bdf_parse_start_): Reserve space for artificial properties. 2025-01-16 03:47:14 +00:00
Alexei Podtelezhnikov
ae11e18cbd * src/bdf/bdflib.c (bdf_add_property_): Add extra protection.
See https://issues.oss-fuzz.com/issues/389972472
    https://issues.oss-fuzz.com/issues/389968131
2025-01-15 15:50:12 +00:00
Alexei Podtelezhnikov
a0d86e5650 * src/bdf/bdflib.c: Clean up. 2025-01-14 22:58:04 -05:00
Alexei Podtelezhnikov
a3c68e3b48 [bdf] Use flags instead of options.
* src/bdf/bdf.h (bdf_options_t): Removed.
(BDF_KEEP_COMMENTS, BDF_KEEP_UNENCODED, BDF_CORRECT_METRICS): Updated
to avoid collisions with the other parsing flags.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Use default flags explicitly.
* src/bdf/bdflib.c (bdf_load_font): Use flags as an argument to
initialize the parser.
(bdf_set_fedault_spacing_): Default to BDF_PROPORTIONAL explicitly.
(bdf_parse_*_): Updated.
2025-01-14 22:32:46 -05:00
Alexei Podtelezhnikov
a05c22103d [bdf] Adjust parsing flow and CHARS handling.
* src/bdf/bdflib.c (bdf_readstream_): Remove CHARS exception.
(bdf_parse_glyphs_): Move glyphs allocation...
(bdf_parse_properties_): and missing ascent and descent handling...
(bdf_parse_start_): ...to here under CHARS.
2025-01-14 21:11:33 -05:00
Alexei Podtelezhnikov
0864367ada * src/bdf/bdflib.c (bdf_readstream_): Tweak variables and loop design. 2025-01-14 18:39:50 -05:00
Alexei Podtelezhnikov
ee1310ab5c * src/bdf/bdflib.c (bdf_parse_glyphs_): Free unused glyph_name.
See https://issues.oss-fuzz.com/issues/389330334.
2025-01-13 17:19:31 +00:00
Alexei Podtelezhnikov
f219996754 * src/bdf/bdflib.c (bdf_parse_glyphs_): Store glyph as soon as possible. 2025-01-13 03:48:28 +00:00
Alexei Podtelezhnikov
aab40d5cc4 * src/bdf/bdflib.c (bdf_parse_glyphs_): Avoid possible leak. 2025-01-12 00:24:42 -05:00
Alexei Podtelezhnikov
bbc445e165 [bdf] Speed up bitmap parsing.
A dedicated parser of bitmap data with minimal error checking and
no string comparisons helps to improve performance.

* src/bdf/bdflib.c (bdf_parse_bitmap_): New dedicated bitmap parser.
(bdf_parse_glyphs_): Pass to `bdf_parse_bitmap_` on BITMAP.
2025-01-11 23:11:07 -05:00
Alexei Podtelezhnikov
4433c7b7ba * src/bdf/bdflib.c (a2i): Formatting. 2025-01-11 18:54:04 -05:00
Alexei Podtelezhnikov
ff5872b4da * src/bdf/bdflib.c (bdf_parse_*_): Minor improvements. 2025-01-10 22:55:13 -05:00
Alexei Podtelezhnikov
cf451e5ff3 * src/bdf/bdf.h (bdf_font_t): Correct internal type.
* src/bdf/bdflib.c (*): Update users.
2025-01-10 22:31:07 -05:00
Alexei Podtelezhnikov
8d536080ec * builds/windows/ftsystem.c: Fix ancient condition. 2025-01-10 22:44:40 +00:00
Alexei Podtelezhnikov
1f57020ff3 * src/bdf/bdflib.c (bdf_parse_start_): Fix tracing labels. 2025-01-10 03:23:41 +00:00
Alexei Podtelezhnikov
704d540527 * MSBuild.rsp: Force console color for mintty. 2025-01-09 15:18:55 +00:00
Heiko Lewin
1400b20ae8 * CMakeLists.txt: Use modern IMPORTED targets.
This resolves build problems with newer libPNG versions by switching
to using IMPORTED CMake targets for common libraries where provided.
To do this the required CMake version is raised to version 3.12.
Doing this seems justified as using IMPORTED targets is a cleaner
and more powerful solution that can leverage advanced and CMake-specific
features that may be utilized by the referred dependencies' CMake modules.

Resolves #1311.
2025-01-09 13:21:50 +00:00
Alexei Podtelezhnikov
73318c864a [cff] Remove size/slot checks.
After the previous commit, cff_glyph_load is no longer called
without first checking for valid size and glyph objects in
FT_Glyph_Load and these checks can be removed downstream.

* src/cff/cffdrivr.c (cff_glyph_load): Remove `size` and `glyph` checks.
* src/cff/cffgload.c (cff_slot_load): Ditto.
2025-01-08 15:45:32 -05:00
Alexei Podtelezhnikov
c7a255b462 * src/cff/cffdrivr.c (cff_get_advances): Do only fast advances.
Otherwise, let TT_Get_Advances fall back on cff_load_glyph to do
slow advances. This avoids unchecked access to cff_load_glyph and
this is how tt_get_advances is implemented.
2025-01-07 19:52:29 -05:00
Alexei Podtelezhnikov
81330e1f8a * src/truetype/ttgload.c (TT_Load_Glyph): Consolidate flag setting. 2025-01-03 22:54:20 -05:00
Alexei Podtelezhnikov
5245fd69fd Delay FT_GLYPH_FORMAT_OUTLINE assignmets.
This assignmets used to be done prematurely before errors were checked
and outlines were actually loaded. Delaying the assignment provides
certain protection against careless usage of malformed input that
should now remain FT_GLYPH_FORMAT_NONE.

* src/cff/cffgload.c (cff_slot_load): Ditto.
* src/cid/cidgload.c (cid_slot_load_glyph): Ditto.
* src/pfr/pfrobjs.c (pfr_slot_load): Ditto.
* src/truetype/ttgload.c (TT_Load_Glyph): Ditto.
* src/type1/t1gload.c (T1_Load_Glyph): Ditto.
2025-01-03 21:26:10 -05:00
Alexei Podtelezhnikov
afc7000cac * builds/compiler/gcc-dev.mk: Silence some warnings. 2025-01-03 18:17:49 +00:00