Commit Graph

5075 Commits

Author SHA1 Message Date
Werner Lemberg e1f364e509 [woff2] Fix memory leak.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28148

* src/sfnt/sfwoff2.c (woff2_open_font): Reject fonts that have
multiple tables with the same tag.  While not explicitly forbidden
in the OpenType specification, it is implicitly forbidden by
describing a binary search algorithm for tables that only works
reliably if table tags are unique.
2021-02-25 20:00:07 +01:00
Werner Lemberg df7fcafe6e * CMakeLists.txt: Update location of `LICENSE.TXT`.
Fixes #1035.
2021-02-22 15:33:23 +01:00
Werner Lemberg 111f2f27b5 * builds/unix/ax_pthread.m4: Update from 'autoconf-archive'.
A bunch of fixes were added recently to its git repository.
2021-02-19 20:33:50 +01:00
Werner Lemberg eca35e04fc [unix] Updates for autoconf 2.71.
This fixes warnings reported by autoupdate.

* builds/unix/ax_pthread.m4: Replace `as_echo` with `AS_ECHO`.

* builds/unix/configure.raw: Remove obsolete `AC_HEADER_STDC`.
Don't escape back quotes in messages for `AC_MSG_WARN`.
2021-02-17 21:10:34 +01:00
Werner Lemberg 635d394fe3 * builds/toplevel.mk: Fix previous commit.
<top_level>: Use `TOP_DIR` in `wildcard` function.
(check_out_submodule, copy_submodule): Move down to come after
definition of `all` rule.
Call `mkdir` conditionally.
2021-02-16 19:24:15 +01:00
Werner Lemberg c3a0b43ec6 * builds/toplevel.mk: Use rules for handling 'dlg'.
Suggested by Alexei.

(check_out_submodule, copy_submodule): New targets.
<top-level>: Replace calls to `shell` with rules.
2021-02-16 17:04:51 +01:00
Werner Lemberg dfa7cca5f3 * builds/toplevel.mk: Avoid side effects of `shell`.
We use a dummy variable to catch its output.  Otherwise the `make`
program is going to interpret the return value of `shell`; this can
cause obscure warning or error messages or even be harmful.
2021-02-16 14:29:45 +01:00
Werner Lemberg 92bd99bd25 Move 'dlg' submodule to `subprojects` directory.
This is for future changes with Meson, which doesn't allow a
different name for its `subprojects` directory.  Having both a
`submodules` and a `subprojects` directory is confusing.

* .gitmodules, autogen.sh (copy_submodule_files, DLG_INC_DIR,
DLG_SRC_DIR): Updated.

* builds/toplevel.mk (<top-level>, do-dist),
builds/windows/vc2010/script.bat: Updated.

* src/tools/no-copyright: Updated.
2021-02-16 14:07:18 +01:00
Dominik Röttsches 215ae25330 [sfnt] Update paint format values to support non-variable paints.
* freetype.h (FT_PaintFormat): Update paint format identifiers after
a specification change.  The specification was updated to have
sibling formats, variable and non-variable variants for each.
Reflect that here.

* sfnt/ttcolr.c (read_paint): Remove parsing of variable indices as
the non-variable formats no longer have them.
2021-02-16 13:15:41 +01:00
Daniel E b2aeca5fda * CMakeLists.txt: Improve 'bz2' support.
Not all distributions such as FreeBSD provide a `.pc` file for
'(lib)bz2' so follow autotools and add it to `Libs.private` instead.
2021-02-15 09:09:09 +01:00
Werner Lemberg 7849316ccf * src/tools/update-copyright-year: Fix single-year entry handling.
The fix from 2021-01-17 didn't cover the case where the year to be
updated is identical to the current year.
2021-02-13 09:21:37 +01:00
Werner Lemberg d51452e3ec Add new function `FT_Get_Transform`.
See

  https://github.com/harfbuzz/harfbuzz/issues/2428

for some reasons to introduce this function.

* include/freetype/freetype.h, src/base/ftobjs.c (FT_Get_Transform):
Implement it.
2021-02-13 08:52:58 +01:00
Werner Lemberg d93a011933 Minor editing of last commit; formatting. 2021-02-13 07:50:04 +01:00
Alexei Podtelezhnikov 70fd20e67e Decorate qsort callbacks with cdecl.
* include/freetype/internal/compiler-macros.h (FT_COMPARE_DEF):
Add new macro.
* src/base/ftrfork.c, src/bdf/bdflib.c, src/gxvalid/gxvcommn.c,
src/psaux/afmparse.c, src/psnames/psmodule.c, src/type1/t1afm.c,
src/sfnt/sfwoff.c, src/sfnt/sfwoff2.c: Update qsort callbacks.

