Commit Graph

7359 Commits

Author SHA1 Message Date
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
Alexei Podtelezhnikov 536a10aca8 * builds/windows/ftsystem.c (FT_Stream_Open): Cast to remove warning. 2021-08-17 22:24:46 -04:00
Alexei Podtelezhnikov 5116f12963 * builds/windows/ftsystem.c (FT_Stream_Open): Support UNICODE compilation. 2021-08-17 22:08:45 -04:00
Werner Lemberg fed5521016 * src/sfnt/ttcolr.c (tt_face_get_color_glyph_clipbox): Minor fix. 2021-08-09 19:27:34 +02:00
Dominik Röttsches e40ae7569a [sfnt] Add missing blend mode 'plus' to 'COLR' v1.
* include/freetype/ftcolor.h (FT_Composite_Mode): Add missing blend mode
'plus' after it was added to the spec.
2021-08-09 19:25:26 +02:00
Werner Lemberg 2c853b38a7 include/freetype/freetype.h (FT_Encoding): Improve documentation.
Based on a suggestion by Antony Lee <anntzer.lee@gmail.com>.
2021-08-08 00:22:34 +02:00
Werner Lemberg 18fc64e6a3 [smooth] Avoid integer overflow.
Reported as

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

* src/smooth/ftgrays.c(ADD_LONG, SUB_LONG, MUL_LONG, NEG_LONG)
[STANDALONE_]: Removed, unused.
(ADD_INT) [STANDALONE_]: New macro.
(FT_INTEGRATE): Use ADD_INT.
2021-08-07 17:16:52 +02:00
Dominik Röttsches 47cf8ebf4a [sfnt] Add API for retrieving a 'COLR' v1 'ClipBox' table.
The optional 'COLR' v1 glyph-specific clip box helps upstream graphics
libraries allocate a sufficiently large bitmap for a glyph without having to
traverse the glyph graph for that.  See

  https://github.com/googlefonts/colr-gradients-spec/issues/251

for background on the introduction of this specification change.

* include/freetype/ftcolor.h (FT_ClipBox): New structure.
(FT_Get_Color_Glyph_ClipBox): New function declaration.

* include/freetype/internal/sfnt.h (TT_Get_Color_Glyph_ClipBox_Func):
New function type.
(SFNT_Interface, FT_DEFINE_SFNT_INTERFACE): Use it.

* src/base/ftobjs.c (FT_Get_Color_Glyph_ClipBox): New function to link API
with SFNT implementation.

* src/sfnt/sfdriver.c (sfnt_interface): Updated.
* src/sfnt/ttcolr.c (Colr): New field `clip_list`.
(tt_face_load_colr): Parse global clip list offset.
(tt_face_get_color_glyph_clipbox): New function to find the clip box for a
glyph id from the clip list array.
* src/sfnt/ttcolr.h: Updated.
2021-08-07 14:44:05 +02:00
Werner Lemberg 6be8bfe499 [smooth] Fix left shifts of negative numbers.
Reported as

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

* src/smooth/ftgrays.c (LEFT_SHIFT): New macro.
(gray_render_conic) [BEZIER_USE_DDA]: Use it.
2021-08-06 08:31:22 +02:00
Werner Lemberg 09195a82a4 * meson.build: Fix zlib support.
This commit synchronizes zlib support with both autotools and cmake: If no
external zlib is found (or intentionally disabled on the command line), use
the internal zlib by undefining `FT_CONFIG_OPTION_SYSTEM_ZLIB` without
modifying `FT_CONFIG_OPTION_USE_ZLIB`.

Also improve summary output.

Problem reported by Moazin.
2021-08-02 12:55:28 +02:00
Anuj Verma be6ab31900 [sdf] Fix out-of-range-access.
* src/sdf/ftbsdf.c (first_pass, second_pass): Fix range during forward pass.
Otherwise the index goes out of range for the last column.

