summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* [truetype] Check avar_segment before accessBen Wagner2022-11-091-3/+6
| | | | | | | | | * src/truetype/ttgxvar.c (tt_done_blend): check `avar_segment` before accessing to free its `correspondence`. Reported as: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53062
* [truetype] Restore behavior of ft_var_load_hvvarBen Wagner2022-11-091-9/+6
| | | | | | | | | | | | | | | | | | | | | * src/truetype/ttgcvar.c (ft_var_load_hvvar): restore previous behavior In a previous change [0] the behavior of `ft_var_load_hvvar` was changed to not load the item variation store if it was at offset 0, but not return an error when this happened. This broke any users, like `tt_hvadvance_adjust`, that rely on successful completion of `ft_var_load_hvvar` to imply that returned table's `itemStore` had been initialized. This lead such users to dereference NULL. This change appears to have been unintentional and unrelated to the actual avar2 changes. As a result, fix these NULL dereferences by restoring the code to always attempt to initialize the `itemStore`. [0] ae4eb996 "[truetype] Add support for `avar` table 2.0 format." Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53061
* [build] fix for make multisuzuki toshiya2022-11-082-0/+2
| | | | | | | | Fix "make multi" by MR !223 * include/freetype/internal/services/svmm.h: include ftmm.h to define FT_Get_MM_Func. * src/truetype/ttgxvar.h: include ftmmtypes.h to use GX_AVarTable properly. * src/base/ftmac.c: include ftdebug.h to use FT_THROW() properly.
* * src/pfr/pfrsbit.c (pfr_lookup_bitmap_data): Accelerate the search.Alexei Podtelezhnikov2022-11-071-3/+8
| | | | | This is mostly for consistency because PFR fonts with bitmap strikes do not seem to exist.
* [bdf, pfr, psnames] Accelarate charmap searches.Alexei Podtelezhnikov2022-11-063-44/+45
| | | | | | | | | | | | | | The binary searches within charmaps can be accelerated because they often contain dense continuous blocks of character codes. Within such blocks, you can predict matches based on misses. This method has been deployed in `bdf` since 0f122fef34; we only refactor it there. We now use it in `pfr` and `psnames`, which speeds up the unicode charmap access by about 50% in PFR and Type 1 fonts. * src/bdf/bdfdrivr.c (bdf_cmap_char_{index,next}): Refactor. * src/pfr/pfrcmap.c (pfr_cmap_char_{index,next}): Predict `mid` based on the mismatch distance. * src/psnames/psmodule.c (ps_unicodes_char_{index,next}): Ditto.
* [truetype] Add support for `avar` table 2.0 format.Behdad Esfahbod2022-11-042-40/+176
| | | | | | | | | | | | | | | | | | | See https://github.com/harfbuzz/boring-expansion-spec/blob/main/avar2.md for the specification. Currently, this is implemented only in most recent OS versions on Apple platforms and in the HarfBuzz library, but it is expected to be added to the OpenType standard soon. * src/truetype/ttgxvar.h (GX_AVarTableRec): New structure. (GX_BlendRec): Use it to replace `avar_segment` with `avar_table`. * src/truetype/ttgxvar.c (ft_var_load_avar): Load new table version. (ft_var_to_normalized, tt_done_blend): Extend for new format. (ft_var_load_hvvar, ft_var_to_design): Updated.
* Replace '1/64th' (and similar entries) with '1/64' in docs and comments.Werner Lemberg2022-10-242-8/+8
|
* * src/truetype/ttgload.c: Cosmetic changes.Alexei Podtelezhnikov2022-10-211-24/+11
|
* [cff, truetype] Simplify SVG metrics scaling.Alexei Podtelezhnikov2022-10-212-35/+23
| | | | | | | | Use pre-calculated scaling factors. Also, the advance widths used to be rounded, which was incorrect. * src/cff/cffgload.c (cff_slot_load): Use `x_scale` and `y_scale`. * src/truetype/ttgload.c (TT_Load_Glyph): Ditto.
* [sfnt] Additional bounds checks for `COLR` v1 table handling.Dominik Röttsches2022-10-181-11/+18
| | | | | | | | | | | * src/sfnt/ttcolr.c (read_paint): Add `colr` argument, necessary for... ... another use of `ENSURE_READ_BYTES`. Update callers. (tt_face_get_paint_layers): Ensure that the 4-byte paint table offset can be read. This is a follow-up to !124 and issue https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52404
* [gzip] Update sources to zlib 1.2.13.Werner Lemberg2022-10-189-56/+74
|
* * src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Simplify calculations.Alexei Podtelezhnikov2022-10-181-21/+12
|
* Minor formatting.Werner Lemberg2022-10-181-2/+2
|
* [sfnt] Guard individual `COLR` v1 paint field reads.Dominik Röttsches2022-10-181-2/+38
| | | | | | | | | | | * src/sfnt/ttcolr.c (ENSURE_READ_BYTES): New macro. (read_paint): Use it – after the start pointer `p` has been checked for whether it allows reading the format byte, each successive paint table field read need to be bounds-checked before reading further values. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52404
* * src/base/ftsynth.c (FT_GlyphSlot_Slant): New API with custom slant.Liu Kunpeng(柳鲲鹏)2022-10-161-4/+12
| | | | * include/freetype/ftsynth.h (FT_GlyphSlot_Slant): Declare it.
* [cff] Remove `FT_CONFIG_OPTION_NO_GLYPH_NAMES`.Werner Lemberg2022-10-102-31/+2
| | | | | | | | | This ancient option stayed completely undocumented. Given that the 'cff' driver requires the 'psnames' module, it makes no sense today to have this macro. * src/cff/cffdrivr.c (cff_services), src/cff/cffobjs.c (cff_face_init): Remove corresponding conditional code.
* Minor comment changes.Werner Lemberg2022-10-101-2/+2
|
* [autofit] Reset the face charmap directly.Alexei Podtelezhnikov2022-10-034-5/+4
| | | | | | | | | 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.
* * src/type1/t1afm.c (T1_Read_PFM): Set charmaps directly.Alexei Podtelezhnikov2022-10-031-8/+2
| | | | | | As with the previous commit, we can avoid the validation checks of `FT_Set_Charmap` and set it directly when choosing from the available list.
* * src/cache/ftccmap.c (FTC_CMapCache_Lookup): Avoid `FT_Set_Charmap`. Alexei Podtelezhnikov2022-10-031-8/+6
| | | | | Set charmap aggressively without all validations of `FT_Set_Charmap` because we take it from the available array and only temporarily. Even CMap Format 14 will gracefully return 0.
* * src/cache/ftcbasic.c (ftc_basic_family_get_count): Remove redundancy.Alexei Podtelezhnikov2022-10-031-2/+1
|
* * src/psaux/pshints.c (cf2_hintmap_insertHint): Fix midpoint computation.Werner Lemberg2022-09-301-2/+4
| | | | | | | Replace '(start + end) / 2' with 'start + (end - start) / 2' to avoid overflow. Fixes #1180.
* * src/psaux/pshints.c (cf2_hintmap_build): Improve debugging output.Werner Lemberg2022-09-301-3/+3
|
* [truetype] Fix undefined pointer arithmetic.mlugg2022-09-291-4/+5
| | | | | * src/truetype/ttgxvar.c (tt_var_get_item_delta, ft_var_load_mvar): Use `FT_OFFSET`.
* * src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Use lighter FT_DivFix.Alexei Podtelezhnikov2022-09-291-4/+2
|
* [base] FT_Attach_Stream: Make `parameters` argument constant.Ali Chraghi2022-09-291-2/+2
|
* * src/tools/*.py: Migrate to Python 3.Azamat Hackimov2022-09-283-808/+805
| | | | Fixes #1185, closes !205. Formatting changes according to PEP8.
* [sfnt] Guard access in 'COLR' table when requesting child table pointer.Dominik Röttsches2022-09-271-5/+13
| | | | | | | | | | | * src/sfnt/ttcolr.c (tt_face_get_colorline_stops, read_paint): Tighten pointer bounds checks. (get_child_table_pointer): Check whether incoming pointer `p` lies within the 'COLR' table. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51816
* [sfnt] Add SVG document bounds checking.Ben Wagner2022-09-271-36/+45
| | | | | | | | | | | | | | | | | Add a check that the document content is actually contained within the `SVG ` table. Without this check a malformed font may claim arbitrary memory as its document content. * src/sfnt/ttsvg.c (tt_face_load_svg): Take `numEntries` into account when testing 'documentRecord' extents. (find_doc): Rename `stream` to `document_records` for clarity. (tt_face_load_svg_doc): Split `doc` from `doc_list` pointer for clarity. Test that the document content is contained within the table. Ensure minimum length of document before testing for gzip format. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51812
* [base] Clean up the bitmap flow control.Alexei Podtelezhnikov2022-09-221-20/+20
| | | | | | | * src/base/ftbitmap.c (FT_Bitmap_Copy): Flip the copy if its pitch is trully opposite, zero is not a positive value. (FT_Bitmap_Convert): Set negative pitch as needed, accept negative alignment values.
* [base] Discard and recreate bitmaps for copying and converting. Alexei Podtelezhnikov2022-09-221-49/+17
| | | | | | | | Reusing target bitmaps for copying and converting is permitted. It is, however, pointless to preserve their content before overwriting. Free- malloc might be faster than realloc. * src/base/ftbitmap.c (FT_Bitmap_Copy, FT_Bitmap_Convert): Free an old buffer and create a new one.
* Reject 'COLR' table if version is 1 but header too small.Dominik Röttsches2022-09-161-3/+13
| | | | | | | | | * src/sfnt/ttcolr.c (tt_face_load_colr): If the version is determined to be 1, then the table size has to be at least the size of the v1 header. Also, for peeking the number of base glyphs and entries in the layer list, ensure that the table is sufficiently long. Fixes #1179. Original patch by Sergey Temnikov.
* * src/otvalid/otvgsub.c (otv_SingleSubst_validate): Fix format 1 handling.Werner Lemberg2022-09-151-5/+15
| | | | Fixes #1181.
* [truetype] Reject 'fvar' loading when `num_instances` is too small.Dominik Röttsches2022-09-061-5/+16
| | | | | | | | | | * src/truetype/ttgxvar.c (TT_Get_MM_Var): Reject retrieving master when 'fvar' values locally do not match with sanitized values from initialization at `sfnt_init_face` time. Reported as https://bugs.chromium.org/p/chromium/issues/detail?id=1360295
* [sfnt] Handle variable `COLR` v1 fonts without delta set index mapDominik Röttsches2022-09-051-3/+2
| | | | | | | | Fixes #1178. * src/sfnt/ttcolr.c (get_deltas_for_var_index_base): Set outer index to 0 and inner index to the delta index when retrieving deltas if the `COLR` table has no delta set index map.
* [sfnt] Pointer sanity checks before reading layer info in 'COLR' v0Dominik Röttsches2022-09-051-1/+3
| | | | | | | | | * src/sfnt/ttcolr.c (tt_face_get_colr_layer): Check that the pointer to read from is within the 'COLR' table. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50633
* [autofit] Minor fix.Werner Lemberg2022-09-051-1/+1
| | | | | * src/autofit/afglobal.c (af_face_globals_compute_style_coverage): Avoid compiler warning.
* [sfnt] Don't require 'gvar' table to support variation fonts.Dominik Röttsches2022-09-052-22/+10
| | | | | | | | | | | | | Fixes #1172. * src/sfnt/sfobjs.c (sfnt_load_face): Tag font as Multiple Masters font if `fvar` is present; do not require other tables to be present. * src/truetype/ttgxvar.c (tt_set_mm_blend): Allow for a missing 'gvar' table when setting variation coordinates. However, if a 'gvar' table is actually present, do perform a sanity check and fail on malformedness. (TT_Get_MM_Var): Don't assume 'fvar' needs 'gvar' or 'CFF2 tables in all cases, which is an overly tight check.
* * src/base/ftver.rc: Explicitly use UTF-16.Alexei Podtelezhnikov2022-08-261-3/+3
| | | | Fixes #1177 to avoid mistranslation and other problems.
* [sfnt] Avoid undefined shifts in `COLR` v1 color line retrievalDominik Röttsches2022-08-261-2/+2
| | | | | | | * src/sfnt/ttcolr.c (tt_face_get_colorline_stops): Disambiguate shift behavior by using multiplication using macros from ftcalc.h. Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50573
* [base, type1] Better handling of out-of-memory situations.Chris Liddell2022-08-212-3/+6
| | | | | | | | | | | This follows similar code in `cff_slot_done`. * src/base/ftobjs.c (ft_glyphslot_done), src/type1/t1objs.c (T1_GlyphSlot_Done): Check `internal` pointer. The Type1 problems was reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50057.
* * src/cache/ftcmanag.c (FTC_Manager_New): Initialize `cur_weight`.@udoudou2022-08-031-0/+1
| | | | See !192.
* * src/sfnt/ttload.c: Trace formatting updates.Alexei Podtelezhnikov2022-08-021-13/+13
|
* * src/psaux/psobjs.c (ps_table_release): Remove redundant casting. Alexei Podtelezhnikov2022-08-021-1/+1
|
* * src/base/ftobjs.c (Mac_Read_sfnt_Resource): Reduce casting.Alexei Podtelezhnikov2022-08-011-6/+6
|
* [cache] Remove some casts, clean up tracing.Alexei Podtelezhnikov2022-08-014-11/+11
| | | | | | | | | * src/cache/ftcbasic.c (FTC_ImageCache_Lookup, FTC_SBitCache_Lookup): Clean up tracing types. * src/cache/ftccache.c (ftc_node_destroy): Ditto. * src/cache/ftcmanag.c (FTC_Manager_Check): Ditto. (FTC_Manager_Check, FTC_Node_Unref): Remove a cast. * src/cache/ftccmap.c (FTC_CMapCache_Lookup): Ditto.
* [autofit] Updated to reduce casting (cont'd).Alexei Podtelezhnikov2022-08-013-16/+13
| | | | | | | * src/autofit/afmodule.h (AF_ModuleRec): Change `default_script` type. * src/autofit/afglobal.c (af_face_globals_compute_style_coverage): Remove casting. * src/autofit/afmodule.c (af_property_{set,get}): Updated accordingly.
* [autofit] Updated to reduce casting.Alexei Podtelezhnikov2022-08-013-20/+20
| | | | | | | | * 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.
* [psaux] Remove unused structure field.Alexei Podtelezhnikov2022-07-311-1/+0
| | | | | * include/freetype/internal/psaux.h (PS_TableRec): Remove `num_elems`. * src/psaux/psobjs.c (ps_table_new): Remoove its initialization.
* [sfnt] Implement VarClipBox.Dominik Röttsches2022-07-301-2/+30
| | | | | * src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Depending on the format, read `var_index_base`, then retrieve and apply scaled deltas.