Ben Wagner
2a6665a4c0
[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.
4 years ago
Werner Lemberg
7ca7da9d13
* src/autofit/aflatin.c (af_latin_metrics_scale_dim): Fix tracing.
...
Problem reported by Alexei.
4 years ago
Werner Lemberg
0abbc9f512
[psaux] Fix MSVC compiler warnings.
...
* src/psaux/afmparse.c (afm_parse_track_kern, afm_parse_kern_pairs):
Add cast.
4 years ago
Werner Lemberg
6e253b26b2
Typos in previous commit.
4 years ago
Werner Lemberg
a50c39aa8e
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.
4 years ago
Werner Lemberg
2bfdc161fb
[build] Allow overriding of `ANSIFLAGS` for GNU make build.
...
* builds/*: Implement it.
4 years ago
Alexei Podtelezhnikov
28eee3636c
[type42] Fix auto-hinting.
...
The autohinter could not access the base (unscaled) outline in the
child TrueType glyph slot. We now share the internal parts between
the parent and child glyph slots. Fixes #1057 .
* src/type42/t42objs.c (T42_GlyphSlot_Init): Remove the internal parts
of `T42_GlyphSlot' and replace it with the child TrueType structure.
(T42_GlyphSlot_Done): Updated accordingly.
4 years ago
Werner Lemberg
0d1c306e51
[psaux] Guard and trace AFM kern data allocation.
...
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31543
* include/freetype/internal/fttrace.h: Add 'afmparse' trace
component.
* src/psaux/afmparse.c (FT_COMPONENT): Define.
(afm_parse_track_kern, afm_parse_kern_pairs): Protect against
allocations bombs.
Add tracing.
(afm_parse_kern_data): Don't allow multiple kern data sections.
4 years ago
Werner Lemberg
5f485339be
.gitignore: Add `subprojects` directory, fix some patterns.
4 years ago
Alexei Podtelezhnikov
16947c0eb1
* meson.build (ft2_public_headers): Add missing `ftcid.h'.
...
Fixes #1058 .
4 years ago
Alexei Podtelezhnikov
2468e59af1
[type42] Avoid some memory zeroing.
...
* src/type42/t42objs.c (T42_Open_Face): Tweak allocation macro.
* src/type42/t42parse.c (t42_parse_sfnts): Ditto.
4 years ago
Nikolaus Waxweiler
ebf9e5ac71
[CMake] Update dependency finders.
...
1. Fixes CMake using any found HarfBuzz version lower than the minimum
required. This is based on HALX99's merge request at
https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/31
2. Update FindHarfBuzz.cmake from
https://github.com/WebKit/WebKit/blob/1ce32454/Source/cmake/FindHarfBuzz.cmake
and guard post-CMake-3.1 features to keep the minimum version unchanged
3. Update FindBrotliDec.cmake to stop the warnings, based on what
https://github.com/google/woff2/blob/a0d0ed7d/cmake/FindBrotliDec.cmake
is doing
* CMakeLists.txt, builds/cmake/FindHarfBuzz.cmake: Implement 1 and 2.
* builds/cmake/FindBrotliDec.cmake: Implement 3.
4 years ago
Ben Wagner
06e21ffedf
[gzip] Use exact type for `ft_gzip_alloc` and `ft_gzip_free`.
...
While a function pointer may be cast to another function pointer
type, it is required to cast the function pointer back to the
original function pointer type before calling it. If a parameter is
a pointer the exact pointer type is required. Using a pointer to a
different underlying type is technically undefined behavior. The
wrapper functions `ft_gzip_alloc` and `ft_gzip_free` took
`FT_Memory` (a `FT_MemoryRec_*`) instead of `voidpf` (`void*`), so
when gzip calls these callbacks through `alloc_func` or `free_func`
it invokes undefined behavior. On most platforms this works out as
expected, but newer undefined behavior detectors and targets like
wasm can detect this and will produce an error.
* src/gzip/ftgzip.c (ft_gzip_alloc, ft_gzip_free): Update signatures
to exactly match `alloc_func` and `free_func`, respectively.
Internally, cast the `void*` opaque pointer to `FT_Memory`.
4 years ago
Alexei Podtelezhnikov
81852fbccc
Prioritize the anti-aliasing renderer module.
...
* modules.cfg: Reorder the renderers.
* include/freetype/config/ftmodule.h: Ditto.
4 years ago
Alexei Podtelezhnikov
1bc801b0d6
[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".
4 years ago
Daniel McArdle
de15165774
[psaux] Use doubling allocation strategy for CF2_ArrStack.
...
Fixes timeout reported as
https://crbug.com/1206181
* src/psaux/psarrst.c (cf2_arrstack_{push,init}): Implement it.
* src/psaux/psarrst.h (CF2_ArrStackiRec): Drop `chunk'.
4 years ago
Alexei Podtelezhnikov
2d3f5dd294
* src/smooth/ftgrays.c (FT_MAX_GRAY_SPANS): Increase from 10 to 16.
...
Ten was barely enough for two slanted stems. Sixteen can actually fit
a bit more complicated scanlines.
4 years ago
Alexei Podtelezhnikov
c653b8d2f1
* src/smooth/ftgrays.c (FT_GRAY_SET): Adjust for better code.
4 years ago
Alexei Podtelezhnikov
8f43d324d1
[smooth] Faster bitmap sweeping.
...
Selecting the fill rule or checking the direct mode each time we call
`gray_hline' is sub-optimal. This effectively splits the direct mode
into a separate code path while inlining `gray_hline' and saving 5-7%
of rendering time.
* src/smooth/ftgrays.c (gray_hline): Eliminated in favor of...
(FT_FILL_RULE, FT_GRAY_SET): ... these new macros...
(gray_sweep): ... inlined here.
(gray_sweep_direct): New function that handles the direct span buffer.
(gray_TWorker): Remove the span buffer.
(gray_raster_render, gray_convert_glyph): Updated.
4 years ago
Alexei Podtelezhnikov
b070264521
* src/smooth/ftgrays.c (gray_hline): Simplify even-odd computations.
...
It is too bad the even-odd rule is not used much.
4 years ago
Alexei Podtelezhnikov
967a34eee3
[type1] Avoid MM memory zeroing.
...
* src/type1/t1load.c (t1_allocate_blend, parse_blend_design_map):
Tweak allocation macros.
* src/type1/t1objs.c (T1_Face_Done): Minor.
4 years ago
Alexei Podtelezhnikov
2f62d8e075
* src/bdf/bdflib.c (_bdf_list_ensure): Tweak allocation macro.
4 years ago
Alexei Podtelezhnikov
79ed536d01
* src/psaux/psobjs.c (ps_parser_load_field): Tweak allocation macro.
4 years ago
Alexei Podtelezhnikov
44c59414eb
* src/sfnt/sfobjs.c (sfnt_load_face): Tweak allocation macro.
4 years ago
Alexei Podtelezhnikov
998c7c0f1c
* src/cid/cidload.c (cid_read_subrs): Tweak allocation macro.
4 years ago
Alexei Podtelezhnikov
2d95784885
* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Tweak allocation.
4 years ago
Alexei Podtelezhnikov
8150ed0db2
[cff,psaux] Avoid memory zeroing (contd.).
...
* src/cff/cffload.c (cff_blend_doBlend, cff_blend_build_vector): Tweak
allocation macros.
* src/psaux/psarrst.c (cf2_arrstack_setNumElements): Ditto.
* src/psaux/psstack.c (cf2_stack_init): Ditto.
4 years ago
Ben Wagner
82fd32d674
* src/cid/cidload.c (cid_hex_to_binary): Improve return value.
...
Add argument to return the actual number of bytes that were decoded.
The actual number of bytes decoded can be quite variable depending
on the number of ignored 'whitespace' bytes or early termination
with `>`.
(cid_face_open): Updated to use this calculated value. This avoids
trusting `parser->binary_length` is always be correct and reading
uninitialized bits if fewer are actually decoded.
First reported as
https://crbug.com/1203240
4 years ago
Alexei Podtelezhnikov
66630d882c
[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.
4 years ago
Alexei Podtelezhnikov
ec95f9c921
[bdf,pcf] Avoid memory zeroing (contd.).
...
* src/bdf/bdflib.c (bdf_create_property, _bdf_add_comment,
_bdf_add_property, bdf_load_font): Tweak allocation macros.
* src/pcf/pcfread.c (pcf_get_properties, pcf_get_metrics): Ditto.
4 years ago
Alexei Podtelezhnikov
d911cb5392
* src/cid/cidload.c (cid_read_subrs): Tweak allocaton macro.
4 years ago
Alexei Podtelezhnikov
dc42f826af
[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.
4 years ago
Alexei Podtelezhnikov
b8968d666e
* src/sfnt/ttpost.c (load_format_{20,25}): Tweak allocaton macros.
4 years ago
Alexei Podtelezhnikov
2583b6085e
* src/sfnt/pngshim.c (Load_SBit_Png): Tweak allocaton macro.
4 years ago
Alexei Podtelezhnikov
56ae943050
[truetype] Avoid some memory zeroing.
...
* src/truetype/ttinterp.c (Init_Context): Tweak allocation macro.
* src/truetype/ttpload.c (tt_face_load_cvt): Ditto.
4 years ago
Alexei Podtelezhnikov
c177cc354d
[woff2] Avoid some memory zeroing.
...
* src/sfnt/sfwoff2.c (store_loca, woff2_open_font): Tweak macros.
4 years ago
Alexei Podtelezhnikov
4e1c6a12e5
* src/gzip/ftgzip.c (ft_gzip_alloc): Zero out memory again.
4 years ago
Alexei Podtelezhnikov
f631542dae
[lzw] Preserve decompression stack when relocating to heap.
...
* src/lzw/ftzopen.c (ft_lzwstate_stack_grow): Copy stack when
relocating to heap.
4 years ago
Alexei Podtelezhnikov
c213c8a9bb
* src/cid/cidgload.c (cid_load_glyph): Restore the glyph_length check.
4 years ago
Werner Lemberg
2ec6feaf39
* src/psmodule.c (ps_unicodes_init): Ignore empty glyph names.
...
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33637
4 years ago
Alexei Podtelezhnikov
caff87b1f9
* src/sfnt/sfobjs.c (sfnt_init_face): Revert macro change.
4 years ago
Alexei Podtelezhnikov
8750e843df
[cff] Avoid some memory zeroing.
...
* src/cff/cffparse.c (cff_parser_init): Tweak memory macro.
* src/cff/cffload.c (cff_index_load_offsets, cff_index_get_pointers,
cff_charset_load, cff_vstore_load): Ditto.
4 years ago
Alexei Podtelezhnikov
618d0834c7
[pfr] Avoid some memory zeroing.
...
* src/pfr/pfrobjs.c (pfr_face_init) : Tweak memory macro.
* src/pfr/pfrload.c (pfr_extra_item_load_stem_snaps,
pfr_phy_font_load): Ditto.
4 years ago
Alexei Podtelezhnikov
b0a281974d
* src/winfonts/winfnt.c (FNT_Face_Init): Tweak memory macro.
4 years ago
Alexei Podtelezhnikov
deee5b7017
[psaux,psnames] Avoid some memory zeroing.
...
* src/psaux/psstack.c (cf2_stack_init): Tweak memory macro.
* src/psnames/psmodule.c (ps_unicodes_init): Ditto.
4 years ago
Alexei Podtelezhnikov
270ff52f62
[base] Avoid some memory zeroing.
...
* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Use FT_QNEW_ARRAY.
* src/base/ftsnames.c (FT_Get_Sfnt_{Name,LangTag}): Ditto.
4 years ago
Alexei Podtelezhnikov
c2d283143a
[bdf,pcf] Avoid some memory zeroing.
...
* src/pcf/pcfread.c (pcf_read_TOC, pcf_get_properties, pcf_load_font):
Tweak memory macros.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Ditto.
* src/bdf/bdflib.c (_bdf_readstreami, bdf_create_property,
_bdf_parse_glyphs, _bdf_parse_start): Ditto.
(_bdf_add_property): Do not handle zero size.
4 years ago
Issam E. Maghni
f998eaf972
* builds/meson/process_ftoption_h.py: Add LF at EOF.
...
This fixes
.../ftoption.h:1030:10: error:
no newline at end of file [-Werror,-Wnewline-eof]
for the generated `ftoption.h` file.
4 years ago
Alexei Podtelezhnikov
c78f78fab4
* src/cff/cffload.c (cff_index_get_pointers): s/FT_QALLOC/FT_ALLOC/.
4 years ago
Alexei Podtelezhnikov
0bd5d95d66
* src/base/ftobjs.c (Mac_Read_POST_Resource): s/FT_ALLOC/FT_QALLOC/.
...
* builds/mac/ftmac.c (FT_New_Face_From_SFNT, read_lwfn): Ditto.
4 years ago