src/autofit/aflatin.c

Branch


Log

Author Commit Date CI Message
Werner Lemberg 4334f009 2025-09-28T08:09:48 [autofit] Prevent signed integer overflow. * src/autofit/aflatin.c (af_latin_stretch_top_tilde, af_latin_stretch_bottom_tilde, af_latin_align_top_tilde, af_latin_align_bottom_tilde, af_glyph_hints_apply_vertical_separation_adjustments): Use `ADD_LONG` and `SUB_LONG` for values that involve `FT_LONG_MAX` and `FT_LONG_MIN`. Fixes issue #1363.
Werner Lemberg 32cb5390 2025-09-06T06:14:03 Update all copyright notices.
Werner Lemberg f1be7392 2025-07-01T18:00:12 More signedness fixes. As reported by clang 19. * src/autofit/afadjust.c (add_substitute): Make first argument unsigned. Update all callers. Other minor signedness fixes. (af_reverse_character_map_new): Minor signedness fixes. * src/autofit/afgsub.c (af_hash_insert): Minor signedness fixes. * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Make third argument unsigned. Update all callers. Other minor signedness fixes. (af_latin_hints_apply): Minor signedness fixes. * src/bdf/bdflib.c (bdf_parse_bitmap_): Minor signedness fix. * src/truetype/ttobjs.c (tt_size_init_bytecode): Minor signedness fix.
Werner Lemberg 8d82c9fa 2025-07-01T17:08:37 */*: Fix trivial signedness issues with format strings in trace messages. As reported with clang 19's `-Wformat` option.
Werner Lemberg c6abd1e4 2025-05-26T20:24:55 [autofit] Fix integer overflow. Reported as https://issues.oss-fuzz.com/issues/420401635 * src/autofit/aflatin.c (af_latin_stretch_top_tilde, af_latin_stretch_bottom_tilde): Use `SUB_LONG`.
Werner Lemberg 47e35a58 2025-05-16T08:08:53 [autofit] Simplify return value of `af_adjustment_database_lookup`. * src/autofit/adfadjust.h (af_adjustment_database_lookup): Return integer. (AF_AdjustmentDatabaseEntry): Move structure to... * src/autofit/afadjust.c: ...this file. (af_adjustment_database_lookup, af_reverse_character_map_new): Updated. * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Updated.
Werner Lemberg 2492b547 2025-05-16T07:39:06 [autofit] Use a hash for handling vertical accent adjustments. This greatly simplifies the code. * src/autofit/afadjust.c (af_reverse_character_map_new): Implement it. (af_reverse_character_map_done): Updated. * src/autofit/afadjust.h: Updated. * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Updated. * src/autofit/aftypes.h: Include `fthash.h`. (AF_StyleMetrics): Change type of `reverse_charmap` to `FT_Hash`.
Werner Lemberg 70154166 2025-05-16T07:20:57 * src/autofit/aflatin.c (af_latin_hints_apply): Improve code legibility.
Werner Lemberg 9dc66cbd 2025-05-20T05:36:49 [autofit] Use `FT_LONG_MIN` and `FT_LONG_MAX` for `FT_Pos` variables. * src/autofit/aflatin.c (af_latin_metrics_init_blues, af_compute_vertical_extrema, af_find_highest_contour, af_find_second_highest_contour, af_find_lowest_contour, af_find_second_lowest_contour, af_check_contour_horizontal_overlap): Updated.
Werner Lemberg d6e087d1 2025-05-19T16:13:06 [autofit] Fix uninitialized variables. * src/autofit/aflatin.c (af_latin_stretch_top_tilde, af_latin_stretch_bottom_tilde): Initialize `min_measurement`.
Werner Lemberg f68733d4 2025-05-19T05:23:29 [autofit] Speed up construction of reverse character map. (1/4) Build reverse cmap for characters of the current script style only. * src/autofit/afadjust.c (in_range): New function. (af_reverse_character_map_new): Pass `AF_StyleMetrics` instead of `AF_FaceGlobals` so that we can access the current script style. Use `in_range` to limit tested code points. * src/autofit/afadjust.h: Updated. * src/autofit/aflatin.c (af_latin_metrics_init): Updated.
Werner Lemberg b87f48a7 2025-05-19T15:48:24 * src/aflatin.c (af_latin_hint_edges): Refine fix for serif handling. Commit 11432424 (from 2025-May-12) was too aggressive; it is now restricted to edges that are not too far away.
Werner Lemberg d3fbbed9 2025-05-13T14:44:20 [autofit] Fix vertical adjustment of (mainly) double diacritics. The series of commits that introduced this adjustment support had some flaws. - If there were two diacritics on top of a base glyph, and the upper diacritic was a tilde, the vertical centering correction was incorrectly applied to the lower, non-tilde glyph instead of the tilde. - The maximum value allowed to shift a glyph was too strict (and also not handling rounding issues), causing some diacritics and combinations of diacritics to be not shifted at all. * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Correctly handle vertical centering correction.
Werner Lemberg 4c9f14f4 2025-05-12T18:04:14 [autofit] Code hygiene. * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Use more flag variables and improve trace messages.
Werner Lemberg 11432424 2025-05-12T08:52:19 * src/autofit/aflatin.c (af_latin_hint_edges): Fix handling of serifs. This has been discovered while inspecting the auto-hinting results of character 'Ễ' in font `arial.ttf` (version 7.00) at 13ppem.
Werner Lemberg 87f0b694 2025-05-12T14:02:31 [autofit] Minor. * src/autofit/aflatin.c (af_latin_hint_edges): Rename `has_serifs` to `has_non_stem_edges` and make it of type `FT_Bool`.
Werner Lemberg fd66a29d 2025-05-12T08:28:55 [autofit] New algorithm for preventing hinting of tilde glyphs. The old algorithm removed segments from edges to make the auto-hinter ignore a tilde. However, the implementation had two flaws. - Edge array elements were moved around without reordering them afterwards. - The linking between edges and segments wasn't correctly updated for moved edges, which could cause endless loops. Correcting both problems are non-trivial; additionally, a fix would make the auto-hinter slower. For these reasons, a new, simpler approach is taken: A new flag allows points to be tagged as being ignored, and if such a point is enountered, it doesn't get added to a segment. Fixes issue #1333. * src/autofit/afhints.h (AF_FLAG_IGNORE): New macro. * src/autofit/aflatin.c (af_latin_hints_compute_segments, af_touch_contour): Use it. (af_remove_segments_containing_point, af_remove_top_points_from_edges, af_remove_bottom_points_from_edges): Removed. (af_latin_stretch_top_tilde): Call `af_touch_top_contours` and `af_touch_bottom_contours` unconditionally. (af_latin_hints_apply): Updated.
Werner Lemberg 15b7e8c3 2025-05-14T10:20:04 Whitespace, formatting, minor spelling fix.
Werner Lemberg 3e079bd7 2025-05-05T18:02:44 [autofit] Add safety check for accent adjustments. This commit does two things. - Ignore accents that have too large heights. This situation can happen if an accent outline is unexpectedly not the highest (or lowest) contour. - Add a new adjustment flag `AF_ADJUST_NO_HEIGHT_CHECK` to override the height check. * src/autofit/afadjust.h (AF_ADJUST_NO_HEIGHT_CHECK): New macro. * src/autofit/afadjust.c (adjustment_database): Updated. * src/autofit/aflatin.c (af_latin_hints_apply): Handle new flag. (af_glyph_hints_apply_vertical_separation_adjustments): Check limit.
Werner Lemberg 620daa3c 2025-05-03T20:35:42 [autofit] Better handling of characters with attached diacritics. (2/3) * src/autofit/afadjust.h (AF_IGNORE_CAPITAL_TOP, AF_IGNORE_CAPITAL_BOTTOM, AF_IGNORE_SMALL_TOP, AF_IGNORE_SMALL_BOTTOM): New macros. * src/autofit/afadjust.c (af_reverse_character_map_new) [FT_DEBUG_LEVEL_TRACE]: Updated. Also fix debugging strings of other flags. * src/autofit/afhints.h (AF_EDGE_NO_BLUE): New edge flag to make the auto-hinter ignore the edge while assigning blue zones. * src/autofit/aflatin.c (af_latin_hints_compute_blue_edges): Use it. (af_prevent_top_blue_alignment, af_prevent_bottom_blue_alignment, af_latin_get_base_glyph_blues, af_latin_ignore_top, af_latin_ignore_bottom): New functions. (af_latin_hints_apply): Updated.
Werner Lemberg a37e11c3 2025-05-01T06:19:25 [autofit] Better handling of characters with attached diacritics. (1/3) Introduce blue zone properties that will be used to make the auto-hinter ignore diacritics attached on the top or the bottom of a base character. * src/autofit/afblue.hin (AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM, AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM): New properties. * src/autofit/afblue.dat: Use them. * src/autofit/afblue.c, src/autofit/afblue.h: Rengenerated. * src/autofit/aflatin.h (AF_LATIN_IS_CAPITAL_BOTTOM_BLUE, AF_LATIN_IS_SMALL_BOTTOM_BLUE, AF_LATIN_BLUE_BOTTOM, AF_LATIN_BLUE_BOTTOM_SMALL): New macros. * src/autofit/aflatin.c (af_latin_metrics_init_blues)[FT_DEBUG_LEVEL_TRACE]: Updated.
Werner Lemberg ab0fe6d5 2025-05-05T19:38:04 [autofit] Avoid division by zero. Fixes issue #1331. * src/autofit/aflatin.c (af_latin_stretch_bottom_tilde): Don't divide by zero.
Behdad Esfahbod (بهداد اسفهبد) 97bb53ee 2025-04-28T07:24:41 [autofit] Enable dynamic loading of HarfBuzz. (2/2) Handle the case where loading HarfBuzz dynamically fails. * src/autofit/ft-hb.c, src/autofit/ft-hb.h (ft_hb_enabled): New function. * src/autofit/afglobal.c (af_face_globals_new, af_face_globals_free): Guard HarfBuzz functions with `ft_hb_enabled`. * src/autofit/aflatin.c (af_latin_metrics_init_widths, af_latin_metrics_init_blues, af_latin_metrics_check_digits): Simplify setup of `shaper_buf`. Guard calls of `af_shaper_buf_create` with `ft_hb_enabled`. * src/autofit/afcjk.c (af_cjk_metrics_init_widths, af_cjk_metrics_init_blues, af_cjk_metrics_check_digits): Dito. * src/autofit/afshaper.c: Guard all HarfBuzz function calls with `ft_hb_enabled`.
Behdad Esfahbod (بهداد اسفهبد) e9d03072 2025-04-26T19:05:31 [autofit] Some preparations for loading HarfBuzz dynamically. (2/4) Pass `AF_FaceGlobals` to many functions, or provide it, tagged with `FT_UNUSED`. We need this later on to access a dynamically linked HarfBuzz library. * src/autofit/ft-hb-ft.h (ft_hb_ft_font_create): Use `globals` argument. Drop unused `destroy` argument. * src/autofit/ft-hb-ft.c (ft_hb_ft_face_create, ft_hb_ft_font_create): Use `globals` argument. Drop unused `destroy` argument. (ft_hb_ft_face_create, ft_hb_ft_reference_table): Cast `user_data` to `AF_FaceGlobals`. * src/autofit/afadjust.c (af_get_glyph_alternates_helper, af_get_glyph_alternates): Add `globals` argument. Update callers. * src/autofit/afshaper.c, src/autofit/afshaper.h (af_shaper_buf_create, af_shaper_buf_destroy): Use `globals` argument. * src/autofit/afglobal.c (af_face_globals_new): Updated. * src/autofit/afcjk.c (af_cjk_metrics_init_widths, af_cjk_metrics_init_blues, af_cjk_metrics_check_digits): Updated. * src/autofit/aflatin.c (af_latin_metrics_init_widths, af_latin_metrics_init_blues, af_latin_metrics_check_digits): Updated.
Werner Lemberg f35bb759 2025-04-29T21:14:21 * src/autofit/aflatin.c (af_latin_stretch_top_tilde): Don't divide by zero. Reported as https://issues.oss-fuzz.com/issues/414320186
Werner Lemberg d38a13dd 2025-04-25T17:58:56 [autofit] Support diacritics with special vertical minima. This code catches situations like U+1F90 ('ᾐ'), where some fonts have exactly the same vertical minimum for the lower accent as for the base glyph. * src/autofit/aflatin.c (af_find_highest_contour, af_find_lowest_contour): Handle it.
Werner Lemberg 9eb6548d 2025-04-25T12:28:18 [autofit] More tilde stretch support. (3/3) The auto-hinter now supports up to four tilde glyphs (two above and two below a base character). Note that diacritics above (or below) a tilde are now also ignored by the auto-hinter. * src/autofit/afadjust.h (AF_ADJUST_TILDE_TOP2, AF_ADJUST_TILDE_BOTTOM2): New macros. * src/autofit/afadjust.c (af_reverse_character_map_new): Updated. * src/autofit/aflatin.c (af_remove_top_points_from_edges, af_remove_bottom_points_from_edges): Make functions also handle all contours higher (or lower) of the given one in the argument. (af_touch_top_contours, af_touch_bottom_contours): New functions. (af_latin_stretch_top_tilde, af_latin_stretch_bottom_tilde): Use it to also handle all contours higher (or lower) than the tilde contour. * (af_latin_hints_apply): Handle more tilde glyphs.
Werner Lemberg c6b45a76 2025-04-25T12:26:45 [autofit] More tilde stretch support. (2/3) * src/autofit/aflatin.c (af_latin_stretch_top_tilde, af_latin_stretch_bottom_tilde): Return vertical size difference between stretched and original contour. (af_latin_align_top_tilde, af_latin_align_bottom_tilde): Return applied delta. (af_latin_hints_apply): Updated; the return values are not used yet.
Werner Lemberg cbce230d 2025-04-24T08:13:54 [autofit] More tilde stretch support. (1/3) Move some existing code that we soon need elsewhere into separate functions. * src/autofit/aflatin.c (af_move_contours_up, af_move_contours, down): New functions. (af_glyph_hints_apply_vertical_separation_adjustments): Use them. (af_touch_contour): New function. (af_latin_stretch_top_tilde, af_latin_stretch_bottom_tilde): Use it. (af_latin_remove_top_tilde_points_from_edges, af_latin_remove_bottom_tilde_points_from_edges): Renamed to... (af_remove_top_points_from_edges, af_remove_bottom_points_from_edges): ...this. Update callers.
Werner Lemberg 7722a5b2 2025-04-23T19:29:59 [autofit] Support two below/above accents for vertical adjustment. (2/2) * src/autofit/afadjust.h (AF_ADJUST_UP2, AF_ADJUST_DOWN2): New macros. * src/autofit/afadjust.c (af_reverse_character_map_new): Updated. * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Implement it.
Werner Lemberg 40d4b579 2025-04-23T19:13:45 [autofit] Support two below/above accents for vertical adjustment. (1/2) Some variable renamings.
Werner Lemberg 619305c4 2025-04-23T17:35:21 [autofit] Routines for finding the second highest/lowest contour. * src/autofit/aflatin.c (af_find_second_highest_contour, af_find_second_lowest_contour): New functions.
Werner Lemberg 7a2646e6 2025-04-23T06:47:33 [autofit] Use more functions to reduce code. * src/autofit/aflatin.c (af_find_highest_contour, af_find_lowest_contour): Updated. (af_glyph_hints_apply_vertical_separation_adjustments): Use `af_compute_vertical_extrema`, `af_find_highest_contour`, and `af_find_lowest_contour`. (af_latin_hints_apply): Use `af_compute_vertical_extrema`,
Werner Lemberg 387c2d80 2025-04-23T06:44:10 * src/autofit/aflatin.c (af_compute_vertical_extrema): New function. To be used in a follow-up commit.
Werner Lemberg 357032d1 2025-04-22T19:48:16 * src/autofit/aflatin.c: Some variable renaming.
Werner Lemberg 25369eca 2025-04-22T18:24:25 [autofit] Avoid recomputation of highest and lowest contour. * src/autofit/aflatin.c (af_latin_hints_apply): Compute highest and lowest contour in this function. (af_latin_remove_top_tilde_points_from_edges, af_latin_remove_bottom_tilde_points_from_edges, af_latin_stretch_top_tilde, af_latin_stretch_bottom_tilde, af_latin_align_top_tilde, af_latin_align_bottom_tilde): Updated.
Werner Lemberg 64da9d47 2025-04-22T18:10:26 * src/aflatin.c (af_latin_trace_height): Remove. Update caller. The algorithm works fine.
Werner Lemberg ba94c954 2025-04-22T12:43:55 [autofit] Support vertical stretching of tilde below base glyph. (2/2) * src/autofit/afadjust.h (AF_ADJUST_TILDE_BOTTOM): New macro. * src/autofit/afadjust.c (af_reverse_character_map_new): Updated. * src/autofit/aflatin.c (af_find_lowest_contour, af_latin_remove_bottom_tilde_points_from_edges, af_latin_stretch_bottom_tilde, af_latin_align_bottom_tilde): New functions in analogy to the top tilde versions. (af_glyph_hints_apply_vertical_separation_adjustments): Add support in analogy to the top tilde code. (af_latin_hints_apply): Updated.
Werner Lemberg ec28f488 2025-04-21T13:38:17 [autofit] Support vertical stretching of tilde below base glyph. (1/2) * src/autofit/aflatin.c (af_latin_remove_tilde_points_from_edges, af_latin_stretch_tilde, af_latin_align_tilde): Rename to... (af_latin_remove_top_tilde_points_from_edges, af_latin_stretch_top_tilde, af_latin_align_top_tilde): ...this. Update all callers. (af_latin_hints_apply): Rename `is_tilde` to `is_top_tilde`.
Werner Lemberg 8d1f5156 2025-04-21T09:55:44 [autofit] Allow vertical adjustment at the top and bottom simultaneously. This will be used to hint characters like U+1FB7 ('ᾷ'). * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Implement it.
Werner Lemberg 162a93b1 2025-04-21T07:00:07 [autofit] Indicate tilde handling with a flag macro, too. * src/autofit/afadjust.h (AF_ADJUST_TILDE_TOP): New macro. (AF_AdjustmentDatabaseEntry): Remove field `apply_tilde`. * src/autofit/afadjust.c (adjustment_database, af_reverse_character_map_new), src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments, af_latin_hints_apply): Updated.
Werner Lemberg 582cc21b 2025-04-21T06:37:45 [aflatin] Convert adjustment database enum to macros. We are going to add more values, and we want to use combinations of them. * src/autofit/afadjust.h (AF_VerticalSeparationAdjustmentType): Replace with... (AF_ADJUST_UP, AF_ADJUST_DOWN, AF_ADJUST_NONE): ... new macros. (AF_AdjustmentDatabaseEntry): Rename field `vertical_separation_adjustment_type` to `flags`. * src/autofit/afadjust.c (af_reverse_character_map_new), src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Updated.
Werner Lemberg 566e30c1 2025-04-21T05:47:41 [autofit] Shorten adjustment enum names. * src/autofit/afadjust.h (AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP, AF_VERTICAL_ADJUSTMENT_BOTTOM_CONTOUR_DOWN, AF_VERTICAL_ADJUSTMENT_NONE): Renamed to... (AF_ADJUST_UP, AF_ADJUST_DOWN, AF_ADJUST_NONE): ...this. * src/autofit/afadjust.c (adjustment_database, af_reverse_character_map_expand), src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Updated.
Werner Lemberg d6c29228 2025-04-17T19:36:51 [autofit] Don't access uninitialized memory. Reported as https://bugs.ghostscript.com/show_bug.cgi?id=708295 * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Initialize all array elements of `contour_y_minima` and `contour_y_maxima`.
Werner Lemberg cc849c32 2025-04-16T19:39:02 [autofit] Avoid crash. Reported as https://issues.oss-fuzz.com/issues/410811029 * src/autofit/aflatin.c (af_remove_segments_containing_point): Check `edge->last`.
Werner Lemberg 05797069 2025-04-14T09:22:10 [autofit] Reduce adjustment database lookups. This is also in preparation for a follow-up commit. * src/autofit/afadjust.h (af_lookup_vertical_separation_type, af_lookup_tilde_correction_type): Replaced with... (af_adjustment_database_lookup, af_reverse_character_map_lookup): ... this. * src/autofit/afadjust.c (af_adjustment_database_lookup, af_adjustment_database_lookup): Updated. (af_lookup_vertical_separation_type, af_lookup_tilde_correction_type): Removed. (af_reverse_character_map_new)[FT_DEBUG_LEVEL_TRACE]: Updated. * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments, af_latin_hints_apply): Updated.
Werner Lemberg 218c59a2 2025-04-11T07:38:03 [autofit] Better vertical separation adjustment support. (2/2) * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Handle diacritics with more than a single contour.
Werner Lemberg 52d4573e 2025-04-11T07:30:55 [autofit] Better vertical separation adjustment support. (1/2) Test vertical maxima instead of vertical minima to identify the highest contour (and vice versa to identify the lowest contour). Doing so will allow support of diacritics that consist of more than a single outline. This works because of the topological constraints ensured by the adjustment database. * src/autofit/aflatin.c (af_find_highest_contour, af_glyph_hints_apply_vertical_separation_adjustments): Implement it.
Werner Lemberg c6106cff 2025-04-10T14:05:14 [autofit] Use new y extrema arrays. * src/autofit/aflatin.c (af_glyph_hints_apply_vertical_separation_adjustments): Implement it.
Werner Lemberg 53a5e2e6 2025-04-15T06:58:52 [autofit] Avoid crash. Reported as https://issues.oss-fuzz.com/issues/410609442 * src/autofit/aflatin.c (af_remove_segments_containing_point): Check `edge`.
Craig White 771449f1 2024-01-29T08:32:21 [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_tilde, af_latin_align_tilde): New functions. (af_latin_hints_apply): Call tilde-unflatting code if necessary.
Craig White 7099b09e 2024-01-29T08:21:09 [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.
luz paz f92c9655 2024-08-13T23:29:13 Fix various typos.
Alexei Podtelezhnikov 2edfd7e1 2024-05-04T16:42:47 * src/autofit/aflatin.c (af_latin_metrics_scale_dim): Remove FT_ABS. See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68679
Alexei Podtelezhnikov 47574f7e 2024-01-27T11:11:22 Update all copyright notices.
Werner Lemberg 45903920 2023-09-05T08:07:17 [autofit] Fix synchronization mistake between FreeType and ttfautohint. Found by Behdad. * src/autofit/aflatin.c (af_latin_metrics_init_blues): Fix array size of `blue_sorted`: FreeType doesn't have artificial blue zones.
Werner Lemberg a20de84e 2023-08-12T11:47:41 Fix warnings in tracing messages for 32bit compilation. Since we now require C99, use `%td` for `ptrdiff_t` and `%zu` for `size_t`.
Ben Wagner 7bed7a02 2023-06-01T21:05:32 Fix some `FT_Fixed` vs. `FT_Long` confusion. `FT_Fixed` and `FT_Long` are both typedef'ed to be `signed long`. However, `FT_Fixed` implies that the lower 16 bits are being used to express fractional values and so these two types should not be confused. * include/freetype/internal/services/svmm.h (FT_Set_MM_Blend_Func): Use `FT_Fixed` for `coords`. Users are passing `FT_Fixed` and implementations are taking `FT_Fixed`. (FT_Get_MM_Blend_Func): Ditto. * src/autofit/afcjk.c (af_cjk_metrics_check_digits): Use `FT_Long` for `advance` and `old_advance`. `advance`'s address is passed as `FT_Long*` to `af_shaper_get_elem`, which writes the advance in em units (not fixed). The exact value is not important here as it is only compared to check whether it has changed. * src/autofit/aflatin.c (af_latin_metrics_check_digits): Ditto.
Werner Lemberg 5edd6d52 2023-05-08T07:22:59 Minor compiler warning fixes. * src/autofit/afcjk.c (af_cjk_get_standard_widths), src/autofit/aflatin.c (af_latin_get_standard_widths): Use `FT_CALLBACK_DEF`. * src/cff/cffparse.c (cff_parser_run): Initialize and fix allocation of `q`.
Werner Lemberg 274e0dd5 2023-05-07T19:54:46 [autofit] Signature fixes.
Werner Lemberg cfe54d6a 2023-04-26T13:15:57 s/this is,/that is,/
Alexei Podtelezhnikov 7f949904 2023-02-20T23:29:58 [autofit] Clean up contour indexing. * src/autofit/aflatin.c (af_latin_metrics_init_blues): Refactor. * src/autofit/afcjk.c (af_cjk_metrics_init_blues): Ditto.
Werner Lemberg be724c81 2023-02-07T22:24:53 For debugging, avoid implicit conversion from integer to double. Otherwise we get zillions of clang 15 warnings. * src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c, src/base/ftobjs.c, src/base/ftoutln.c, src/cff/cffparse.c, src/raster/ftraster.c, src/sfnt/pngshim.c, src/truetype/ttgload.c, src/truetype/ttgxvar.c, src/truetype/ttobjs.c, src/type1/t1gload.c: Use `double` cast in debugging and tracing macros.
Werner Lemberg 65f85237 2023-01-17T09:18:25 Update all copyright notices.
Alexei Podtelezhnikov 0417527d 2022-10-03T19:23:26 [autofit] Reset the face charmap directly. There is no need to validate the original charmap in `FT_Set_Charmap`. It can be reset directly. * src/autofit/afglobal.c (af_face_globals_compute_style_coverage): Use direct assignment. * src/autofit/af{latin,cjk,indic}.c (af_latin_metrics_init): Ditto.
Alexei Podtelezhnikov 4f195185 2022-08-01T09:52:43 [autofit] Updated to reduce casting. * src/autofit/afglobal.h (AF_FaceGlobalsRec): Change `glyph_count` type. * src/autofit/afglobal.c (af_face_globals_compute_style_coverage, af_face_globals_get_metrics, af_face_globals_is_digit, af_face_globals_new): Changed local types and updated accordingly. * src/autofit/aflatin.c (af_latin_metrics_init_blues): Ditto.
Alexei Podtelezhnikov ee72e285 2022-07-29T22:55:28 [autofit] Use unsigned accounting for hints. * src/autofit/afhints.h (AF_AxisHintsRec): Use unsigned types. * src/autofit/afhints.c (af_axis_hints_new_{segment,edge}, af_glyph_hints_get_num_segments, af_glyph_hints_get_segment_offset): Updated accordingly. * src/autofit/aflatin.c (af_cjk_hints_compute_edges): Ditto. * src/autofit/afcjk.c (af_cjk_hints_compute_edges): Ditto.
Werner Lemberg d0cfb4e1 2022-01-11T10:54:10 Update all copyright notices.
Werner Lemberg 5aa2a5c3 2022-01-07T06:41:36 [autofit, pshinter] Use `FT_OFFSET`. This avoids ``` runtime error: applying zero offset to null pointer ``` warnings of clang's undefined behaviour sanitizer. * src/autofit/afcjk.c (af_cjk_hints_link_segments, af_cjk_hints_compute_edges, af_cjk_hints_compute_blue_edges, af_cjk_hint_edges, af_cjk_align_edge_points): Do it. * src/autofit/afhints.c (af_glyph_hints_align_edge_points, af_glyph_hints_align_strong_points): Ditto. * src/autofit/aflatin.c (af_latin_metrics_init_widths, af_latin_hints_link_segments, af_latin_hints_compute_edges, af_latin_hints_compute_blue_edges, af_latin_hint_edges): Ditto. * src/pshinter/pshalgo.c (psh_hint_table_init): Ditto.
Alexei Podtelezhnikov a81cf5aa 2021-09-02T22:10:57 Cosmetic zeros.
David Turner 2f11522a 2021-06-02T19:05:09 Remove experimental auto-hinting 'warp' mode. This feature was always experimental, and probably nevery worked properly. This patch completely removes it from the source code, except for a documentation block describing it for historical purpose.
Werner Lemberg 232243e7 2021-06-19T06:32:29 Prevent hinting if there are too many segments. This speeds up handling of broken glyphs. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35309 * src/autofit/aflatin.c (af_latin_hints_compute_segments): Implement it.
Werner Lemberg 7ca7da9d 2021-06-02T06:59:01 * src/autofit/aflatin.c (af_latin_metrics_scale_dim): Fix tracing. Problem reported by Alexei.
Werner Lemberg b6e8a712 2021-01-17T07:18:48 Update all copyright notices.
Werner Lemberg 272ae5ee 2020-12-07T10:29:24 * src/*: More fixes for using a '\n' in `FT_TRACE` and `FT_ERROR`.
Werner Lemberg a6adb256 2020-12-02T14:15:07 * src/*: Don't use more than one '\n' in `FT_TRACE` and `FT_ERROR`. This ensures good logging output, with all lines having a proper prefix (if requested).
Priyesh Kumar 53be1753 2020-07-28T07:33:40 Fix `-Wformat' compiler warnings. * src/*: Fix format specifiers. * builds/unix/ftsystem.c (FT_Stream_Open): Ditto.
Werner Lemberg 16586859 2020-06-13T21:15:45 Remove redundant inclusion of `ft2build.h'. * */*: Remove `#include <ft2build.h>' where possible. * include/freetype/freetype.h: Remove cpp error about missing inclusion of `ft2build.h'.
David Turner e1339133 2020-06-08T13:31:55 Make macros for header file names optional. We no longer have to take care of the 8.3 file name limit; this allows us (a) to introduce longer, meaningful file names, and (b) to avoid macro names in `#include' lines altogether since some compilers (most notably Visual C++) doesn't support this properly. */*: Replace #include FOO_H with #include <freetype/foo.h> or something similar. Also update the documentation.
Werner Lemberg e5038be7 2020-01-19T17:05:19 Update all copyright notices.
Werner Lemberg 2c9a2d58 2019-12-13T23:56:25 Another bunch of UBSan warnings on adding offsets to nullptr. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19427 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19433 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19441 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19451 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19452 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19457 * src/autofit/aflatin.c (af_latin_hints_compute_segments, af_latin_hints_compute_edges): Use `FT_OFFSET'. * src/base/ftstream.c (FT_Stream_EnterFrame): Use `FT_OFFSET'. * src/psaux/cffdecode.c (cff_decoder_parse_charstrings): Exit early if there is no charstring. * src/psaux/psobjs.c (t1_decrypt): Use `FT_OFFSET'. * src/smooth/ftsmooth.c (ft_smooth_render_generic): Exit early for zero bitmap dimensions.
Werner Lemberg 47ca5cb6 2019-06-16T15:32:11 [autofit] Disable hinting if no blue zones are available (#56450). * src/autofit/afglobal.c (af_face_global_get_metrics): Start again (with dummy hinter module) if no blue zones are present. * src/autofit/aflatin.c (af_latin_metrics_init_blues): Change signature to return error code. If no blue zones are found, update `glyph_styles' array to hold AF_STYLE_NONE_DFLT instead of the current style. (af_latin_metrics_init): Return internal error code if no blue zones are found.
Werner Lemberg 3736b28a 2019-06-13T13:45:05 * src/autofit/aflatin.c (af_latin_metrics_init_widths): Minor.
Werner Lemberg f0384d5f 2019-04-09T11:01:24 Minor.
Werner Lemberg 75859970 2019-02-23T10:07:09 Update all copyright notices.
Werner Lemberg f686ad46 2019-01-22T20:31:44 Update copyright years.
Werner Lemberg a9af6914 2018-09-25T09:10:09 Fix handing of `FT_Bool'. Before this commit we had code like (FT_Bool)( globals->glyph_styles[gindex] & 0x8000) Since `FT_Bool' is defined to be an `unsigned char', the code evaluated to something like (unsigned char)( 0x8532 & 0x8000) which in turn expanded to (unsigned char)( 0x8000) and finally yielded 0x00 – i.e., false – not as expected. Problem reported and analyzed by Tony Smith <tony.smith@macro4.com>. * include/freetype/fttypes.h (FT_BOOL): Add a comparison against zero so that we always have a Boolean expression. */*: Replace castings to `FT_Bool' with calls to `FT_BOOL' where possible.
Werner Lemberg a0dd16fb 2018-08-15T18:13:17 Don't use `trace_' prefix for FT_COMPONENT arguments. * include/freetype/internal/ftdebug.h (FT_TRACE_COMP, FT_TRACE_COMP_): New auxiliary macros to add `trace_' prefix. (FT_TRACE): Use `FT_TRACE_COMP'. */* (FT_COMPONENT): Updated.
Werner Lemberg 9ac9060d 2018-06-03T09:01:17 [GSoC] src/*.*: Convert block comments to `light' style. This monster commit was created by applying Nikhil's scripts `docconverter.py' and `markify.py' to all C header and source files, followed up by minor manual clean-up. No change in functionality, of course. I used commit f7419907bc6044b9b7057f9789866426c804ba82 from https://github.com/nikramakrishnan/freetype-docs.git.
Werner Lemberg e0015f76 2018-05-08T11:51:16 [autofit] Avoid potential SEGV if running out of memory. Problem reported by Shailesh Mistry <shailesh.mistry@hotmail.co.uk>. * src/autofit/afshaper.c (af_shaper_buf_create, af_shaper_buf_destroy) [!FT_CONFIG_OPTION_USE_HARFBUZZ]: Don't allocate and free a four-byte buffer. Instead, make those functions no-ops; the calling functions will provide a pointer to a buffer instead. * src/autofit/afcjk.c (af_cjk_metrics_init_widths, af_cjk_metrics_init_blues, af_cjk_metrics_check_digits), src/autofit/aflatin.c (af_latin_metrics_init_widths, af_latin_metrics_init_blues, af_latin_metrics_check_digits) [!FT_CONFIG_OPTION_USE_HARFBUZZ]: Use pointer to local variable for `shaper_buf'.
Werner Lemberg 95149592 2018-05-02T20:27:48 Remove FT_CONFIG_OPTION_PIC and related code. */* [FT_CONFIG_OPTION_PIC]: Remove all code guarded by this preprocessor symbol. */*: Replace `XXX_GET' macros (which could be either a function in PIC mode or an array in non-PIC mode) with `xxx' arrays. * include/freetype/internal/ftpic.h, src/autofit/afpic.c, src/autofit/afpic.h, src/base/basepic.c, src/base/basepic.h, src/base/ftpic.c, src/cff/cffpic.c, src/cff/cffpic.h, src/pshinter/pshpic.c, src/pshinter/pshpic.h, src/psnames/pspic.c, src/psnames/pspic.h, src/raster/rastpic.c, src/raster/rastpic.h, src/sfnt/sfntpic.c, src/sfnt/sfntpic.h, src/smooth/ftspic.c, src/smooth/ftspic.h, src/truetype/ttpic.c, src/truetype/ttpic.h: Removed.
Werner Lemberg 0a0c2256 2018-01-02T09:33:57 Update copyright year.
Werner Lemberg 96dcc8ad 2017-09-13T08:16:23 [autofit] Really fix #41334 (#52000). * src/autofit/aflatin.c (af_latin_hints_compute_segments): Set `segment->delta' everywhere.
Alexei Podtelezhnikov a7f276a2 2017-05-15T00:25:37 [autofit] Make autohint warping NORMAL option. This moves warping option from LIGHT to NORMAL mode. This makes LIGHT truly void of hinting in x-direction, with left side bearing never changed and right side bearing only altered by advance rounding. Therefore, LIGHT is now ready to return fractional advance. As a NORMAL option, warping substitutes normal hinting. * src/autofit/afcjk.c (af_cjk_hints_apply): Updated. * src/autofit/aflatin.c (af_latin_hints_apply): Updated. * src/autofit/aflatin2.c (af_latin2_hints_apply): Updated. * src/autofit/afloader.c (af_loader_load_glyph): Handle warping phantom points as normal.
Werner Lemberg ba40054c 2017-05-02T12:32:19 [autofit] Remove `slight' auto-hint mode again. A poll on freetype-devel favoured changes directly applied to `light'. * include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT, FT_RENDER_MODE_SLIGHT): Removed. * src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c (af_latin_hints_init), src/autofit/aflatin2.c (af_latin2_hints_init): Revert change from 2017-04-22. * src/autofit/afloader.c (af_loader_load_glyph) Remove references to FT_RENDER_MODE_SLIGHT. [AF_CONFIG_OPTION_TT_SIZE_METRICS]: Enable TrueType-like metrics unconditionally. * src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Revert change from 2017-04-22. * src/base/ftobjs.c (FT_Load_Glyph): Revert change from 2017-04-22. * src/pshinter/pshalgo.c (ps_hints_apply): Revert change from 2017-04-22. * src/smooth/ftsmooth.c (ft_smooth_render): Revert change from 2017-04-22. * docs/CHANGES: Updated.
Werner Lemberg 5aa6716a 2017-04-22T13:27:21 Add new `slight' auto-hinting mode. This mode uses fractional advance widths and doesn't scale glyphs horizontally, only applying vertical scaling and hinting. At the same time, the behaviour of the `light' auto-hinter gets restored for backwards compatibility: Both vertical and horizontal scaling is again based on rounded metrics values (this was changed in a commit from 2017-03-30 as a side effect). To be more precise, the behaviour is restored for TrueType fonts only; for other font formats like Type 1, this is a new feature of the `light' hinting mode. * include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT): New macro. (FT_RENDER_MODE_SLIGHT): New render mode. * include/freetype/internal/ftobjs.h (FT_Size_InternalRec): Add `autohint_mode' and `autohint_metrics' fields. * src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c (af_latin_hints_init), src/autofit/aflatin2 (af_latin2_hints_init): Updated. * src/autofit/afloader.c (af_loader_embolden_glyph_in_slot): Use `autohint_metrics'. (af_loader_load_glyph): s/internal/slot_internal/. Initialize `autohint_metrics' and `autohint_mode' depending on current auto-hint mode. Use `autohint_metrics'. Updated. * src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Updated. * src/base/ftobjs.c (FT_Load_Glyph): Updated. (FT_New_Size): Allocate `internal' object. * src/pshinter/pshalgo.c (ps_hints_apply): Updated. * src/smooth/ftsmooth.c (ft_smooth_render): Updated.
Alexei Podtelezhnikov e7b01304 2017-04-02T22:01:47 [autofit] Disable metrics adjustment for `FT_LOAD_TARGET_LCD'. * src/autofit/aflatin.c (af_latin_hints_init): Updated. * src/autofit/aflatin2.c (af_latin2_hints_init): Ditto.
Alexei Podtelezhnikov 54b58097 2017-03-31T22:41:53 [autofit] Disable stem adjustment for `FT_LOAD_TARGET_LCD'. * include/freetype/freetype.h (FT_LOAD_TARGET_LCD): Document it. * src/autofit/afcjk.c (af_cjk_hints_init): Updated. * src/autofit/aflatin.c (af_latin_hints_init): Ditto. * src/autofit/aflatin2.c (af_latin2_hints_init): Ditto.
Werner Lemberg 467b026c 2017-02-18T10:42:48 Remove clang warnings. * src/autofit/aflatin.c (af_latin_sort_blue): Add missing `static' keyword. * src/base/ftmm.c (FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates): Initialize some variables.
Werner Lemberg 319125d4 2017-02-13T09:34:17 [autofit] Prevent overlapping blue zones. Problem reported as https://github.com/google/fonts/issues/632 The font in question (Nunito) has values 705 and 713 for the reference and overshoot values, respectively, of the first blue zone. Blue zone 2, however, has value 710 for both the reference and overshoot. At 12ppem, reference and overshoot of blue zone 0 becomes 8px, while blue zone 2 becomes 9px. A peculiarity of this font is that the tops of isolated vertical stems like `N' have a slight overshoot also. The auto-hinter tries to find the nearest blue zone using the *original* coordinates. For vertical stems, this is value 713. For normal horizontal tops like in character `E', this is value 710. Since value 713 is mapped to 8px but value 710 to 9px, `N' and similar characters are one pixel higher than `E', which looks very bad. This commit sanitizes blue zones to avoid such a behaviour. * src/autofit/aflatin.c (af_latin_sort_blue): New function. (af_latin_metrics_init_blues): Sort blue values and remove overlaps.