src/sfnt


Log

Author Commit Date CI Message
Werner Lemberg fc082956 2022-04-01T14:44:42 * src/sfnt/sfwoff.c (reconstruct_glyf): Fix gcc 10 warning.
Werner Lemberg 695d606a 2022-04-01T08:50:33 Whitespace.
Werner Lemberg 87989a14 2022-03-31T07:43:41 Fix clang++ warnings. * src/base/ftglyph.c (ft_svg_glyph_prepare), src/base/ftobj.c (ft_glyphslot_init), src/cache/ftccmap.c (ftc_cmap_node_new), src/cache/ftcimage.c (FTC_INode_New), src/lzw/ftlzw.c (FT_Stream_OpenLZW), src/psaux/psobjs.c (ps_parser_load_field), src/pshinter/pshglob.c (psh_globals_new), src/sfnt/ttsvg.c (tt_face_load_svg_doc): Initialize variables used for allocation. * src/sdf/ftsdf.c (split_sdf_conic, split_sdf_cubic): Change type of `max_splits` to FT_UInt. (sdf_generate_bounding_box): Add cast.
Werner Lemberg a8e4563c 2022-03-19T23:54:31 Add `FT_FACE_FLAG_SBIX_OVERLAY` and `FT_HAS_SBIX_OVERLAY`. * include/freetype/freetype.h (FT_FACE_FLAG_SBIX_OVERLAY, FT_HAS_SBIX_OVERLAY): New macro. * src/sfnt/ttsbit.c (tt_face_load_sbit): Handle `FT_FACE_FLAG_SBIX_OVERLAY`. Remove obsolete tracing message.
Werner Lemberg 1949a7ec 2022-03-19T18:51:34 Add `FT_PARAM_TAG_IGNORE_SBIX`. This is another bit to handle 'sbix' tables as described in the OpenType specification. * include/freetype/ftparams.h (FT_PARAM_TAG_IGNORE_SBIX): New macro. * src/sfnt/sfobjc.c (is_apple_sbix): Rename to... (has_sbix): ... this. Check for more sbit tables. Handle `FT_PARAM_TAG_IGNORE_SBIX` to eventually control `has_sbix`. Only call sbit table loader if an sbit table is present.
Werner Lemberg ac4c1ebf 2022-02-07T06:55:54 [truetype] Fix 'sbix' table handling. * src/sfnt/ttsbit.c (tt_face_load_sbix_image): Correct calculation of 'metrics->horiBearingY'. Set vertical metrics. * src/sfnt/sfobjs.c (sfnt_load_face): Adjust setting of `FT_FACE_FLAG_SBIX`. Handle metrics of fonts with 'sbix' table. * src/truetype/ttgload.c (TT_Load_Glyph): For 'sbix' embedded bitmaps, apply bbox offset and bearing values of the corresponding glyph in the 'glyf' table if it exists and has a contour. * src/truetype/ttobjs.c (tt_face_init): Handle font with 'sbix' table. Fixes issue #998.
Werner Lemberg 907715a6 2022-02-09T07:31:56 Add `FT_FACE_FLAG_SBIX` and `FT_HAS_SBIX`. Fonts with 'sbix' tables need special handling by the application. * include/freetype/freetype.h (FT_FACE_FLAG_SBIX, FT_HAS_SBIX): New macros. * src/sfnt/sfobjs.c (sfnt_load_face): Set `FT_FACE_FLAG_SBIX` if 'sbix' table is present.
Werner Lemberg fc15ebe0 2022-03-21T11:15:41 * src/sfnt/ttkern.c (tt_face_get_kerning): Exit early if no table. Fixes #1141.
Ben Wagner a960be9e 2022-03-18T17:41:01 [woff2] Support overlap flag for simple glyphs. In the woff2 spec it has been proposed to allow the OVERLAP_SIMPLE flag to be retained through the woff2 format [0]. [0] https://www.w3.org/TR/WOFF2/#glyf_table_format * src/sfnt/sfwoff2.h (GLYF_OVERLAP_SIMPLE): add glyf flag. * src/sfnt/sfwoff2.c (reconstruct_glyf): parse optionFlags and overlapSimpleBitmap[]. (store_points): set OVERLAP_SIMPLE on first point's flag if the overlap bit is set.
Werner Lemberg 53dfdcd8 2022-03-17T19:24:16 [sfnt] Avoid invalid face index. Fixes #1138. * src/sfnt/sfobjs.c (sfnt_init_face), src/sfnt/sfwoff2.c (woff2_open_font): Check `face_index` before decrementing.
Werner Lemberg 1e2eb650 2022-03-07T10:13:29 Documentation, whitespace.
Ben Wagner 335224be 2022-03-03T16:33:40 [sfnt] Fix bounds check in SVG. The `SVG_DOCUMENT_LIST_MINIMUM_SIZE` macro is non trivial and not protected by parentheses. As a result, the expression `table_size - SVG_DOCUMENT_LIST_MINIMUM_SIZE` expands to `table_size - 2U + SVG_DOCUMENT_RECORD_SIZE` instead of the expected `table_size - (2U + SVG_DOCUMENT_RECORD_SIZE)`. This causes an incorrect bounds check which may lead to reading past the end of the `SVG ` table. * src/sfnt/ttsvg.c (tt_face_load_svg): wrap macro definitions in parentheses. Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45179
Werner Lemberg 5b26e92a 2022-02-19T05:26:53 src/sfnt/ttkern.c (tt_face_load_kern): Micro-optimize. A kerning table can be handled by binary search if it has equal entries. Fixes #1132.
Alexei Podtelezhnikov bee88864 2022-01-30T21:55:21 Clean-up - do not doubt FT_FREE. * src/base/ftobjs.c (memory_stream_close): Do not reassign zero after `FT_FREE`. * src/sfnt/sfwoff.c (sfnt_stream_close): Ditto. * src/sfnt/sfwoff2.c (stream_close): Ditto. * src/psaux/psobjs.c (ps_parser_load_field): Ditto. * src/truetype/ttgxvar.c (ft_var_load_avar, tt_set_mm_blend, tt_set_mm_blend): Ditto.
Alexei Podtelezhnikov b34741c1 2022-01-27T22:55:34 Minor clean-ups. * src/base/ftrfork.c (raccess_make_file_name): Do not set error. * src/sfnt/sfdriver.c (get_win_string, get_apple_string): Ditto. * src/cff/cffobjs.c (cff_strcpy): Do not confuse about error. * src/psaux/psobjs.c (ps_table_done): Ditto. * src/truetype/ttgxvar.c (ft_var_readpacked*, ft_var_load_avar): Ditto.
Werner Lemberg 112527dd 2022-01-22T11:45:30 [sfnt] Reject malformed SVG tables. * src/sfnt/ttsvg.c (SVG_TABLE_HEADER_SIZE, SVG_DOCUMENT_RECORD_SIZE, SVG_DOCUMENT_LIST_MINIMUM_SIZE, SVG_MINIMUM_SIZE): New macros. (tt_face_load_svg): Check offsets. Check table and record sizes. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43918
Moazin Khatti 0bf49bd2 2021-12-25T20:14:11 Add 'svg' module for OT-SVG rendering. * CMakeLists.txt (BASE_SRCS): Add svg module file. * meson.build (ft2_public_headers): Add `otsvg.h`. * modules.cfg (RASTER_MODULES): Add `svg` module. * builds/meson/parse_modules_cfg.py: Add svg module. * include/freetype/config/ftmodule.h: Add `ft_svg_renderer_class`. * include/freetype/fterrdef.h: Add `Invalid_SVG_Document` and `Missing_SVG_Hooks` error codes. * include/freetype/internal/fttrace.h: Add tracing for `otsvg`. * include/freetype/internal/svginterface.h: New file. It adds an interface to enable the presetting hook from the `base` module. * include/freetype/otsvg.h (SVG_Lib_Init_Func, SVG_Lib_Free_Func, SVG_Lib_Render_Func, SVG_Lib_Preset_Slot_Func): New hooks for SVG rendering. (SVG_RendererHooks): New structure to access them. * src/base/ftobjs.c: Include `svginterface.h`. (ft_glyphslot_preset_bitmap): Add code for presetting the slot for SVG glyphs. (ft_add_renderer): Updated. * src/svg/*: New files.
Moazin Khatti f93a897a 2021-12-25T19:20:44 Add code to load OT-SVG glyph documents. * include/freetype/config/ftheader.h (FT_OTSVG_H): New macro. * include/freetype/freetype.h (FT_FACE_FLAG_SVG, FT_HAS_SVG): New macros. (FT_LOAD_SVG_ONLY): New internal macro. * include/freetype/ftimage.h (FT_Glyph_Format): New enumeration value `FT_GLYPH_FORMAT_SVG`. * include/freetype/internal/ftobjs.h (FT_GLYPH_OWN_GZIP_SVG): New macro. * include/freetype/internal/fttrace.h: Add `ttsvg` for `ttsvg.c`. * include/freetype/internal/sfnt.h(load_svg, free_svg, load_svg_doc): New functions. * include/freetype/internal/tttypes.h (TT_FaceRec): Add `svg` for the SVG table. * include/freetype/otsvg.h (FT_SVG_DocumentRec): New structure to hold the SVG document and other necessary information of an OT-SVG glyph in a glyph slot. * include/freetype/tttags.h (TTAG_SVG): New macro. * src/base/ftobjs.c: Include `otsvg.h`. (ft_glyphslot_init): Allocate `FT_SVG_DocumentRec` in `slot->other` if the SVG table exists. (ft_glyphslot_clear): Free it upon clean-up if it is a GZIP compressed glyph. (ft_glyphslot_done): Free the document data if it is a GZIP compressed glyph. (FT_Load_Glyph): Don't auto-hint SVG documents. * src/cache/ftcbasic.c (ftc_basic_family_load_glyph): Add support for FT_GLYPH_FORMAT_SVG. * src/sfnt/rules.mk (SFNT_DRV_SRC): Add `ttsvg.c`. * src/sfnt/sfdriver.c: Include `ttsvg.h`. (sfnt_interface): Add `tt_face_load_svg`, `tt_face_free_svg` and `tt_face_load_svg_doc`. * src/sfnt/sfnt.c: Include `ttsvg.c`. * src/sfnt/sfobjs.c (sfnt_load_face, sfnt_done_face): Add code to load and free data of the the SVG table. * src/sfnt/ttsvg.c: New file, implementing `tt_face_load_svg`, `tt_face_free_svg` and `tt_face_load_svg_doc`. * src/sfnt/ttsvg.h: Declarations of the SVG functions in `ttsvg.c`.
Dominik Röttsches 3876846e 2022-01-11T13:40:20 [sfnt] Fix limit checks for `COLR` v1 ClipBoxes * src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Fix off-by-one in limit checks.
Werner Lemberg d0cfb4e1 2022-01-11T10:54:10 Update all copyright notices.
Werner Lemberg 947fddc8 2022-01-09T07:26:26 * src/sfnt/ttcolr.c (read_paint): Fix undefined left-shift operation. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43151
Werner Lemberg 4a89112b 2022-01-08T16:56:57 * src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Add limit checks. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40716
Alexei Podtelezhnikov ca011128 2022-01-08T22:28:44 [sfnt] Fix off-by-one error. The 0-base index is equal to the number of previosly parsed entries. It is an error to adjust it by one to get the number truncated by a stream error. This is probably inconsequential because valid entries are correctly accounted for. * src/sfnt/ttload.c (check_table_dir): Do not adjust the truncated number of tables.
Werner Lemberg 7a493e3a 2022-01-08T10:28:19 [sfnt, type42] Correct previous commit. Really fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42773. * src/sfnt/ttload.c (check_table_dir): Revert change. * src/type42/t42.parse.c (t42_parse_sfnts): Don't use `FT_QREALLOC` but `FT_REALLOC` for setting up `ttf_data` to avoid uninitialized memory access while handling malformed TrueType fonts later on.
Werner Lemberg bf9b1ef9 2022-01-07T10:25:52 * src/sfnt/ttload.c (check_table_dir): Initialize `table`. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42773
Werner Lemberg b5c2172f 2022-01-07T06:53:44 [sfnt] Avoid 'runtime error: applying zero offset to null pointer'. * src/sfnt/ttsbit.c (tt_sbit_decoder_load_byte_aligned): Exit early if `line` is NULL.
Dominik Röttsches 9597fd7b 2021-11-11T17:33:37 [sfnt] Avoid undefined shifts in `COLR` v1 paint parsing * src/sfnt/ttcolr.c (read_paint, tt_face_get_paint): Tighten shift behavior by using multiplication, mostly using macros from ftcalc.h. Fixes: https://bugs.chromium.org/p/chromium/issues/detail?id=1269168
Werner Lemberg d899b200 2021-11-08T12:27:04 * src/sfnt/sfobjs.c (sfnt_open_font): Fix typo.
Werner Lemberg 7ef26604 2021-11-04T09:10:57 [sfnt] Reduce footprint if WOFF and WOFF2 support is not needed. Based on a patch from metarutaiga (MR !106). The gist of this commit is that it doesn't make sense to support WOFF without compression (which would be only possible in WOFF 1.0 anyway). * src/sfnt/sfobjs.c (sfnt_open_font): Guard WOFF code with `FT_CONFIG_OPTION_USE_ZLIB` block. Guard WOFF2 code with `FT_CONFIG_OPTION_USE_BROTLI` block. * src/sfnt/sfwoff.c, src/sfnt/sfwoff.h: Guard files with `FT_CONFIG_OPTION_USE_ZLIB` blocks, not parts of the code. * src/sfnt/sfwoff2.c, src/sfnt/sfwoff2.h, src/sfnt/woff2tags.c, src/sfnt/woff2tags.h: Guard files with `FT_CONFIG_OPTION_USE_BROTLI` blocks, not parts of the code. Fixes #1111.
Alexei Podtelezhnikov 9ebdc9cb 2021-11-07T23:21:40 * src/sfnt/ttload.c (tt_face_load_gasp): Fix a type mismatch warning.
Dominik Röttsches d3d3ff76 2021-11-01T17:32:27 [sfnt] Clarify `COLR` v1 FT_Paint* format representations * include/freetype/ftcolor.h (FT_PaintLinearGradient, FT_PaintRadialGradient, FT_PaintSweepGradient, FT_PaintTransform, FT_PaintTranslate, FT_PaintScale, FT_PaintRotate, FT_PaintSkew): Clarify 16.16 fixed point representation of struct fields. * src/sfnt/ttcolr.c (read_paint): Shift coordinates for FT_PaintLinearGradient, FT_PaintRadialGradient, FT_PaintSweepGradient accordingly. Fixes: https://gitlab.freedesktop.org/freetype/freetype/-/issues/1110
Alexei Podtelezhnikov 793c0126 2021-10-27T22:36:11 [woff] Optimize table tagging. * include/freetype/internal/wofftypes.h (WOFF_TableRec): Use 32-bit tag. * src/sfnt/sfwoff.c (woff_open_font): Use 32-bit tag.
Alexei Podtelezhnikov a577bbcb 2021-10-27T22:24:27 [woff2] Optimize table tagging. Fixes #1107. * include/freetype/internal/wofftypes.h (WOFF2_TableRec): Use 32-bit tag. * src/sfnt/sfwoff2.c (compare_tags, find_table, woff2_open_font): Use 32-bit tag. * src/sfnt/woff2tags.[ch] (woff2_known_tags): Use static storage and return 32-bit tag.
Werner Lemberg 80b13f57 2021-10-26T10:57:17 Formatting.
Ben Wagner fde91ab8 2021-10-20T11:45:15 [sfnt] Delay setting gasp ranges and count until computed. Previously, the gasp.numRanges was set and gasp.gaspRanges was allocated and assigned before a possible early exit if the frame could not be entered. It is also possible that the gaspRanges allocation could fail but the numRanges still be set to non-zero. In such cases an error would be returned, but the face would have a gasp in an inconsistent state which may still be accessed. Reported as https://bugs.chromium.org/p/chromium/issues/detail?id=1261450 * src/sfnt/ttload.c (tt_face_load_gasp): Delay setting gasp.numRanges and gasp.gaspRanges until after the ranges are initialized.
Ben Wagner 6d12e3a0 2021-10-20T11:38:16 [sfnt] Delay setting names and langTags until computed. Previously, the table->names and table->langTags fields were created pointing to uninitialized memory and an early exit could happen if the frame could not be entered. The caller would then be unable to properly dispose of the memory as the string fields had not been initialized. Reported as https://bugs.chromium.org/p/chromium/issues/detail?id=1261343 * src/sfnt/ttload.c (tt_face_load_name): delay setting table->langTags and table->names until after the memory they will point to is fully initialized.
Alexei Podtelezhnikov 986d503f 2021-10-17T09:14:27 * src/sfnt/ttload.c (tt_face_load_name): NULL-initialize langTag. Another attempt to fix fallout reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40024
Alexei Podtelezhnikov afd1cb28 2021-10-16T20:25:11 * src/sfnt/ttload.c (tt_face_load_name): Accounting fix. Fallout reported as https://crbug.com/40024
Ben Wagner c71eb22d 2021-10-15T22:18:38 Fix typos in memory macros. FT_QNEW_ARRAY and FT_QRENEW_ARRAY were using the non-Q FT_MEM_NEW_ARRAY and FT_MEM_RENEW_ARRAY. Change these to use the Q versions. Also fix the one issue discovered in tt_face_load_name where table->names is created with FT_QNEW_ARRAY but the extra string member is not initialized to NULL. * include/freetype/internal/ftmemory.h (FT_Q(RE)NEW_ARRAY): Use FT_MEM_Q(RE)NEW_ARRAY as needed. * src/sfnt/ttload.c (tt_face_load_name): Initialize `entry->string`.
Alexei Podtelezhnikov 49270c17 2021-09-14T21:32:43 Replace boolean allocation macros with MEM ones. * src/base/ftbitmap.c (FT_Bitmap_Copy): Use MEM-macro. * src/base/ftobjs.c (ft_glyphslot_alloc_bitmap): Ditto. * src/bzip2/ftbzip2.c (ft_bzip2_alloc): Ditto. * src/cache/ftccache.c (ftc_cache_init): Ditto * src/gzip/ftgzip.c (ft_gzip_alloc): Ditto. * src/psnames/psmodule.c (ps_unicodes_init): Ditto. * src/sfnt/sfobjs.c (sfnt_load_face): Ditto. * src/sfnt/ttload.c (tt_face_load_name): Ditto.
Alexei Podtelezhnikov 058f3f2d 2021-09-13T16:24:25 [bdf, psnames, sfnt] Avoid some memory zeroing. * src/bdf/bdfdrivr.c (BDF_Face_Init): Use Q-macro. * src/sfnt/sfobjs.c (sfnt_load_face): Ditto. * src/psnames/psmodule.c (src/psnames/psmodule.c): Remove zero.
Dominik Röttsches 633fe087 2021-08-19T16:56:22 [sfnt] Fix format expectation for `COLR` v1 ClipList * src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Change ClipList format expectation to 1 instead of 0 to make it compliant with the latest spec.
Werner Lemberg fed55210 2021-08-09T19:27:34 * src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Minor fix.
Dominik Röttsches 47cf8ebf 2021-07-28T17:36:57 [sfnt] Add API for retrieving a 'COLR' v1 'ClipBox' table. The optional 'COLR' v1 glyph-specific clip box helps upstream graphics libraries allocate a sufficiently large bitmap for a glyph without having to traverse the glyph graph for that. See https://github.com/googlefonts/colr-gradients-spec/issues/251 for background on the introduction of this specification change. * include/freetype/ftcolor.h (FT_ClipBox): New structure. (FT_Get_Color_Glyph_ClipBox): New function declaration. * include/freetype/internal/sfnt.h (TT_Get_Color_Glyph_ClipBox_Func): New function type. (SFNT_Interface, FT_DEFINE_SFNT_INTERFACE): Use it. * src/base/ftobjs.c (FT_Get_Color_Glyph_ClipBox): New function to link API with SFNT implementation. * src/sfnt/sfdriver.c (sfnt_interface): Updated. * src/sfnt/ttcolr.c (Colr): New field `clip_list`. (tt_face_load_colr): Parse global clip list offset. (tt_face_get_color_glyph_clipbox): New function to find the clip box for a glyph id from the clip list array. * src/sfnt/ttcolr.h: Updated.
Werner Lemberg d2367aba 2021-07-29T08:16:25 src/sfnt/ttcolr.c: Minor formatting.
Dominik Röttsches 30a82e1e 2021-07-26T18:28:56 [sfnt] 'COLR' v1 PaintSweepGradient spec update * src/sfnt/ttcolr.c (read_paint): PaintSweepGradient follows other spec changes and now has the angles specified as F2DOT14, reflect that in the implementation. * include/freetype/ftcolor.h (FT_PaintSweepGradient): Update documentation.
Dominik Röttsches 5c0ac7a4 2021-07-26T17:32:09 [sfnt] Retrieve affine matrix from offset in 'COLR' v1 parsing. * src/sfnt/ttcolr.c (read_paint): Implement spec change where affine transform matrix is now referenced by offset instead of being placed inline in the PaintTransform table.
Dominik Röttsches 66189807 2021-07-26T17:32:22 [sfnt] 'COLR' v1 PaintSkew related spec updates * src/sfnt/ttcolr.c (read_paint): Implement spec changes around PaintSkew, PaintSkewAroundCenter. Update parsing to read shorter values as changed in the spec. * include/freetype/ftcolor.h (FT_PaintSkew): Update documentation.
Dominik Röttsches 48df0fa6 2021-07-23T19:02:51 [sfnt] PaintRotate/PaintRotateAroundCenter spec updates * src/sfnt/ttcolr.c (read_paint): Implement spec change where PaintRotate and PaintRotateAroundCenter were split for a more compact format definition. Update parsing to read shorter values as changed in the spec. * include/freetype/ftcolor.h (FT_PaintRotate): Update documentation.
Dominik Röttsches d7bdcb1b 2021-07-23T19:37:47 [sfnt] 'COLR' v1 PaintTranslate and PaintScale precision * src/sfnt/ttcolr.c (read_paint): Implement spec changes in PaintTranslate and PaintScale and friends. Update parsing to read new shorter values.
Werner Lemberg 801cd842 2021-07-18T07:53:57 * Version 2.11.0 released. ========================== Tag sources with `VER-2-11-0'. * docs/VERSION.TXT: Add entry for version 2.11.0. * docs/CHANGES: Updated. * README, src/base/ftver.rc, builds/windows/vc2010/index.html, builds/windows/visualc/index.html, builds/windows/visualce/index.html, builds/wince/vc2005-ce/index.html, builds/wince/vc2008-ce/index.html, docs/freetype-config.1: s/2.10.4/2.11.0/, s/2104/2110/. * include/freetype/freetype.h (FREETYPE_MINOR): Set to 11. (FREETYPE_PATCH): Set to 0. * builds/unix/configure.raw (version_info): Set to 24:0:18. * CMakeLists.txt (VERSION_MINOR): Set to 11. (VERSION_PATCH): Set to 0. * builds/toplevel.mk (dist): Ignore more git-related files.
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.