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.
2021-05-29 09:51:04 +02:00
Werner Lemberg
2bfdc161fb
[build] Allow overriding of `ANSIFLAGS` for GNU make build.
...
* builds/*: Implement it.
2021-05-29 00:27:40 +02:00
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.
2021-05-27 11:38:56 -04:00
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.
2021-05-25 11:27:56 +02:00
Alexei Podtelezhnikov
16947c0eb1
* meson.build (ft2_public_headers): Add missing `ftcid.h'.
...
Fixes #1058 .
2021-05-23 05:36:16 -04:00
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.
2021-05-20 22:20:36 -04:00
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.
2021-05-19 21:53:21 +01:00
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`.
2021-05-19 09:07:33 +02:00
Alexei Podtelezhnikov
81852fbccc
Prioritize the anti-aliasing renderer module.
...
* modules.cfg: Reorder the renderers.
* include/freetype/config/ftmodule.h: Ditto.
2021-05-18 22:18:17 -04:00
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".
2021-05-16 23:12:01 -04:00
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'.
2021-05-13 23:08:31 -04:00
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.
2021-05-12 17:24:35 -04:00
Alexei Podtelezhnikov
c653b8d2f1
* src/smooth/ftgrays.c (FT_GRAY_SET): Adjust for better code.
2021-05-12 16:17:21 -04:00
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.
2021-05-12 00:04:59 -04:00
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.
2021-05-10 22:06:01 -04:00
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.
2021-05-07 19:17:48 -04:00
Alexei Podtelezhnikov
2f62d8e075
* src/bdf/bdflib.c (_bdf_list_ensure): Tweak allocation macro.
2021-05-07 09:33:41 -04:00
Alexei Podtelezhnikov
79ed536d01
* src/psaux/psobjs.c (ps_parser_load_field): Tweak allocation macro.
2021-05-06 23:46:46 -04:00
Alexei Podtelezhnikov
44c59414eb
* src/sfnt/sfobjs.c (sfnt_load_face): Tweak allocation macro.
2021-05-06 22:54:03 -04:00
Alexei Podtelezhnikov
998c7c0f1c
* src/cid/cidload.c (cid_read_subrs): Tweak allocation macro.
2021-05-06 22:51:37 -04:00
Alexei Podtelezhnikov
2d95784885
* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Tweak allocation.
2021-05-06 22:49:13 -04:00
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.
2021-05-05 23:30:46 -04:00
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
2021-05-04 08:56:10 +02:00
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.
2021-05-03 22:40:16 -04:00
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.
2021-05-02 18:30:22 -04:00
Alexei Podtelezhnikov
d911cb5392
* src/cid/cidload.c (cid_read_subrs): Tweak allocaton macro.
2021-05-01 23:49:11 -04:00
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.
2021-05-01 12:46:44 -04:00
Alexei Podtelezhnikov
b8968d666e
* src/sfnt/ttpost.c (load_format_{20,25}): Tweak allocaton macros.
2021-05-01 12:24:44 -04:00
Alexei Podtelezhnikov
2583b6085e
* src/sfnt/pngshim.c (Load_SBit_Png): Tweak allocaton macro.
2021-05-01 09:22:26 -04:00
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.
2021-05-01 09:14:04 -04:00
Alexei Podtelezhnikov
c177cc354d
[woff2] Avoid some memory zeroing.
...
* src/sfnt/sfwoff2.c (store_loca, woff2_open_font): Tweak macros.
2021-05-01 09:09:52 -04:00
Alexei Podtelezhnikov
4e1c6a12e5
* src/gzip/ftgzip.c (ft_gzip_alloc): Zero out memory again.
2021-04-30 09:35:21 -04:00
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.
2021-04-27 11:39:58 -04:00
Alexei Podtelezhnikov
c213c8a9bb
* src/cid/cidgload.c (cid_load_glyph): Restore the glyph_length check.
2021-04-27 08:54:19 -04:00
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
2021-04-27 13:28:35 +02:00
Alexei Podtelezhnikov
caff87b1f9
* src/sfnt/sfobjs.c (sfnt_init_face): Revert macro change.
2021-04-26 22:45:40 -04:00
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.
2021-04-26 17:21:51 -04:00
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.
2021-04-26 17:14:28 -04:00
Alexei Podtelezhnikov
b0a281974d
* src/winfonts/winfnt.c (FNT_Face_Init): Tweak memory macro.
2021-04-26 17:10:28 -04:00
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.
2021-04-26 17:07:44 -04:00
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.
2021-04-25 23:40:59 -04:00
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.
2021-04-25 23:33:15 -04:00
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.
2021-04-25 20:30:43 +02:00
Alexei Podtelezhnikov
c78f78fab4
* src/cff/cffload.c (cff_index_get_pointers): s/FT_QALLOC/FT_ALLOC/.
2021-04-24 22:38:48 -04:00
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.
2021-04-23 22:04:05 -04:00
Alexei Podtelezhnikov
e6e5b67db3
* src/sdf/ftsdf.c (sdf_{edge,contour,shape}_new): Use FT_QALLOC.
2021-04-23 21:33:03 -04:00
Alexei Podtelezhnikov
6ada59ab7c
[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.
2021-04-23 19:22:51 -04:00
Alexei Podtelezhnikov
ec9e5114b1
[cff,type1,type42] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
...
* src/cff/cffload.c (cff_index_get_pointers, cff_index_get_name):
Do not zero out the buffer.
* src/cff/cffdrivr.c (cff_ps_get_font_info): Ditto.
* src/type1/t1load.c (parse_subrs, parse_charstrings,
parse_blend_axis_types): Ditto.
* src/type1/t1parse.c (T1_New_Parser, T1_Get_Private_Dict): Ditto.
* src/type42/t42parse.c (t42_parser_init): Ditto.
2021-04-23 14:03:03 -04:00
Alexei Podtelezhnikov
baa0f71ddf
[cid] s/FT_ALLOC/FT_QALLOC/ and clean up.
...
* src/cid/cidgload.c (cid_load_glyph): Do not zero out the buffer.
* src/cid/cidload.c (cid_face_open, cid_read_subrs): Ditto.
2021-04-23 13:48:34 -04:00
Alexei Podtelezhnikov
b3438ccb31
[pfr] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
...
* src/pfr/pfrload.c (pfr_extra_item_load_font_id, pfr_aux_name_load):
Do not zero out the buffer.
2021-04-23 08:35:02 -04:00