Commit Graph

7394 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov 058f3f2d7d [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.
2021-09-13 16:24:25 -04:00
Alexei Podtelezhnikov 59b43ae663 * src/base/ftobjs.c (FT_CMap_New): Revert to zeroing.
Fixes fallout from c1fa7aa2bc, reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38641
2021-09-13 16:16:18 -04:00
Alexei Podtelezhnikov 073ff2d77e [truetype] Clean up `exec` initialization.
* src/truetype/ttinterp.c (Init_Context): Absorbed into...
(TT_New_Context): ... this function.
2021-09-13 00:04:45 -04:00
Alexei Podtelezhnikov fab94f9fcc [truetype] Avoid some memory zeroing.
* src/truetype/ttgload.c (load_truetype_glyph): Use Q-macro.
* src/truetype/ttinterp.c (Update_Max): Ditto.
* src/truetype/ttpload.c (src/truetype/ttpload.c): Ditto.
2021-09-12 23:30:07 -04:00
Alexei Podtelezhnikov c1fa7aa2bc [base] Avoid some memory zeroing.
* src/base/ftobjs.c (FT_New_Size, FT_CMap_New, FT_CMap_Done,
ft_open_face_internal, ft_open_face_internal): Use Q-macros.
2021-09-12 23:25:46 -04:00
Alexei Podtelezhnikov a8e8d9d7a4 [cache, psaux] Remove zeros.
* src/cache/ftcmru.c (FTC_MruList_New): Remove initialization.
* src/psaux/psstack.c (cf2_stack_init): Ditto.
2021-09-12 23:21:32 -04:00
Alexei Podtelezhnikov 9870b6c07e [cache] Avoid some memory zeroing.
* src/cache/ftcmru.c (FTC_MruList_New): Use Q-macro.
* src/cache/ftcmanag.c (FTC_Manager_RegisterCache): Ditto.
* src/cache/ftccache.c (ftc_cache_init, ftc_cache_resize): Ditto.
2021-09-12 14:32:22 -04:00
Alexei Podtelezhnikov 2d57b05928 * src/cache/ftcmanag.c (FTC_Manager_New): Add missing zero.
Fixes fall out from a7b199d081.
2021-09-11 10:38:08 -04:00
Alexei Podtelezhnikov 5b626281f1 [truetype] Tweak `hdmx` checking.
Fixes #1096.

* src/truetype/ttpload.c (tt_face_load_hdmx): Account for padding.
2021-09-10 10:19:07 -04:00
Alexei Podtelezhnikov e942a31007 [truetype] Tweak `loca` clamping.
Fixes #1095.

* src/truetype/ttpload.c (tt_face_load_loca): Fix up clamping.
* include/freetype/internal/tttypes.h (TT_Face): Correct docs.
2021-09-09 22:17:46 -04:00
Alexei Podtelezhnikov c350aac099 Fortify memory debugging (cont'd).
* src/base/ftdbgmem.c (FT_DumpMemory): Check for active debugger.
(ft_mem_table_destroy): Move `FT_DumpMemory` call from here...
(ft_mem_debug_done): ... to here.
2021-09-08 12:18:23 -04:00
Alexei Podtelezhnikov 63806aad9f Fortify memory debugging.
These changes are neccessary to properly recover `memory->user` that
holds the Windows heap handle now.

* src/base/ftdbgmem.c (ft_mem_debug_init): Handle all table allocations,
initializations, and sizing instead of...
(ft_mem_table_new): ... this function removed.
(ft_mem_debug_done): Better check for the active debugger and free the
debugger table here instead of...
(ft_mem_table_destroy): ... here.
2021-09-08 10:54:44 -04:00
Werner Lemberg 77dcc5ed6a src/tools/ftrandom/ftrandom.c (_XOPEN_SOURCE): Set to 600.
This allows C99 compilation on Solaris.

Problem reported by Mojca Miklavec.
2021-09-07 18:51:53 -07:00
Alexei Podtelezhnikov 7e26c7a6da [builds/windows] Use native memory allocation API.
* builds/windows/ftsystem.c (ft_alloc, ft_realloc, ft_free):
Wrap HeapAlloc, HeapReAlloc, and HeapFree.
(FT_New_Memory): Set the heap handle.
2021-09-07 17:06:27 -04:00
Werner Lemberg 60a93ea231 [dlg] Synchronize with upstream.
* src/dlg/dlgwrap.c (_XOPEN_SOURCE): Set to 600.

Fixes #1093.
2021-09-07 06:40:55 -07:00
Alexei Podtelezhnikov aee1fd3bb8 Cosmetic zeros. 2021-09-03 22:13:22 -04:00
Alexei Podtelezhnikov 7bf655b228 * src/bdf/bdflib.c (_bdf_parse_start): Keep parser memory. 2021-09-03 11:31:41 -04:00
Werner Lemberg d1d3dc0235 autogen.sh: Make it work with old Solaris 10 shell. 2021-09-02 22:12:07 -07:00
Alexei Podtelezhnikov 7f8f0c1c70 [smooth, raster, sdf] Clean up initialization calls.
* src/raster/ftraster.c (ft_black_init): Removed.
(ft_black_new): Clean up.
* src/sdf/ftbsdf.c (bsdf_raster_new): Ditto.
* src/sdf/ftsdf.c (sdf_raster_new): Ditto.
* src/smooth/ftgrays.c (gray_raster_new): Ditto.
2021-09-02 23:30:31 -04:00
Alexei Podtelezhnikov a7b199d081 * src/cache/ftcmanag.c (FTC_Manager_New): Avoid some zeroing. 2021-09-02 22:58:50 -04:00
Alexei Podtelezhnikov 0a6f0f8fed * src/bdf/bdflib.c (bdf_load_font): Remove memory shuffling. 2021-09-02 22:52:21 -04:00
Alexei Podtelezhnikov a81cf5aade Cosmetic zeros. 2021-09-02 22:10:57 -04:00
Alexei Podtelezhnikov 7482c98f15 [base] Clean up stream reading.
* src/base/ftstream.c (FT_Stream_ReadUShort, FT_Stream_ReadUOffset,
FT_Stream_ReadULong and their LE variants): Remove unnecessary
initialization and slightly refactor.
(FT_Stream_GetByte, FT_Stream_ReadByte): Rename to return unsigned
value and align with sister functions.

* include/freetype/internal/ftstream.h (FT_Stream_GetByte,
FT_Stream_ReadByte): Update prototypes and caller macros.
2021-09-01 22:18:29 -04:00
Alexei Podtelezhnikov 612925ff22 s/0/NULL/ where appropriate. 2021-09-01 21:37:21 -04:00
Alexei Podtelezhnikov efa1a35907 * builds/windows/ftsystem.c (FT_Stream_Open): Fix double-close. 2021-08-30 09:38:25 -04:00
Alexei Podtelezhnikov b6c11d494e [smooth] Reduce shift in multiply-shift optimization.
* src/smooth/ftgrays.c (FT_UDIVPREP, FT_UDIV): Reduce shift.

Smaller shifts that keep the division operands of FT_UDIVPREP within
32 bits result in slightly faster divisions, which is noticeable in
the overall performance.  The loss of precision is tolerable until the
divisors (the components dx and dy) approach 32 - PIXEL_BITS. With
PIXEL_BITS = 8, this corresponds to 65,000 pixels or the bitmap size
that we refuse to render anyway.

Using `ftbench -p -s60 -t5 -bc timesi.ttf`,

Before: 8.52 us/op
After:  8.32 us/op
2021-08-30 07:09:53 -04:00
Werner Lemberg d1c2000504 [truetype] Fix compilation if !TT_CONFIG_OPTION_BYTECODE_INTERPRETER.
* src/truetype/ttgxvar.c (tt_cvt_ready_iterator): Compile function
conditionally.
(tt_face_vary_cvt) [!TT_CONFIG_OPTION_BYTECODE_INTERPRETER]: Add code.

Fixes #1091.
2021-08-28 07:36:08 +02:00
Alexei Podtelezhnikov 6804ce2986 [builds/windows] Revise SSE2 settings.
* builds/windows/vc2010/freetype.vcxproj [x64]: Remove explicit SSE2.
* builds/windows/visualc/freetype.vcproj [Win32]: Add explicit SSE2.
2021-08-27 09:46:40 -04:00
Ben Wagner a842a0984b [smooth] Detect SSE2 with MSVC for x86
MSVC does not set `__SSE2__`. Instead one must check whether `_M_IX86_FP` is
defined and greater than or equal to 2.

* src/smooth/ftgrays.c (FT_SSE2): New macro.
Use it where appropriate.
2021-08-27 09:20:26 +02:00
Alexei Podtelezhnikov 3785393d1a Expand comment (cont'd). 2021-08-26 15:31:11 +00:00
Alexei Podtelezhnikov 686e2a5eb3 Expand comment. 2021-08-25 23:18:43 +00:00
Alexei Podtelezhnikov f7f9cb0dde * src/smooth/ftgrays.c (gray_render_conic): Refactor redundancy. 2021-08-24 15:29:06 -04:00
suzuki toshiya 5031835790 [truetype] Fix for the family name shorter than 8 characters.
* src/truetype/ttobjs.c (tt_skip_pdffont_random_tag):
If the family name to be checked is shorter than 8 characters,
do not check its syntax.
2021-08-25 00:31:26 +09:00
suzuki toshiya c4fc0e690c [truetype] Simplify `trick_names'.
* src/truetype/ttobjs.c (tt_check_trickyness_family): For the case
that the beginning part of a long tricky family name is already
registered as another tricky family name, no need to double-check
the longer one.  Such long tricky family names are removed from
the `trick_names'.
2021-08-24 16:58:11 +09:00
suzuki toshiya 992382ba29 [truetype] Add 2 tricky font names.
Additional fix for the issue #1087.

* src/truetype/ttobjs.c (tt_check_trickyness_family): Add 2 tricky
font names reported in #1087.
2021-08-24 16:51:54 +09:00
suzuki toshiya 2b3ccd6e26 [truetype] New function to skip the randomization tag.
* src/truetype/ttobjs.c (tt_skip_pdffont_random_tag):
New function to skip the randomization tag in the names of the
fonts embedded in a PDF.  It is used by tt_check_trickyness_family(),
to keep from mistaking "DLC" in the randomization tag as a
tricky font name. See discussion in:

https://lists.nongnu.org/archive/html/freetype-devel/2021-02/msg00002.html

For technical detail about the randomization tag, please find
PDF Reference 5.5.3 "Font Subsets".  Thanks to Justyna Wawrzynska
for pointing out the issue caused by the randomization tag.
2021-08-24 16:49:34 +09:00
suzuki toshiya 1c23982dd2 [truetype] Add checksums for 2 tricky fonts.
Thanks to Ting717 for providing sample PDF. Fixes #1087.

* src/truetype/ttobjs.c (tt_check_trickyness_sfnt_ids): Add
checksums for 2 tricky fonts `DFHei-Bd-WIN-HK-BF' and
`DFMing-Md-WIN-HK-BF'.
2021-08-24 16:46:06 +09:00
Alexei Podtelezhnikov 78f2bd0bd3 Whitespace formatting. 2021-08-22 22:32:07 -04:00
Alexei Podtelezhnikov d92aa23fd7 Decorate const arguments.
* src/base/ftglyph.c (FT_Glyph_Transform, FT_Glyph_To_Bitmap): Do it.
* include/freetype/ftglyph.h (FT_Glyph_Transform, FT_Glyph_To_Bitmap):
Do it.
2021-08-22 13:12:45 -04:00
Alexei Podtelezhnikov d62d583d92 [smooth] Clean up the null cell usage.
Put the null cell at the end of the pool and store it explicitly so that
we can use it as both the limit and the dumpster.

* src/smooth/ftgrays.c (gray_TWorker): Store the last `cell_null` and
remove unnecesary fields.
(NULL_CELL_PTR, CELL_IS_NULL): Remove in favor of explicit `cell_null`.
(gray_dump_cells, gray_set_cell, gray_sweep{,_direct}): Update callers.
(gray_convert_glyph_inner): Trace remaining cells (oh well).
(gray_convert_glyph): Set up `cell_null` and slightly improve the pool
management.
2021-08-20 23:40:49 -04:00
Alexei Podtelezhnikov 6e9d8d314f [base] Restore quiet no-op rendering of bitmap glyphs.
Fixes #1076.

* src/base/ftobjs.c (FT_Render_Glyph_Internal): Discard an error when
rendering a bitmap glyph.
2021-08-20 16:01:32 -04:00
Alexei Podtelezhnikov de3b5c201c [smooth] Fortify 64-bit algorithm.
* src/smooth/ftgrays.c (FT_UDIVPREP, FT_UDIV): s/long/FT_Int64/ and
s/unsigned long/FT_UInt64/.
(gray_render_line): Adjust a critical variable type.
2021-08-20 13:51:40 -04:00
Carlo Bramini f0f00f7c16 * builds/windows/ftsystem.c (FT_Stream_Open): Support legacy Windows. 2021-08-19 22:14:42 -04:00
Alexei Podtelezhnikov ffdac8d67e Determine `long long` availability based on its size.
MSVC, for example, used `long long` even without full C99 support.

* include/freetype/config/ftstdlib.h: Check if `long long` limits are
defined in <limits.h>.
* include/freetype/config/integer-types.h: Check `long long` size and
use it to typedef FT_Int64.
2021-08-19 20:41:55 -04:00
Dominik Röttsches 633fe08764 [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.
2021-08-19 21:35:08 +00:00
Alexei Podtelezhnikov 02ba0fc81e Readily use `long long` as a 64-bit type in C99 mode.
* include/freetype/config/integer-types.h (FT_INT64):
FT_CONFIG_OPTION_FORCE_INT64 is no longer required to use `long long`.
2021-08-18 23:27:48 -04:00
Alexei Podtelezhnikov 857038399a Use FT_INT64 instead of FT_LONG64.
* include/freetype/config/integer-types.h: Remove synonymous FT_LONG64.
* include/freetype/internal/ftcalc.h: s/FT_LONG64/FT_INT64/.
* src/base/ftcalc.c: Ditto.
* src/base/fttrigon.c: Ditto.
* src/smooth/ftgrays.c: Ditto.
2021-08-18 23:05:51 -04:00
Alexei Podtelezhnikov e2cceed857 [builds/windows] Do not set CharacterSet for VC++.
* builds/windows/vc2010/freetype.vcxproj: s/Unicode/NotSet/.
* builds/windows/visualc/freetype.vcproj: s/"1"/"0"/.
2021-08-18 11:36:33 -04:00
Werner Lemberg f44c2d5860 * src/sdf/ftsdf.c (get_control_box): Fix compiler warning. 2021-08-18 08:52:21 +02:00
Werner Lemberg f11f3ed15b [base] Fix ppem size overflow.
Fixes #1086.

* src/base/ftobjs.c (FT_Request_Metrics): Add return value.
Check whether ppem values fit into unsigned short values.
(FT_Request_Size): Updated.

* include/freetype/internal/ftobjs.h: Updated.

* src/cff/cffobjs.c (cff_size_request), src/cid/cidobjs.c
(cid_size_request), src/truetype/ttdriver.c (tt_size_request),
src/type1/t1objs.c (T1_Size_Request): Updated.
2021-08-18 07:27:02 +02:00