Commit Graph

7297 Commits

Author SHA1 Message Date
Werner Lemberg de9faa53ed configure: Use string comparison for directory inodes.
Inode values might be larger than integers supported by the shell.

Fixes #1105.
2021-10-18 21:05:04 +02:00
Alexei Podtelezhnikov 986d503f4a * 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
2021-10-17 09:14:27 -04:00
Alexei Podtelezhnikov 30ca63d4fb [bdf] Fix up user properties.
Fallout reported as
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40027

* src/bdf/bdflib.c (_bdf_add_property): Cosmetic NULL.
(bdf_create_property): Limit allocations to customary signed
FT_Long and NULL-initialize unused storage.
(bdf_free_font): Do not free unused storage.
2021-10-16 23:02:47 -04:00
Alexei Podtelezhnikov afd1cb2881 * src/sfnt/ttload.c (tt_face_load_name): Accounting fix.
Fallout reported as
  https://crbug.com/40024
2021-10-16 20:25:11 -04:00
Ben Wagner c71eb22dde 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`.
2021-10-15 22:18:38 -04:00
Ben Wagner 8406ae5324 [truetype] Reload context after re-executing `prep`.
When a different hinting mode from the current is selected, the `prep` table
must be re-executed with the new mode.  After this happens the context must
be re-loaded in preparation for the glyph program to be run.

Fixes #1104.

* truetype/ttgload.c (tt_loader_init): Add call to `TT_Load_Context`.
2021-10-15 22:37:31 +02:00
Werner Lemberg 0b92c56c34 [truetype] Minor documentation improvements. 2021-10-15 19:02:41 +02:00
Anurag Thakur 943a6bf7e6 Add clang build to linux CI 2021-10-14 02:00:10 +00:00
Anurag Thakur ede96b239b CI: Add macOS CI, including a clang build 2021-10-12 21:06:41 +05:30
Alexei Podtelezhnikov e294a95ca8 * src/cid/cidload.c (parse_fd_array): Protect against trancation. 2021-10-11 23:25:29 -04:00
Alexei Podtelezhnikov 1029eb9377 [type1] Revert to signed size for binary data.
Recently introduced and reported as
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39838

* src/type1/t1load.c (read_binary_data): Reject negative size.
(parse_subrs, parse_charstrings): Use customary signed size.
2021-10-11 22:25:14 -04:00
Alexei Podtelezhnikov 77bd46e959 [psaux] Signedness revisions.
Unsigned indexes are easier to check.

* src/psaux/cffdecode.c (cff_decoder_parse_charstrings): Updated.
* src/psaux/psintrp.c (cf2_interpT2CharString): Ditto.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Ditto.
* src/type1/t1load.c (read_binary_data): Ditto.
2021-10-10 23:12:12 -04:00
Alexei Podtelezhnikov 3b036820d6 [cid] Signedness revisions.
Unsigned checks are simpler.

* include/freetype/t1tables.h (CID_FaceInfoRec): Change to unsignd
`num_dicts`.
* src/cid/cidparse.h (CID_Parser): Change to unsigned `num_dict`.

* src/cid/cidgload.c (cid_load_glyph): Updated.
* src/cid/cidload.c (cid_load_keyword, parse_fd_array,
parse_expansion_factor, parse_font_name, cid_read_subrs,
cid_face_open): Updated.
* src/cid/cidobjs.c (cid_face_done): Updated.
* src/cid/cidparse.c (cid_parser_new): Updated.
2021-10-10 23:11:10 -04:00
Alexei Podtelezhnikov 012b4f2d48 * src/cid/cidload.c (cid_face_open): Streamline CIDCount check. 2021-10-08 22:14:12 -04:00
Alexei Podtelezhnikov 946df22165 * src/cid/cidload.c (cid_face_open): Streamline SubrCount check. 2021-10-07 22:44:53 -04:00
Alexei Podtelezhnikov 0313a11c4c * src/cid/cidgload.c (cid_load_glyph): Fortify incremental loading. 2021-10-07 22:43:12 -04:00
Alexei Podtelezhnikov 22befeef82 Signedness revisions.
This eliminates explicit casting by switching to unsigned fields.
The revisions mostly impact the handling of CID fonts.

* include/freetype/fttypes.h (FT_Data): Change to unsigned `length`.
* include/freetype/t1tables.h (CID_FaceDictRec): Ditto for `sd_bytes`.
(CID_FaceInfoRec): Ditto for `gd_bytes` and `gd_bytes`.
* include/freetype/internal/tttypes.h (TT_LoaderRec): Ditto for
`byte_len`.

* src/cid/cidgload.c (cid_load_glyph): Updated.
* src/cid/cidload.h (cid_get_offset): Update argument.
* src/cid/cidload.c (cid_get_offset, cid_read_subrs, cid_face_open):
Updated.
* src/cff/cffgload.c (cff_get_glyph_data, cff_free_glyph_data):
Updated.
* src/psaux/psft.c (cf2_getT1SeacComponent): Updated.
* src/truetype/ttgload.c (TT_Process_Composite_Glyph,
load_truetype_glyph): Updated.
2021-10-07 22:41:56 -04:00
Jan Alexander Steffens (heftig) 842ec5ed62 meson.build (gen_docs): Use `current_source_dir` instead of `source_root`.
These two are not equal when FreeType is used as a subproject, such as in
`freetype-demos`.  In that case, `source_root` points at the root project,
causing the docs build to fail.
2021-10-07 12:29:23 +02:00
Alexei Podtelezhnikov 0f23ae2e80 * src/smooth/ftgrays.c (FT_DIV_MOD): Limit the ARM workaround. 2021-10-05 16:28:40 -04:00
Alexei Podtelezhnikov a156040600 [builds/unix, builds/vms] Standardize `mmap` failure.
* builds/unix/ftsystem.c (FT_Stream_Open): Check for MAP_FAILED.
* builds/vms/ftsystem.c (FT_Stream_Open): Ditto.

This should cover https://savannah.nongnu.org/patch/?5909 as well.
2021-10-05 14:19:06 -04:00
Hugh McMaster 467e49e817 autogen.sh: Only copy submodules if building from a git branch.
`autogen.sh` fails if building from a standard source tarball.  Firstly, git
expects to be called in a git repository, then `copy_submodule_files`
blindly attempts to copy files.

Debian, Ubuntu, Linux Mint, and other derivatives all run `autogen.sh`
before compiling to regenerate build files.

This patch ensures that various git commands are only called and 'dlg' files
are only copied if `autogen.sh` is called from a git repository.
2021-10-05 19:44:27 +02:00
Alexei Podtelezhnikov bbab0a675e * include/freetype/internal/ftgloadr.h: Add missing header.
Noticed by Jouk Jansen.
2021-10-04 23:55:46 -04:00
Alexei Podtelezhnikov ec6a458821 [pshinter] Additional clean-ups.
* src/pshinter/pshalgo.h (psh_hint_table_find_strong_points): Streamline code.
* src/pshinter/pshalgo.h (PSH_Glyph): Remove unused fields.
2021-10-04 23:10:59 -04:00
Alexei Podtelezhnikov 227445f613 [pshinter] More convenient direction definition.
It is easier to check directions using flags than integer values.

* src/pshinter/pshalgo.h (PSH_Dir): Redefine directions.
(PSH_PointRec): Use them as an enum type.

* src/pshinter/pshalgo.c (psh_compute_dir): Modify return type.
(psh_glyph_init, psh_hint_table_find_strong_points,
psh_glyph_find_blue_points): Update users.
2021-10-03 22:48:23 -04:00
Alexei Podtelezhnikov d102a51438 [pshinter] Remove unnecessary check.
* src/pshinter/pshalgo.c (psh_hint_table_find_strong_points): Do not
check if direction is defined before checking how.
2021-10-03 22:45:42 -04:00
AnuthaDev 3a65f1a215 CI: Hardcode meson version to fix build failure on windows 2021-10-02 14:11:17 +00:00
Alexei Podtelezhnikov 311764fabb Additional `FT_MSB` macro definitions.
* include/freetype/internal/ftcalc.h [__DECC,_CRAYC]: Use builtins
and intrinsics.
2021-10-01 11:50:12 -04:00
Alexei Podtelezhnikov 68fae526c4 * src/autofit/afhints.c (af_glyph_hints_reload): Decrease casting. 2021-09-30 22:59:04 -04:00
Alexei Podtelezhnikov 1d79c892cf * src/tools/apinames.c: Facilitate OpenVMS linker options. 2021-09-29 22:17:31 -04:00
Alexei Podtelezhnikov dd0ccdc3d3 * src/winfonts/winfnt.c (FNT_Face_Init): Correct reallocation. 2021-09-28 22:57:58 -04:00
Alexei Podtelezhnikov 12ef831fc3 [builds/unix] Do not use autoconf SIZEOF.
* builds/unix/ftconfig.h.in [FT_USE_AUTOCONF_SIZEOF_TYPES]: Removed.
* builds/unix/configure.raw: Remove AC_CHECK_SIZEOF and update.

After this commit, autoconf builds will fully rely on <limits.h>
rather than falling back on it if AC_CHECK_SIZEOF failed for some
reason.  There is a risk that misconfigured cross-compilation might
have wrong headers.  Note that Meson and CMake builds always relied on
<limits.h> for sizes and availability of integer types.
2021-09-24 22:27:27 -04:00
Alexei Podtelezhnikov 766b2c19e2 Propagate sign when reading OFF3.
Signed 24-bit values are extremely rare.  FreeType only reads them in
PFR fonts with bitmap strikes conditionally. They have not been seen
in the known fonts.  That is why this bug could never be discovered.
`FT_FRAME_OFF3` propagates sign correctly.

* include/freetype/internal/ftstream.h (FT_PEEK_OFF3, FT_PEEK_OFF3_LE):
Propagate sign into 32-bit value.
(FT_GET_OFF3, FT_READ_OFF3): Needed fixing but removed as unused.
2021-09-24 22:14:22 -04:00
Alexei Podtelezhnikov a69320a9b2 [bdf] Simplify comment collection or lack thereof.
BDF comments are neither actually collected nor retrieved. There is
no need to be fancy with delimiters.

* src/bdf/bdflib.c (_add_bdf_comment): Delimit comments with zeros...
(bdf_load_font): ...and do not null-terminate comments additionally.
(_bdf_parse_glyphs): Check if comments are kept, which they are not.
(_bdf_parse_start): Minor clean up.
2021-09-24 22:06:44 -04:00
Alexei Podtelezhnikov a29e020059 Use NULL for pointers only.
* src/bdf/bdflib.c (*): Code changes.
* include/freetype/freetype.h: Comments only.
* src/cff/cffload.c, src/cff/cffobjs.c: Ditto.
* src/winfonts/winfnt.c: Ditto.
2021-09-23 23:10:26 -04:00
Werner Lemberg 6d19b29fbc Minor documentation fixes and improvements. 2021-09-23 08:46:01 +02:00
Alexei Podtelezhnikov 3b573e4527 Reference `fopen` in the docs. 2021-09-22 22:22:13 -04:00
Alexei Podtelezhnikov 90b14882ec [bdf, pcf] Minor optimization.
* src/pcf/pcfread.c (pcf_load_font): Do not call `FT_MulDiv` for a
small job.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Ditto.
* src/bdf/bdflib.c (_bdf_parse_glyphs): Fix a comment.
2021-09-22 20:20:04 -04:00
Alexei Podtelezhnikov b4dddd8244 [base] Initialize stream memory earlier.
With Windows memory management tracking heap, it is important to use
it during the stream opening fallback. In Unix, the argument is
unused, but it is better to set it correctly.

* src/base/ftobjs.c (FT_Stream_New): Set memory before calling
`FT_Stream_Open`.
* builds/windows/ftsystem.c, builds/unix/ftsystem.c (FT_Stream_Open,
ft_close_stream_by_free): Call `ft_alloc` and `ft_free` with proper
memory argumment.
2021-09-22 00:30:03 -04:00
Alexei Podtelezhnikov 93866bec77 [builds/windows] Revert back to `CreateFileA` only.
Calling `CreateFileW` without making sure that the patname is really
`wchar_t` is a bad idea and can lead to unpredictable overreads. For
Windows CE, we impelemnt the missing API.

Fixes #1098 and !76 again.

* builds/windows/ftsystem.c (FT_Stream_Open): Call `CreateFileA`.
[_WIN32_WCE] (CreateFileA, FileSizeEx): Implement missing interfaces.
2021-09-21 23:14:42 -04:00
Alexei Podtelezhnikov 892e7eadc9 * src/bdf/bdflib.c (_bdf_parse_{start,glyphs}): Use appropriate scanner. 2021-09-21 14:39:21 +00:00
Alexei Podtelezhnikov 6190360967 Minor. 2021-09-20 22:18:29 -04:00
Alexei Podtelezhnikov 71969d1edf * src/cff/cffdrivr.c (cff_ps_get_font_{info,extra}): Use FT_QNEW. 2021-09-20 14:31:45 -04:00
Alexei Podtelezhnikov 529158983d [cache] Minor clean-ups.
* src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP): Remove parantheses.
* src/cache/ftccache.c (FTC_Cache_Lookup): Ditto.
(FTC_Cache_RemoveFaceID): Remove unnecessary variable.
2021-09-18 07:05:55 -04:00
Alexei Podtelezhnikov 0b429b609c [builds/windows] Try both wide and narrow `CreateFile`
Windows handles wchar_t* UTF-16 and char* ANSI (presently UTF-8)
filenames using alternative -A and -W API. We'll try them both
when opening a file. This means that you should not worry about
about conversions.

Fixes #1098 and !76.

* builds/windows/ftsystem.c (FT_Stream_Open): Call alternative
`CreateFile` in the case of failure.
2021-09-17 08:31:27 -04:00
Edwin Steiner 6e1ef98a04 [cff] Explicitly set StandardEncoding or ExpertEncoding offsets.
Fixes #1097.

* src/cff/cffload.c (cff_encoding_load): Set special offset values.
2021-09-16 23:08:46 -04:00
Alexei Podtelezhnikov fce74b7365 [cache] Miscellaneous clean-ups.
* src/cache/ftccache.c (ftc_get_top_node_for_hash, FTC_Cache_Clear):
Remove barely used variables.
(ftc_cache_add): Adjust casting.
* src/cache/ftccmap.c (FTC_CMapCache_Lookup): Remove casting.
* src/cache/ftcsbits.c (ftc_snode_load): Remove casting.
2021-09-16 17:03:19 -04:00
Alexei Podtelezhnikov 79d14cc256 * src/cff/cffload.c (cff_fd_select_get): Remove casting. 2021-09-16 16:41:56 -04:00
Alexei Podtelezhnikov ae516e6a43 * src/pcf/pcfread.c (pcf_read_TOC): Remove casting. 2021-09-16 16:39:23 -04:00
Alexei Podtelezhnikov 801b7540dc Minor type adjustments.
* src/cff/cffobjs.c (cff_face_init): Reduce casting.
* src/truetype/ttobjs.c (tt_size_ready_bytecode): Ditto.
* src/type1/t1load.c (T1_Set_MM_Design): Ditto.
2021-09-14 22:55:50 -04:00
Alexei Podtelezhnikov 49270c1701 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.
2021-09-14 21:32:43 -04:00