Fixes #1026 when compiling FreeType with an unusual calling convention
while the C library qsort still expects cdecl.
2021-02-12 19:28:05 -05:00
Dominik Röttsches 54c5ad5c92 [sfnt] Implement 'COLR' v1 sweep gradients.
* freetype.h (FT_PaintSweepGradient): Add `FT_PaintSweepGradient` to
represent a 'COLR' v1 sweep gradient.
Update format.
(FT_PaintFormat): Update shifted paint formats.
Sync with spec.
* sfnt/ttcolr.c (read_paint): Logic to parse sweep gradients.
Fix struct access in radial gradient implementation.
2021-02-11 14:20:03 +01:00
Dominik Röttsches 64f01bfedd [sfnt] Provide optional root transform for 'COLR' v1 glyph graph.
* include/freetype/freetype.h (FT_Get_Color_Glyph_Paint):
Additional function argument root_transform to control whether
root transform should be returned.
(FT_OpaquePaint): Additional tracking field to denote whether
root transform is to be returned.
* include/freetype/internal/sfnt.h
(TT_Get_Color_Glyph_Paint_Func): Propagate additional argument.
* src/base/ftobjs.c (FT_Get_Color_Glyph_Paint): Ditto.
* src/sfnt/ttcolr.c (tt_face_get_colr_glyph_paint): Return root
transform reflecting the size and tranform configured on
FT_Face.
(read_paint): Initialize and track status of insert_root_transform
flag.
2021-02-10 18:51:04 +01:00
Xavier Claessens cc90307d71 * meson.build: s/freetype2_dep/freetype_dep/.
Many projects (e.g., fontconfig, cairo) hardcode the `freetype_dep`
variable name to use FreeType as subproject because that was the
variable name in Centricular's Meson port of FreeType.  While they
should stop hardcoding that variable name, it does not cost us
anything to keep using that name to ease transition.
2021-02-10 18:14:47 +01:00
Xavier Claessens 3dbdb78a25 [meson] Fix handling of HarfBuzz library.
* meson.build (harfbuzz_dep): Do not fall back to HarfBuzz by
default.

Otherwise it causes a dependency cycle:

  cairo => fontconfig => freetype2 => harfbuzz => cairo

Meson will still fall back to HarfBuzz subprojects if the `harfbuzz`
option is set to `enabled` instead of `auto` and a
`subprojects/harfbuzz.wrap` file is present.  In that case it is the
responsibility of the main project to set the proper options on each
subproject to break the dependency cycle.

Fixes: #1028.
2021-02-10 18:10:59 +01:00
Xavier Claessens 2c40559609 Meson: Fix dependency lookup and generate ftconfig.h
[meson] Fix dependency lookup and generate `ftconfig.h`.

- zlib: If not found on the system, meson can build it as a
  subproject.  We thus never use the (outdated) zlib support that
  comes with FreeType.  Doing so has the additional advantage that
  the zlib code can be shared with other projects like GLib if both
  are subprojects of an application.
- harfbuzz: Build as a subproject if not found on the system.
- 'QUESTION: What if the compiler doesn't support `-D` but uses `/D`
  instead as on Windows?'  Answer: Meson translate arguments for us.
- visibility: Replace self-made code with meson-specific solution.

* meson.build (ft2_defines): Rewrite logic to set and handle it.
(process_header_command): New variable, previously called
`ftoption_command`.
(ftoption_command, ftconfig_command): New variables.
(zlib_option): Removed.
(zlib_dep): New variable.
(ft2_deps): Updated.
(harfbuzz_dep): Updated.
(ftconfig_h_in, ftconfig_h): New variables.
(ft2_sources): Updated.
(ft2_lib): Updated, handle visibility.
(summary): Updted.

* meson_options.txt (zlib): Updated.
2021-02-09 16:11:39 +01:00
Xavier Claessens e11cc40a2e * meson.build: Fix resource compilation on Windows.
This is copied from GStreamer's meson port of FreeType.

