src/sfnt


Log

Author Commit Date CI Message
Dominik Röttsches 286da6c5 2021-06-22T15:01:19 [sfnt] Support PaintScale in 'COLR' v1 parsing. * include/freetype/ftcolor.h (FT_PaintFormat): Renumber values, add `FT_COLR_PAINTFORMAT_SCALE`. (FT_PaintScale): New structure to represent 'PaintScale*' tables. (FT_COLR_Paint): Updated. * src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration. (read_paint): Parse 'PaintScale' and friends.
Dominik Röttsches 0348c627 2021-06-29T20:51:32 [sfnt] Handle fonts without layer list in 'COLR' v1. 'COLR' v1 fonts do not necessarily need to have a layer list; for this reason, 'fontTools' recently started generating fonts in a way that drops the layer list if there are no layers in it. This results in the layer list offset becoming zero, which FreeType treated as an invalid table. Fix that and handle the case for layer list offset being 0. This slightly changes how we need to calculate the starting offset for paints. * src/sfnt/ttcolr.c (tt_face_load_colr): Handle case of layer list offset being zero without outright rejecting table.
Dominik Röttsches 7d4e55c3 2021-06-28T16:29:49 [sfnt] Improve paint limit checks Paint tables can appear before the `base_glyphs_v1` offset if the font is produced with the layer list before the base glyph list. In this case paint tables can occur after the layer list but before the base glyph list. Checks in the 'COLR' v1 code were rejecting fonts with this layout. Improve these checks by calculating a minimum offset after which paint tables can occur and use that in safety checks. * src/sfnt/ttcolr.c (Colr, tt_face_load_colr): Declare `paint_start_v1` and calculate that as the minimum of the end of layer list and base glyph list. (get_child_table_pointer, read_paint, tt_face_get_paint_layers): Use that in safety checks.
Dominik Röttsches 4cb21b9a 2021-06-22T20:50:48 [sfnt] s/PaintTransformed/PaintTransform/, s/transformed/transform/. * include/freetype/ftcolor.h (FT_PaintTransformed, FT_PaintFormat, FT_COLR_Paint): Do it to make it harmonize with other names such as 'PaintTranslate'. * src/sfnt/ttcolr.c (read_paint, tt_face_get_paint): Ditto.
Werner Lemberg 08f66322 2021-06-08T18:23:16 More various documentation improvements and fixes.
Werner Lemberg b24cfc8d 2021-06-08T15:26:41 [sfnt] Sanitize cmap4 table better. Fixes #1062. * src/sfnt/ttcmap.c (tt_cmap4_validate): Handle a too-small value of `length` gracefully.
Dominik Röttsches ee6d03d3 2021-06-08T14:29:11 [sfnt] Pointer validity check when reading COLR 'v1' layers * src/sfnt/ttcolr.c (tt_face_get_paint_layers): In addition to the existing sanity checks, ensure that the pointer to the layer to be read is within the 'COLR' v1 table.
Ben Wagner 2a6665a4 2021-06-01T15:25:31 [sfnt] Fix fallout from 2021-05-29 change. * src/sfnt/ttcolr.c (find_base_glyph_record, find_base_glyph_v1_record): Adjust binary search. Needs to be updated with change to unsigned.
Werner Lemberg a50c39aa 2021-05-29T09:50:29 Fix compilation errors and (some) warnings for clang++. * src/autofit/afmodule.c (AF_GlyphHintsRec): Make it static. * src/cache/ftcache.c (FTC_Cache_NewNode), src/cache/ftcsbits.c (ftc_snode_compare): Remove semicolon. * src/cff/cffparse.c (cff_parser_run): Add `break` statement. * src/cid/cidload.c (cid_hex_to_binary): Add cast. * src/sdf/ftbsdf.c (CHECK_NEIGHBOR): Use `do {} while(0)` loop. (bsdf_init_distance_map, finalize_sdf, bsdf_raster_render): Add casts. * src/sdf/ftsdf.c (sdf_generate_bounding_box, sdf_generate_with_overlaps): Ditto. * src/sdf/ftsdfcommon.h (square_root): Ditto. * src/sdf/ftsdfrend.c (sdf_property_get, ft_sdf_render, ft_bsdf_render): Ditto. * src/sfnt/ttcolr.c (find_base_glyph_record, find_base_glyph_v1_record): Fix variable signedness. (read_color_line): Add cast. (read_paint): Add casts. Fix signedness issue. (tt_face_get_colorline_stops) Fix signedness issues. * src/sfnt/ttpost.c (load_format_20): Add casts. * src/truetype/ttsubpix.c (TWEAK_RULES, TWEAK_RULES_EXCEPTIONS): Remove final semicolons.
Alexei Podtelezhnikov 1bc801b0 2021-05-16T23:12:01 [sfnt] Additional guards on the POST table. Fixes timeout (#1055) analyzed by Ben Wagner, reported as https://crbug.com/1194092 * src/sfnt/ttload.c (tt_face_load_post): Check POST format. * src/sfnt/sfobjs.c (sfnt_load_face): Synthesize the missing unicode charmap only if the glyph names exist. * src/psnames/psmodule.c (ps_unicode_value): Short cut ".notdef" and ".null".
Alexei Podtelezhnikov 44c59414 2021-05-06T22:54:03 * src/sfnt/sfobjs.c (sfnt_load_face): Tweak allocation macro.
Alexei Podtelezhnikov 66630d88 2021-05-03T22:40:16 [sfnt] Streamline POST format 2.0 handing. To reduce memory allocations, we read an entire Pascal-string buffer and convert it to a C-string buffer. We also reject tables with Postscript glyph names exceeding 63 bytes. * src/sfnt/ttpost.c (load_format20): Implement it. (load_post_names): Check the minimal POST table size. (load_format25, tt_face_free_ps_names): Updated accordingly.
Alexei Podtelezhnikov dc42f826 2021-05-01T12:46:44 [sfnt] Avoid some memory zeroing. * src/sfnt/sfobjs.c (sfnt_open_font, sfnt_init_face, tt_name_ascii_from_{utf16,other}): Tweak allocaton macros. * src/sfnt/ttload.c (tt_face_load_name): Ditto.
Alexei Podtelezhnikov b8968d66 2021-05-01T12:24:44 * src/sfnt/ttpost.c (load_format_{20,25}): Tweak allocaton macros.
Alexei Podtelezhnikov 2583b608 2021-05-01T09:22:26 * src/sfnt/pngshim.c (Load_SBit_Png): Tweak allocaton macro.
Alexei Podtelezhnikov c177cc35 2021-05-01T09:09:52 [woff2] Avoid some memory zeroing. * src/sfnt/sfwoff2.c (store_loca, woff2_open_font): Tweak macros.
Alexei Podtelezhnikov caff87b1 2021-04-26T22:45:40 * src/sfnt/sfobjs.c (sfnt_init_face): Revert macro change.
Alexei Podtelezhnikov 6ada59ab 2021-04-23T19:22:51 [sfnt] s/FT_ALLOC/FT_QALLOC/ for initialized buffers. * src/sfnt/sfdriver.c (get_win_string, get_apple_string, sfnt_get_var_ps_name): Do not zero out the buffer. * src/sfnt/sfobjs.c (sfnt_init_face): Ditto. * src/sfnt/sfwoff.c (woff_open_font): Ditto. * src/sfnt/sfwoff2.c (woff2_open_font): Ditto.
Dominik Röttsches e662a950 2021-04-19T12:49:16 [sfnt] Return in 'COLR' v1 when layer pointer outside table * src/sfnt/ttcolr.c (tt_face_get_paint_layers): Add missing return when paint pointer outside table. (read_paint): Add missing return when paint pointer outside table.
Dominik Röttsches 7f8a1edd 2021-04-16T12:35:29 [sfnt] Safeguard 'COLR' v1 layer extraction * src/sfnt/ttcolr.c (tt_face_get_paint_layers): Do not output layer pointer to iterator if it is outside the 'COLR' table. (read_paint): Do not attempt to read layers that are outside the table.
Dominik Röttsches 1c086293 2021-04-02T06:55:29 [sfnt] Check validity of pointer location of `read_color_line`. * src/sfnt/ttcolr.c (get_child_table_pointer): New function to fetch child table pointer early for all paint formats that compute a child table pointer. (read_color_line, read_paint): Updated. (tt_face_get_colorline_stops): Check `colr->table`.
Alexei Podtelezhnikov e9c50fa7 2021-03-16T22:12:41 * src/sfnt/pngshim.c (Load_SBit_Png): Free `rows` once later.
Ben Wagner b0729b8f 2021-03-15T14:32:24 [sfnt] Fix memory leak in png loading. Reported as https://bugs.chromium.org/p/chromium/issues/detail?id=1182552 Memory is allocated and the pointer assigned to `rows` inside a 'setjmp' scope. This memory must be freed outside the 'setjmp' scope after a 'longjmp'. Since `rows` is a local and modified inside the 'setjmp' scope it must be marked volatile or it will have an indeterminate value after the 'longjmp'. * src/sfnt/pngshim.c (Load_SBit_Png): Fix memory leak of `rows`.
Werner Lemberg 2149b51f 2021-03-13T19:08:09 Handle various VC++ compiler warnings. Fixes #1039. * src/base/ftstroke.c (ft_stroker_inside, ft_stroker_outside): Initialize `sigma`. * src/sdf/ftsdf.c (sdf_generate_with_overlaps): Exit immediately if function arguments are invalid. * src/sdf/ftsdfrend.c (sdf_property_set) <"overlaps">: Fix cast. * src/sfnt/sfwoff2.c (woff2_decompress) [!FT_CONFIG_OPTION_USE_BROTLI]: Use `FT_UNUSED`. * src/truetype/ttgxvar.c (TT_Get_MM_Var): Initialize `fvar_head`.
Werner Lemberg 7227aabb 2021-03-04T06:41:30 Revert "[sfnt] Fix crash in `Load_SBit_Png` on Windows x64." This reverts commit dbf9142f7e0432c9ed618b3276e2b61fa39e7262, as discussed in #1037.
Jesse Towner dbf9142f 2021-02-25T15:07:25 [sfnt] Fix crash in `Load_SBit_Png` on Windows x64. This change fixes a crash that occurs in `Load_SBit_Png` when running on a 64-bit Windows OS. A memory access violation exception would be raised by `setjmp` if the `jmp_buf` is not aligned to a 16-byte memory boundary. This is due to setjmp executing `movdqa` instructions to store 128-bit XMM registers to memory, which require correct memory alignment. This problem occurs because `png_create_read_struct` uses `malloc` and `free` for memory management, which only guarantees 8-byte alignment on Windows. Instead, to fix the problem, `png_create_read_struct_2` is used on 64-bit Windows, which allows for user-defined memory allocation and deallocation callbacks to be specified. These callbacks forward the allocation and deallocation requests to `_aligned_alloc` and `_aligned_free`, ensuring that the allocated `png_struct` and internal `jmp_buf` have the requisite 16-byte alignment. * src/sfnt/pngshim.c <_WIN64>: Include `malloc.h`. (malloc_callback, free_callback) <_WIN64>: New functions. (Load_SBit_Png) <_WIN64>: Use `png_create_read_struct_2` instead of `png_create_read_struct`
Werner Lemberg e1f364e5 2021-02-25T20:00:07 [woff2] Fix memory leak. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28148 * src/sfnt/sfwoff2.c (woff2_open_font): Reject fonts that have multiple tables with the same tag. While not explicitly forbidden in the OpenType specification, it is implicitly forbidden by describing a binary search algorithm for tables that only works reliably if table tags are unique.
Dominik Röttsches 215ae253 2021-02-16T12:53:45 [sfnt] Update paint format values to support non-variable paints. * freetype.h (FT_PaintFormat): Update paint format identifiers after a specification change. The specification was updated to have sibling formats, variable and non-variable variants for each. Reflect that here. * sfnt/ttcolr.c (read_paint): Remove parsing of variable indices as the non-variable formats no longer have them.
Alexei Podtelezhnikov 70fd20e6 2021-02-12T19:28:05 Decorate qsort callbacks with cdecl. * include/freetype/internal/compiler-macros.h (FT_COMPARE_DEF): Add new macro. * src/base/ftrfork.c, src/bdf/bdflib.c, src/gxvalid/gxvcommn.c, src/psaux/afmparse.c, src/psnames/psmodule.c, src/type1/t1afm.c, src/sfnt/sfwoff.c, src/sfnt/sfwoff2.c: Update qsort callbacks. Fixes #1026 when compiling FreeType with an unusual calling convention while the C library qsort still expects cdecl.
Dominik Röttsches 54c5ad5c 2021-02-10T19:24:13 [sfnt] Implement 'COLR' v1 sweep gradients. * freetype.h (FT_PaintSweepGradient): Add `FT_PaintSweepGradient` to represent a 'COLR' v1 sweep gradient. Update format. (FT_PaintFormat): Update shifted paint formats. Sync with spec. * sfnt/ttcolr.c (read_paint): Logic to parse sweep gradients. Fix struct access in radial gradient implementation.
Dominik Röttsches 64f01bfe 2021-01-20T13:04:50 [sfnt] Provide optional root transform for 'COLR' v1 glyph graph. * include/freetype/freetype.h (FT_Get_Color_Glyph_Paint): Additional function argument root_transform to control whether root transform should be returned. (FT_OpaquePaint): Additional tracking field to denote whether root transform is to be returned. * include/freetype/internal/sfnt.h (TT_Get_Color_Glyph_Paint_Func): Propagate additional argument. * src/base/ftobjs.c (FT_Get_Color_Glyph_Paint): Ditto. * src/sfnt/ttcolr.c (tt_face_get_colr_glyph_paint): Return root transform reflecting the size and tranform configured on FT_Face. (read_paint): Initialize and track status of insert_root_transform flag.
Werner Lemberg d924a66a 2021-02-04T07:44:06 * 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). This is a continuation of a similar patch from 2020-12-02, which missed some locations.
Werner Lemberg b6e8a712 2021-01-17T07:18:48 Update all copyright notices.
Werner Lemberg ba1a6acf 2021-01-15T10:09:00 [sfnt] Additional checks for 'colr' table presence. * sfnt/ttcolr.c (tt_face_get_colr_glyph_paint, tt_face_get_colorline_stops, tt_face_get_paint): Additional checks for whether colr table is present. Prevents crashes when these methods are called on non-COLR fonts.
Dominik Röttsches d3e95d97 2020-12-16T17:12:30 [sfnt] Register 'COLR' v1 API in driver (#59703). * include/freetype/internal/sfnt.h (TT_Get_Color_Glyph_Paint_Func, TT_Get_Paint_Layers_Func, TT_Get_Colorline_Stops_Func, TT_Get_Paint_Func): New function pointer types. (SFNT_Interface): Add them. (FT_DEFINE_SFNT_INTERFACE): Updated. * src/sfnt/sfdriver.c (PUT_COLOR_LAYERS_V1): New macro. (sfnt_interface): Add new function pointers.
Dominik Röttsches 6260b490 2020-12-16T17:06:42 [sfnt] Add 'COLR' v1 API to retrieve color layers (#59703). * src/sfnt/ttcolr.c (tt_face_get_paint_layers): New function to get the layers of a `PaintColrLayers` table in the font, using an `FT_LayerIterator` from an `FT_PaintColrLayers` object retrieved via `tt_face_get_paint`. * src/sfnt/ttcolr.h: Updated.
Dominik Röttsches be06a9d0 2020-12-16T17:02:22 [sfnt] Add 'COLR' v1 API to iterate color stops (#59703). * src/sfnt/ttcolr.c (tt_face_get_colorline_stops): New function to return the current `FT_ColorStop` object from `FT_ColorStopIterator`. Also increment the iterator. * src/sfnt/ttcolr.h: Updated.
Dominik Röttsches cdad4db4 2020-12-16T16:52:24 [sfnt] Add API to get actual paint from `FT_OpaquePaint` (#59703). * src/sfnt/ttcolr.c (tt_face_get_paint): New function to resolve an `FT_OpaquePaint` paint reference into an `FT_COLR_Paint` object of a certain format, which contains the detailed information stored in a paint of the respective format. (read_paint): New function to provide the format specific parsing and to populate the data members of each specific `FT_COLR_Paint` subtype. (read_color_line): New function to parse retrieved color line information into an `FT_ColorLine` object, which has information about the color line extend mode as well as an `FT_ColorStopIterator` object. * src/sfnt/ttcolr.h: Updated.
Dominik Röttsches 9e422b67 2020-12-16T16:44:34 [sfnt] Add API to retrieve 'COLR' v1 root paint (#59703). * src/sfnt/ttcolr.c (BaseGlyphV1Record): New structure. (tt_face_load_colr): Handle version 1 table header. (find_base_glyph_v1_record): New auxiliary function. (tt_face_get_colr_glyph_paint): New function to find the root `FT_OpaquePaint` object for a given glyph ID. * src/sfnt/ttcolr.h: Updated.
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).
Ben Wagner 007c109b 2020-10-23T08:29:14 * src/sfnt/pngshim.c (Load_SBit_Png): Fix memory leak (#59322). The issue is that `rows` is allocated but will not be freed in the event that the call to `png_read_image` fails and calls `longjmp`.
Werner Lemberg a3bab162 2020-10-19T23:45:28 [sfnt] Fix heap buffer overflow (#59308). This is CVE-2020-15999. * src/sfnt/pngshim.c (Load_SBit_Png): Test bitmap size earlier.
Alexei Podtelezhnikov 840ce58f 2020-10-18T07:36:57 * src/sfnt/tt{colr,cpal}.c: Fix signedness warnings from VC++.
Alexei Podtelezhnikov a93f50b6 2020-10-17T21:58:50 * src/sfnt/sfwoff2.c (Read255UShort): Tweak types to please VC++.
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 8cfc41ae 2020-07-25T12:23:22 Fix `-Wformat' compiler warnings. Problem reported by Priyesh kumar <priyeshkkumar@gmail.com> * src/base/ftoutln.c (FT_Outline_Decompose): Fix number of arguments to tracing macro. * src/bdf/bdfdrivr.c (bdf_cmap_char_next, bdf_get_bdf_property): Ditto. * src/cache/ftcbasic.c (ftc_basic_family_get_count): Ditto. Reformulate message. * src/pcf/pcfdrivr.c (pcf_get_bdf_property): Ditto. * src/sfnt/sfwoff2.c (woff2_open_font): Ditto. Trace table offset, too. * src/truetype/ttgxvar.c (ft_var_apply_tuple): Ditto.
Werner Lemberg b6183ea3 2020-07-23T13:03:22 * src/sfnt/sfwoff2.c (woff2_decompress): Fix compiler warning. Reported by Hin-Tak.
Werner Lemberg 96fb73ef 2020-07-07T16:58:14 Fix clang warnings. * include/freetype/internal/autohint.h (FT_DECLARE_AUTOHINTER_INTERFACE): New macro. * src/autofit/afmodule.h: Use it to declare `af_autofitter_interface'. * include/freetype/internal/ftobjs.h (FT_DECLARE_GLYPH): New macro. * src/base/ftbase.h: Use it to declare `ft_bitmap_glyph_class' and `ft_outline_glyph_class'. * src/base/ftglyph.c: Include `ftbase.h'. * src/cff/cffparse.c (cff_parser_run): Fix type of `t2_size'. * src/pcf/pcfdrivr.c (pcf_cmap_char_next): Fix type of `result'. * src/psaux/psauxmod.c (psaux_module_class): Use `FT_DEFINE_MODULE'. * src/psaux/psauxmod.h: Declare `afm_parser_funcs', `t1_cmap_classes', `cff_decoder_funcs', and `psaux_module_class'. * src/pshinter/pshmod.c: Include `pshmod.h'. * src/sfnt/sfwoff2.c (ROUND4, WRITE_SHORT): Fix implicit sign conversion. (compute_ULong_sum): Fix return type. Fix implicit sign conversion. (store_points): Fix type of `last_flag', `repeat_count', and `flag'. Use casts to avoid warnings. (reconstruct_glyf): Fix implicit sign conversion. Use cast to avoid warning. (get_x_mins): Fix implicit sign conversion. * src/sfnt/ttcmap.c: Undef `TTCMAPCITEM'. * src/sfnt/ttcmap.h: Define `TTCMAPCITEM' and include `ttcmapc.h' to declare cmap classes. * src/smooth/ftsmooth.c (ft_smooth_overlap_spans): Use cast. * src/truetype/ttinterp.c (Ins_MIAP): Fix typo.
David Turner cb4a943b 2020-07-06T10:56:36 [build] Fix multi and C++ builds. The following builds were failing due to previous changes: make multi make multi CC="c++" * include/freetype/config/ftconfig.h: Remove `FT_END_HEADER'. * include/freetype/config/ftheader.h (FT_BEGIN_HEADER, FT_END_HEADER): Protect against redefinition. * src/cache/ftccache.h, src/cache/ftcmru.h, src/pcf/pcfutil.h, src/psaux/pserror.h, src/psaux/psft.h, src/psaux/psstack.h, src/sfnt/woff2tags.h: Include `compiler-macros.h'. * src/sfnt/woff2tags.c: Include `woff2tags.h'.
Werner Lemberg 4d364b68 2020-06-19T05:41:37 [woff2] Fix segfault. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23402 * src/sfnt/sfwoff2.c (get_x_mins): Check whether `loca' table exists.
Stephen McDowell d924c5cf 2020-06-19T04:14:39 [sfnt] Support Intel compilers. * src/sfnt/pngshim.c (premultiply_data): Intel compilers do not currently support `__builtin_shuffle'.
Werner Lemberg 7438235b 2020-06-17T15:12:30 woff2tags.h: Fix copyright year.
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 9e6e903c 2020-06-02T17:14:54 * src/sfnt/ttcmap.c (tt_face_build_cmaps): Trace number of cmaps.
David Turner 4eee1340 2020-05-18T09:16:12 Remove Jamfile files from the tree. These have not been used in a very, very long time, so better remove them. A corresponding patch will be submitted to the `freetype2-demos' repository. * src/Jamfile, src/*/Jamfile, Jamrules: Delete.
Nikhil Ramakrishnan 7a019a63 2020-04-04T14:06:37 [woff2] Return if single stream operation fails. * src/sfnt/sfwoff2.c (get_x_mins): Do it. * src/sfnt/woff2tags.c: Remove unused include.
Werner Lemberg fa147af4 2020-02-22T18:30:46 [woff2] Fix font table access. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20778 * src/sfnt/sfwoff2.c (get_x_mins): Explicitly check for presence of `head' table, which might not have been processed yet.
Werner Lemberg 8930cc96 2020-02-12T18:25:03 * src/sfnt/ttcmap.c (tt_face_build_cmaps): Ignore version (#57708).
Werner Lemberg e5038be7 2020-01-19T17:05:19 Update all copyright notices.
Werner Lemberg a99a8e28 2020-01-03T18:09:12 [woff2] Fix memory leaks and a runtime warning. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19773 * src/sfnt/sfwoff2.c (compute_ULong_sum): Add missing cast. (reconstruct_hmtx): Add missing deallocation calls.
Nikhil Ramakrishnan a4df0373 2019-12-31T16:04:01 [woff2] Allow bitmap-only fonts (#57394). * src/sfnt/sfwoff2.c (reconstruct_font): Fix test for `glyf' and `loca' tables.
Dominik Röttsches 4270e9f3 2019-11-27T11:38:45 Avoid more nullptr offset UBSan warnings (#57316). * src/base/ftoutln.c (FT_Outline_Transform): Bail on empty points. * src/cff/cffload.c (cff_subfont_load): Use `FT_OFFSET'. * src/psaux/psft.c (cf2_decoder_parse_substrings): Early out if `charstring_base' or `charstring_len' are null. * src/sfnt/ttload.c (tt_face_load_name): Use `FT_OFFSET'.
Ben Wagner 3cb7b3f7 2019-11-23T10:54:51 [sfnt] Avoid sanitizer warning (#57286). * src/sfnt/ttcmap.c (tt_face_build_cmaps): Avoid possible `NULL + offset' computation. Tag `table' as `const'.
Ben Wagner 9b017959 2019-11-23T10:07:48 [sfnt] Ensure OTTO fonts have tables (#57285). * src/sfnt/ttload.c (tt_face_load_font_dir): Add test.
Werner Lemberg b75031a2 2019-10-25T21:29:13 * src/sfnt/sfwoff2.c (woff2_open_font): Check `num_fonts' for TTCs. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18494
Werner Lemberg 3b8bc65c 2019-10-22T08:07:05 * src/sfnt/sfwoff2.c (woff2_open_font): Avoid undefined shift. Also improve tracing. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18390
Alexei Podtelezhnikov 90a30f15 2019-10-10T22:04:50 * src/sfnt/pngshim.c (premultiply_data): Optimize for __SSE__ only.
Werner Lemberg 545a481a 2019-10-10T13:11:06 * src/sfnt/sfwoff2.c (reconstruct_glyf): Check `triplet_size'. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18108
Werner Lemberg 5a1a79c0 2019-10-08T11:12:18 [woff2] Fix SFNT table checks. Also reduce number of SFNT table lookups. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18065 * include/freetype/internal/wofftypes.h (WOFF2_InfoRec): Add fields `glyf_table', `loca_table', and `head_table'. * src/sfnt/sfwoff2.c (reconstruct_glyf): Update signature. Use table pointers in `info' parameter. (get_x_mins): Check `maxp_table' Use table pointers in `info' parameter. (reconstruct_font): Use and set table pointers in `info' parameter. Fix check for `glyf' and `loca' tables. Update call to `reconstruct_glyf'. (woff2_open_font): Updated.
Werner Lemberg 1167bff3 2019-10-06T23:22:34 * src/sfnt/sfwoff2 (reconstruct_glyf): Fix reallocation. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18046
Werner Lemberg 1f4e5bcb 2019-10-03T21:07:16 * src/sfnt/sfwoff2 (reconstruct_font): Fix reallocation. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17966
Werner Lemberg 94815d6e 2019-10-01T00:15:25 * src/sfnt/sfwoff2 (woff2_open_font): Initialize `woff2.ttc_fonts'. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17804
Werner Lemberg 839a0236 2019-09-30T07:41:57 * src/sfnt/sfwoff2.c (reconstruct_font): Fix memory leak. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17812
Werner Lemberg 12696dcf 2019-09-30T07:27:55 [woff2] Reject fonts without `head' table. Also fix memory deallocation in case of error. `head' problem reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17820 * src/sfnt/sfwoff2.c (reconstruct_glyf): Don't use `stream_close'. Abort if `head_table' is NULL. Don't free `transformed_buf' in case of error. (woff2_open_font): Don't set `uncompressed_buf' to NULL.
Werner Lemberg ba06adaf 2019-09-29T13:29:21 [woff2] Fix compiler warnings. Problem reported by Alexei. * src/sfnt/sfwoff2.c (reconstruct_glyf): Initialize `x_min'. (reconstruct_font): Initialize `num_hmetrics'. (woff2_open_font): Initialize `info'.
Werner Lemberg c37a5014 2019-09-28T07:42:34 * src/sfnt/sfwoff2.c (woff2_open_font): Fix sanity check. Correct thinkos in patch from 2019-09-01.
Werner Lemberg 2bf603bd 2019-09-28T07:37:24 [woff2] Fix memory leaks. One of them reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17766 * src/sfnt/sfwoff2.c (woff2_open_font): Free `info->x_mins' and `woff2->ttc_fonts'. (reconstruct_glyf): Initialize `info->x_mins'.
Werner Lemberg db4083fd 2019-09-25T08:48:26 * src/sfnt/sfwoff2.c (woff2_open_font): Check (sum of) table sizes. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17684
Nikhil Ramakrishnan 5327092b 2019-09-20T06:30:28 [woff2] Fix memory leaks. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16896 * src/sfnt/sfwoff2.c (woff2_open_font): Fix error handling. Free `uncompressed_buf'. (reconstruct_font): Free `transformed_buf'.
Werner Lemberg 99f23d6f 2019-09-17T13:22:28 * src/sfnt/sfwoff2.c (woff2_open_font): Check table index. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17100
Werner Lemberg 3fa35aa4 2019-09-03T21:10:20 * src/sfnt/sfwoff2.c (compute_ULong_sum): Fix undefined shift. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16933
Werner Lemberg 543a3b93 2019-09-01T23:03:09 * src/sfnt/sfwoff2.c (woff2_open_font): Add sanity check. Don't trust `totalSfntSize' unconditionally. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16893
Dominik Röttsches cbee985a 2019-08-27T15:08:15 [woff2] Don't use `FT_UInt64' (#56815). * src/sfnt/sfwoff2.c (woff2_open_font): Use `FT_UInt32' for `file_offset'. This fixes builds on platforms where `FT_LONG64' is not defined while still being sufficient to store a file offset.
Werner Lemberg eef5c1dd 2019-08-27T10:43:32 [woff2] Fix compiler warnings. * src/sfnt/sfwoff2.c (read_num_hmetrics): Remove unused argument `table_len'. Update caller. (triplet_decode, compute_bbox, store_loca, reconstruct_glyf): Make `i' variable unsigned. (reconstruct_glyph): Remove condition which is always false. (reconstruct_html): Removed unused argument `transformed_size'. Update caller. * src/sfnt/woff2tags.c (woff2_known_tags): Remove condition which is always false.
Werner Lemberg 60c52f0e 2019-08-27T10:08:01 [woff2] Formatting; some comments.
Nikhil Ramakrishnan 86803acd 2019-08-22T16:46:03 [woff2] Check whether known tag is in array bounds. If table tag is not 0x3f, we expect a value between 0 and 62. If this is not the case, exit with errors. * src/sfnt/sfwoff2/c: Check whether table tag makes sense. * src/sfnt/woff2tags.c: Return 0 if tag is out of bounds.
Nikhil Ramakrishnan d2681a49 2019-08-21T20:21:02 [woff2] More formatting and documentation. * include/freetype/internal/wofftypes.h, src/sfnt/sfwoff2.c: Implement formatting changes suggested as https://lists.nongnu.org/archive/html/freetype-devel/2019-08/msg00052.html
Nikhil Ramakrishnan 1a103015 2019-08-17T14:57:59 * src/sfnt/sfwoff2.c: Improve trace comments. Adjust tracing levels for comments, and more formatting.
Nikhil Ramakrishnan 97616704 2019-08-14T17:39:55 [woff2] Formatting. * src/sfnt/sfobjs.c, src/sfnt/sfwoff2.c: Better formatting.
Nikhil Ramakrishnan 2a23dc7f 2019-08-14T02:36:27 [woff2] Support `hmtx' reconstruction when `glyf' is untransformed. `reconstruct_hmtx' requires `info->x_mins' and `info->num_glyphs' to reconstruct the hmtx table. In case glyf is not transformed, we call `get_x_mins' which does the necessary work. * src/sfnt/sfwoff2.c (get_x_mins): New function. (reconstruct_font): Call get_x_mins.
Nikhil Ramakrishnan 5367e0ca 2019-08-05T01:53:00 [sfnt] Support `face->num_faces' for WOFF2 fonts. Set correct value of `face->num_faces' for WOFF2 fonts. This is being handled separately because we only load the tables for the requested font face in `woff2_open_font' and create a single-face sfnt stream. The full discussion is at: https://lists.gnu.org/archive/html/freetype-devel/2019-08/msg00000.html * src/sfnt/sfobjs.c (sfnt_open_font): Add parameter `woff2_num_faces'. (sfnt_init_face): Introduce variable `woff2_num_faces', and change `face->root.num_faces' if `woff2_num_faces' is set. * src/sfnt/sfwoff2.c (woff2_open_font): Validate requested face index and handle negative face indices. * src/sfnt/sfwoff2.h (woff2_open_font): Add parameter `num_faces' to declaration.
Nikhil Ramakrishnan bb7668d7 2019-07-28T19:38:05 [woff2] Improve memory and error handling. Free up memory after use, and improve error handling. * src/sfnt/sfwoff2.c (reconstruct_font, woff2_open_font): Implement changes.
Nikhil Ramakrishnan 1e020768 2019-07-18T01:50:16 [woff2] Avoid too many calls to `FT_REALLOC'. We do this by using `totalSfntSize' as an initial reference, and extending the buffer when required. This reduces rendering time considerably. * include/freetype/internal/wofftypes.h (WOFF2_HeaderRec): Add `totalSfntSize', rename `total_sfnt_size' to `actual_sfnt_size'. * src/sfnt/sfwoff2.c (write_buf): Add parameter `dst_size' to keep track of and update total size of stream. (WRITE_SFNT_BUF, WRITE_SFNT_BUF_AT): Modify macros accordingly. (pad4, store_loca, reconstruct_glyf, reconstruct_hmtx, reconstruct_font): Update parameters to accept `sfnt_size'. (woff2_open_font): Add variable `sfnt_size'. Use WOFF2 header field `totalSfntSize' as initial reference (if value makes sense) and allocate `totalSfntSize' bytes for the sfnt stream. `write_buf' handles reallocation if and when required. Also resize the stream to `actual_sfnt_size' after reconstruction.
Nikhil Ramakrishnan 4d9b3d1d 2019-07-16T02:45:03 [woff2] Reconstruct `loca', `hmtx', and swap out stream. Add necessary functions to reconstruct loca and hmtx tables (the two remaining tables that can have a transform). `woff2_open_font' is now capable of loading a woff2 font face. This code may still need more refining and better memory management. * include/freetype/internal/wofftypes.h (WOFF2_HeaderRec): Add total (final) size of sfnt stream. (WOFF2_InfoRec): Add header checksum value. * src/sfnt/sfobjs.c (sfnt_open_font): Change `face_instance_index' parameter to its pointer so its value can be modified by `woff2_open_font'. * src/sfnt/sfwoff2.c: (WRITE_SFNT_BUF_AT): New macro to write into sfnt buffer at given position. (write_buf): Add parameter `extend_buf' which allows caller to specify whether buffer should be reallocated before copying data. (WRITE_SFNT_BUF): Updated. (pad4, store_loca, reconstruct_htmx): New functions. (reconstruct_glyf): Calculate loca values and store them. (reconstruct_font): Call `reconstruct_hmtx', write table record entries, and calculate table checksums. Also calculate font checksum and update `checksumAdjustment' entry in head table. (woff2_open_font): Open stream for sfnt buffer, swap out input stream and return. * src/sfnt/sfwoff2.h (woff2_open_font): Modify parameter to accept pointer to `face_index'.
Nikhil Ramakrishnan e3953e54 2019-07-13T03:14:17 [woff2] Reconstruct transformed `glyf' table. Reconstruct `glyf' table if it is transformed in the uncompressed table stream. Also add necessary structures, macros and functions. * include/freetype/internal/wofftypes.h (WOFF2_InfoRec, WOFF2_SubstreamRec, WOFF2_PointRec): New structures. (WOFF2_TableRec): s/OrigLength/dst_length/. * src/sfnt/sfwoff2.c (READ_255USHORT, READ_BASE128): Use `FT_SET_ERROR' to set implicit `error' variable. (WRITE_SHORT): New macro. (N_CONTOUR_STREAM, N_POINTS_STREAM, FLAG_STREAM, GLYPH_STREAM, COMPOSITE_STREAM, BBOX_STREAM, INSTRUCTION_STREAM): New macros to refer to substreams of the transformed `glyf' tables. (Read255UShort, ReadBase128): Return errors set by `FT_READ_XXX' macros. (with_sign, safe_int_addition): New functions to add sign to values based on a flag and perform safe addition respectively. (triplet_decode): Decode variable-length (flag, xCoordinate, yCoordinate) triplet for a simple glyph. See https://www.w3.org/TR/WOFF2/#triplet_decoding (store_points, compute_bbox, composteGlyph_size, reconstruct_glyf): New functions. (reconstruct_font): Call `reconstruct_glyf'. * src/sfnt/sfwoff2.h: Add required constants. * src/sfnt/woff2tags.h: Move out constants to `sfwoff2.h'.
Nikhil Ramakrishnan 81cf5326 2019-07-06T18:05:18 [woff2] Copy un-transformed tables to sfnt stream. Copy un-transformed tables to the sfnt stream. * src/sfnt/sfwoff2.c: (WRITE_SFNT_BUF): New macro. (write_buf): New function. Extend memory of `dst' buffer and copy bytes from `src'. (compute_ULong_sum): New function. Calculate checksum of table. (reconstruct_font): Change `FT_Byte* sfnt' to `FT_Byte** sfnt_bytes'. This has been done because we reallocate memory to `sfnt' multiple times, which may change the pointer value of `sfnt'. This new pointer must be propogated back to the caller. Same reason for using a double pointer in `write_buf'. * src/sfnt/woff2tags.h (WOFF2_DEFAULT_MAX_SIZE): New macro used for overflow checking.
Nikhil Ramakrishnan 106bacf5 2019-07-05T01:09:52 [woff2] Create stream for uncompressed buffer. Uncompressed buffer is now an `FT_Stream'. Perform basic checks and start iterating over tables. * src/sfnt/sfwoff2.c (stream_close, find_table, read_num_hmetrics): New functions. (reconstruct_font): Modify parameters and iterate over tables. (woff2_open_font): Updated.
Nikhil Ramakrishnan 18f6ff11 2019-07-01T01:29:30 [woff2] Handle TTCs and start reconstructing font. We `handle' TTCs by modifying the `indices' array to point to only those tables that are part of the requested `face_index'. Set and use `num_tables' in `WOFF2_TtcFont'. * src/sfnt/sfwoff2.c (reconstruct_font): New function. (woff2_open_font): Start reconstruction of font.