Fixes issue #1077.
2021-08-02 06:49:50 +02:00
Anuj Verma ebcc96e559 Fix invalid memory access in `bsdf` rasterizer.
Do not generate SDF from bitmap if the `FT_GLYPH_OWN_BITMAP` flag is not
set.  In some cases the bitmap buffer is freed but still points to a valid
address; to handle those cases check the flag before accessing the memory.

* src/sdf/ftsdfrend.c (ft_bsdf_render): Handle the above case.
Also, return an error message if the bitmap's rows/pitch is invalid,
otherwise `slot->buffer` might be assigned to some invalid memory location.
(ft_sdf_render): Same as above.
Plus, move the outline back to original state after rasterization and not if
any error occurs.

Signed-off-by: Anuj Verma <anujv@iitbhilai.ac.in>
2021-08-02 05:51:15 +02:00
Heiko Becker 47b1a541cb * meson.build: Honor `--includedir` instead of hard-coding 'include'.
Signed-off-by: Heiko Becker <heirecka@exherbo.org>
2021-07-29 08:33:56 +02:00
Werner Lemberg d2367abac0 src/sfnt/ttcolr.c: Minor formatting. 2021-07-29 08:16:25 +02:00
Dominik Röttsches 30a82e1e5d [sfnt] 'COLR' v1 PaintSweepGradient spec update
* src/sfnt/ttcolr.c (read_paint): PaintSweepGradient follows other
spec changes and now has the angles specified as F2DOT14, reflect
that in the implementation.
* include/freetype/ftcolor.h (FT_PaintSweepGradient): Update
documentation.
2021-07-29 06:12:51 +00:00
Dominik Röttsches 5c0ac7a435 [sfnt] Retrieve affine matrix from offset in 'COLR' v1 parsing.
* src/sfnt/ttcolr.c (read_paint): Implement spec change where
affine transform matrix is now referenced by offset instead of
being placed inline in the PaintTransform table.
2021-07-29 06:05:18 +00:00
Dominik Röttsches 66189807b8 [sfnt] 'COLR' v1 PaintSkew related spec updates
* src/sfnt/ttcolr.c (read_paint): Implement spec changes around
PaintSkew, PaintSkewAroundCenter.  Update parsing to read shorter
values as changed in the spec.
* include/freetype/ftcolor.h (FT_PaintSkew): Update documentation.
2021-07-29 06:01:34 +00:00
Dominik Röttsches 48df0fa652 [sfnt] PaintRotate/PaintRotateAroundCenter spec updates
* src/sfnt/ttcolr.c (read_paint): Implement spec change where
PaintRotate and PaintRotateAroundCenter were split for a more
compact format definition.  Update parsing to read shorter values
as changed in the spec.
* include/freetype/ftcolor.h (FT_PaintRotate): Update documentation.
2021-07-29 05:59:30 +00:00
Dominik Röttsches d7bdcb1bb5 [sfnt] 'COLR' v1 PaintTranslate and PaintScale precision
* src/sfnt/ttcolr.c (read_paint): Implement spec changes in
PaintTranslate and PaintScale and friends.  Update parsing to read
new shorter values.
2021-07-29 05:56:15 +00:00
AnuthaDev 6af39c3d76 README.git: Add Code of Conduct. 2021-07-29 07:51:59 +02:00
Werner Lemberg ba47af32ba ChangeLog housekeeping.
Archive old `ChangeLog` file.

We no longer write ChangeLog entries manually; instead, the file will be
created from commit messages (which should be formatted in GNU's ChangeLog
style) by a call to

  gitlog-to-changelog --format='%B%n'

or something similar (this script is part of the 'gnulib' repository).
2021-07-25 07:07:19 +02:00
Werner Lemberg c2fa51d9bd Fix some `cppcheck` warnings.
* src/bzip2/ftbzip2.c (ft_bzip2_file_skip_output), src/gzip/ftgzip.c
(ft_gzip_file_skip_output): Reduce scope of `delta`.

* src/psaux/psintrp.c, src/psaux/psintrp.h (cf2_interpT2CharString): Add
`const` to `buf` parameter.