(ft2_sources): Add both debug and resource file (the latter for
Windows only).
(ft2_debug_src): Removed.
2021-02-09 16:11:39 +01:00
Xavier Claessens 69e0faa893 * meson.build: s/ft2_libtool_version/ft2_pkgconfig_version/.
(freetype2_dep): Use it.

`ft2_libtool_version` would be the shared library version, not the
one we should use in file `freetype2.pc`.
2021-02-09 16:11:39 +01:00
Xavier Claessens 0565c5ba2b * meson.build: Use `meson.override_dependency`.
This is a new meson mechanism to avoid other projects to hard-code
the `freetype2_dep` variable name in their build definition.  It
also ensures that meson does not mix system and subproject versions
of FreeType inside of the same project.

Also remove outdated TODO because `declare_dependency` was already
there.
2021-02-09 16:11:39 +01:00
Xavier Claessens 5c81e09b17 * meson.build (bzip2_dep): Simplify.
We remove `static:false` from `find_library('bz2')`.

I don't know whether the previous code was a workaround for an old
meson bug, but at least with version >=0.55.0 (which FreeType uses)
it picks the shared library when both are available.

With this commit, file `freetype2.pc` no longer contains the full path to
file `libbz2.so`; instead, it correctly uses `-lbz2`.  Note that this is a
meson bug is still present in the current version (0.57.0).
2021-02-09 16:09:04 +01:00
Xavier Claessens 1b69fb9bdb * meson.build: Set project version. 2021-02-09 15:54:54 +01:00
Werner Lemberg 947e475283 [base] Fix Netpbm tracing message.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): Don't emit Netpbm
warning if there is nothing to output.
2021-02-04 10:19:26 +01:00
Werner Lemberg d924a66a5c * src/*: Don't use more than one '\n' in `FT_TRACE` and `FT_ERROR`.
This ensures good logging output, with all lines having a proper
prefix (if requested).

This is a continuation of a similar patch from 2020-12-02, which
missed some locations.
2021-02-04 07:46:46 +01:00
Alexei Podtelezhnikov fd7f92b6f0 * builds/unix/configure.raw [mmap]: Restore default path.
Fixes #1023.
2021-02-03 14:44:14 -05:00
Werner Lemberg 0636dc8af1 [psaux] Fix integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30154

* src/psaux/psblues.c (cf2_blues_capture): Use `SUB_INT32`.
2021-02-03 19:16:02 +01:00
Alexei Podtelezhnikov d3befe1c72 * builds/unix/configure.raw [mmap support]: Explicitly handle Windows.
Fixes #1024.
2021-02-02 23:02:54 -05:00
Werner Lemberg 5635d5edc4 * builds/unix/configure.raw [mmap support]: Correctly handle Windows.
Fixes #1024.
2021-02-02 10:33:53 +01:00
Werner Lemberg 4554c6da42 * builds/windows/ftdebug.c: Synchronize with `src/base/ftdebug.c`. 2021-01-31 17:17:40 +01:00
Werner Lemberg 324612ceb2 Always provide logging API.
It's easier to have stubs if FT_DEBUG_LOGGING is undefined than to
modify `ftexport.sym` conditionally.

Problem reported by Alexei.

* src/base/ftdebug.c: Include `ftlogging.h`.

(FT_Trace_Set_Level, FT_Trace_Set_Default_Level, FT_Set_Log_Handler,
FT_Set_Default_Log_Handler) [!FT_DEBUG_LOGGING]: Provide stubs.
2021-01-31 14:28:44 +01:00
Werner Lemberg 939e844468 * builds/unix/configure.raw: Fix typo.
Bug introduced in Vincent's last commit bb33f03.

Fixes issue #1021.
2021-01-30 06:32:38 +01:00
Alexei Podtelezhnikov 7ae5609dbe * src/base/ftstroke.c (FT_Stroker_EndSubPath): Ignore tiny gaps.
Fixes bug #1020.
2021-01-27 16:08:08 -05:00
Alexei Podtelezhnikov 4c3bd2ab93 [stroker] Minor clean-up.
* src/base/ftstroke.c (FT_Stroker_{ConicTo,CubicTo}): Reset the last
line length.
(FT_Stroker_EndSubPath): Call `ft_stroker_process_corner'.
2021-01-27 15:54:34 -05:00
Werner Lemberg 601c5a611e Improve ChangeLog entry for last commit. 2021-01-27 13:04:55 +01:00
Vincent Torri bb33f03a71 * builds/windows/ftsystem.c: Add shared memory support on Windows. 2021-01-27 06:43:41 -05:00
Werner Lemberg c7cc947c0f Minor documentation fixes. 2021-01-23 15:45:10 +01:00
Werner Lemberg 209e9841f2 Require HarfBuzz 2.0.0.
This is needed to make commit f1f9705f9 work.

* CMakeLists.txt (HARFBUZZ_MIN_VERSION), builds/unix/configure.raw
(harfbuzz_pkg), meson.build (harfbuzz_dep): Updated.
2021-01-23 14:15:29 +01:00
Alexei Podtelezhnikov 8dc311320c * autogen.sh: Absorb `version.sed'.
* version.sed: Removed.
2021-01-22 20:27:15 -05:00
Alexei Podtelezhnikov b594cd90bd * srd/base/ftlcdfil.c (FT_Library_SetLcdGeometry): Fix return value. 2021-01-19 07:35:38 -05:00
Nikolaus Waxweiler f1f9705f93 [afshaper] Fix hb_ot_tags_from_script deprecation warning.
* autofit/afshaper.c (af_shaper_get_coverage): Copy the source code
of the function as suggested in
https://github.com/harfbuzz/harfbuzz/issues/2737 and adjust to handle
at most three tags.
2021-01-17 17:33:50 +00:00
Werner Lemberg d35c7f7cba * src/tools/update-copyright-year: Fix single-year entry handling. 2021-01-17 08:44:00 +01:00
Werner Lemberg b6e8a71266 Update all copyright notices. 2021-01-17 07:18:48 +01:00
Alexei Podtelezhnikov 4e7a01840d * builds/unix/unixddef.mk: Remove the second DEVEL_DIR definition. 2021-01-16 12:04:35 -05:00
Werner Lemberg ba1a6acf28 [sfnt] Additional checks for 'colr' table presence.
* sfnt/ttcolr.c (tt_face_get_colr_glyph_paint,
tt_face_get_colorline_stops, tt_face_get_paint): Additional checks
for whether colr table is present.  Prevents crashes when these
methods are called on non-COLR fonts.
2021-01-15 10:09:00 +01:00
Dominik Röttsches 53fea87745 Add config option to test for 'COLR' v1 support in headers.
* include/freetype/config/ftoption.h (TT_SUPPORT_COLRV1): New macro
so that clients can test whether the FreeType checkout that they are
building against supports the 'COLR' v1 API.  This is intended to be
a temporary solution until 'COLR' v1 support is released in a
FreeType version and such a check can be made by using the version
number instead.
2021-01-14 16:06:03 +01:00
Dominik Röttsches 4b58cf47cc [base] Fill 'COLR' v1 API templates to make them work (#59703).
* src/base/ftobjs.c (FT_Get_Color_Glyph_Paint, FT_Get_Paint_Layers,
FT_Get_Paint, FT_Get_Colorline_Stops): Add basic sanity checks,
check for existence of `FT_Face`, check arguments and delegate calls
for the respective 'COLR' v1 API to the SFNT driver.
2021-01-14 15:56:04 +01:00
Dominik Röttsches d3e95d97a0 [sfnt] Register 'COLR' v1 API in driver (#59703).
* include/freetype/internal/sfnt.h (TT_Get_Color_Glyph_Paint_Func,
TT_Get_Paint_Layers_Func, TT_Get_Colorline_Stops_Func,
TT_Get_Paint_Func): New function pointer types.
(SFNT_Interface): Add them.
(FT_DEFINE_SFNT_INTERFACE): Updated.

* src/sfnt/sfdriver.c (PUT_COLOR_LAYERS_V1): New macro.
(sfnt_interface): Add new function pointers.
2021-01-14 15:56:04 +01:00
Dominik Röttsches 6260b4901c [sfnt] Add 'COLR' v1 API to retrieve color layers (#59703).
* src/sfnt/ttcolr.c (tt_face_get_paint_layers): New function to get
the layers of a `PaintColrLayers` table in the font, using an
`FT_LayerIterator` from an `FT_PaintColrLayers` object retrieved via
`tt_face_get_paint`.

* src/sfnt/ttcolr.h: Updated.
2021-01-14 15:56:04 +01:00