* src/raster/ftraster.c (DelOld): Add `const` to `profile` parameter.
(Vertical_Sweep_Span): Reduce scope of `target`.
(FT_Outline_Get_CBox): Reduce scope of `xMin`, `xMax`, `yMin`, `yMax`.

* src/smooth/ftgrays.c (gray_render_conic): Reduce scope of `split`.
(gray_sweep, gray_sweep_direct): Reduce scope of `area`.

* src/tools/apinames.c (names_dump) <OUTPUT_WATCOM_LBC>: Reduce scope of
`temp`.
2021-07-24 20:32:16 +02:00
AnuthaDev 28c2d7f31c * .gitlab-ci.yml: Fixed cmake build, using correct options. 2021-07-24 08:31:42 +02:00
AnuthaDev 1f742f05bf * CMakeLists.txt: Make `cmake` handle disabled dependencies correctly.
Include 'CMakeDependentOption'.

Replace `FT_WITH_XXX` options with `FT_DISABLE_XXX` and `FT_REQUIRE_XXX`
pairs.  Update option logic accordingly.

Fixes #1066.
2021-07-24 08:31:42 +02:00
Ben Wagner 5bcaf51b61 [autofit] Split `afwrtsys.h`.
The header file `afwrtsys.h` has two distinct functions: to include the
required writing system headers and also to generate code for each writing
system.  At each current use site only one or the other is used, with
various macro trickery selecting one or the other.  Split this header into
`afws-decl.h` for the required writing system declarations and `afws-iter.h`
for iterating over the writing systems to generate code.

The motivation for this change is that the Visual C++ compiler treats the
standard include guard idiom like `#pragma once` 'if no non-comment code or
preprocessor directive comes before or after the standard form of the
idiom'.  It appears to check this after macro expansion, so if
`WRITING_SYSTEM` expands to empty the bottom of `afwrtsys.h` is empty and
looks like the standard include guard idiom which is treated like `#pragma
once`, so subsequent inclusion of `afwrtsys.h` is elided.

Fixes #1075.

* src/autofit/afglobal.c (af_writing_system_classes), src/autofit/aftypes.h
(AF_WritingSystem), src/autofit/rules.mk (AUTOF_DRV_H): Updated.

* src/autofit/afwrtsys.h: Split into...
* src/autofit/afws-decl.h, src/autofit/afws-iter.h: New files.
2021-07-24 07:29:17 +02:00
Werner Lemberg 801cd842e2 * Version 2.11.0 released.
==========================

Tag sources with `VER-2-11-0'.

* docs/VERSION.TXT: Add entry for version 2.11.0.
* docs/CHANGES: Updated.

* README, src/base/ftver.rc, builds/windows/vc2010/index.html,
builds/windows/visualc/index.html,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/index.html, docs/freetype-config.1:
s/2.10.4/2.11.0/, s/2104/2110/.

* include/freetype/freetype.h (FREETYPE_MINOR): Set to 11.
(FREETYPE_PATCH): Set to 0.

* builds/unix/configure.raw (version_info): Set to 24:0:18.
* CMakeLists.txt (VERSION_MINOR): Set to 11.
(VERSION_PATCH): Set to 0.

* builds/toplevel.mk (dist): Ignore more git-related files.
2021-07-19 18:07:51 +02:00
Ben Wagner 4082b863c1 Document direct header inclusion valid since 2.6.1.
Since commit e13391333 'Make macros for header file names optional.' the
header file layout has become public and using the macro expansions for
includes is no longer required.  While this happened in 2.10.3, the header
file layout had not changed since commit 392cf22f8a 'Another adjustment to
header locations.' in 2.6.1.  Retroactively make the header file layout
public back to 2.6.1 to speed adoption.
2021-07-17 08:51:32 +02:00
David Turner 357b353c2a * src/smooth/ftgrays.c: Fix compilation if `FT_LONG64` is undefined.
The code assumed that if `__SSE2__` is defined, then 64-bit integer
types are available.  This is not the case apparently for certain
multilib compiler targets like 'x86_32.x86' used by Gentoo.

This patch fixes the issue by disabling the special code path when
64-bit integer types are not available.

Fixes #1071.
2021-07-17 08:31:20 +02:00
Alex Richardson 7bc0f48c27 [tests] Allow arbitrary build directories.
* tests/issue-1063/main.c (main): I am building with a build
directory that is not directly inside the source tree, so the path
`../tests/data/As.I.Lay.Dying.ttf` does not resolve to the test
input file.  This change passes the test data directory as an
environment variable to allow arbitrary build directories.

* tests/meson.build: Updated.
2021-07-16 14:42:51 +02:00
Werner Lemberg 685acc04db docs/CHANGES: Mention slight rendering changes.
Suggested by Ben.
2021-07-16 08:20:44 +02:00
Alex Richardson c35961a925 * tests/issue-1063/main.c (main): Fix uninitialized variable.
I tried running `meson test` but the test just crashed and gdb
reported that the face argument to `FT_Get_Char_Index` was nonsense.
With this change the test prints 'Could not open file: ' as it
should.
2021-07-16 08:07:18 +02:00
Werner Lemberg 552fc97fe5 [smooth] Minor fixes.
* src/smooth/ftgrays.c (gray_render_conic): Move variable and
structure declarations to beginning of function.  Inspite of C99
compliance we still do this for the sake of backward compatibility.
This also avoids a shadowing declaration of `count`.
(gray_convert_glyph_inner): Fix typo.
2021-07-16 07:49:20 +02:00
Werner Lemberg 93771d619f Formatting and ChangeLog additions for previous commits. 2021-07-16 07:40:56 +02:00
Ben Wagner c37c087382 Guard inclusion of emmintrin.h
Guard inclusion of emmintrin.h with "#ifdef __SSE2__". The gcc version
of this header, xmmintrin.h, and mmintrin.h check that the appropriate
defines are set before defining anything (are internally guarded).
However the clang versions of these includes are not internally guarded.
As a result of this, externally guard the inclusion of these headers.
2021-07-15 11:33:16 -04:00
David Turner 56cc2ad446 [smooth] Implement Bezier quadratic arc flattenning with DDA
Benchmarking shows that this provides a very slighty performance
boost when rendering fonts with lots of quadratic bezier arcs,
compared to the recursive arc splitting, but only when SSE2 is
available, or on 64-bit CPUs.

On a 2017 Core i5-7300U CPU on Linux/x86_64:

  ./ftbench -p -s10 -t5 -cb .../DroidSansFallbackFull.ttf

    Before: 4.033 us/op  (best of 5 runs for all numbers)
    After:  3.876 us/op

  ./ftbench -p -s60 -t5 -cb .../DroidSansFallbackFull.ttf

    Before: 13.467 us/op
    After:  13.385 us/op
2021-07-15 13:25:58 +02:00
David Turner 86b9c9347f [smooth] Minor speedup to smooth rasterizer
This speeds up the smooth rasterizer by avoiding a
conditional branches in the hot path. Namely:

- Define a fixed "null cell" which will be pointed
  to whenever the current cell is outside of the current
  target region. This avoids a "ras.cell != NULL"
  check in the FT_INTEGRATE() macro.

- Also use the null cell as a sentinel at the end of
  all ycells[] linked-lists, by setting its x coordinate
  to INT_MAX. This avoids a 'if (!cell)' check in
  gray_set_cell() as well.

- Slightly change the worker struct fields to perform
  a little less operations during rendering.

Example results (on a 2013 Corei5-3337U CPU)

  out/ftbench -p -s10 -t5 -bc /usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf

    Before: 5.472 us/op
    After:  5.275 us/op

  out/ftbench -p -s60 -t5 -bc /usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf

    Before: 17.988 us/op
    After:  17.389 us/op
2021-07-15 13:25:48 +02:00