Commit Graph

7661 Commits

Author SHA1 Message Date
Anurag Thakur 6b161ceb8a [dense] Add optimization for division
* src/dense/ftdense.c: FT_UDIV, FT_UDIVPREP macros taken from smooth
rasterizer, help optimize fixed-point division
2022-11-19 13:22:15 +05:30
Anurag Thakur 5d683228e7 [dense] Add optimization for vertical lines
* src/dense/ftdense.c: Optimize line drawing when a vertical line is encountered
2022-11-19 13:14:51 +05:30
Anurag Thakur 763f11088e [dense] Re-enable SIMD to work with fixed-point
* src/dense/ftdense.c: Use integer SIMD functions for accumulation

* src/dense/ftdense.h: Change types of FT26D6, FT20D12 to better fit
their usage
2022-11-19 13:05:14 +05:30
Anurag Thakur cd2e6217f3 [dense] Migrate line drawing and accumulation to fixed-point
* src/dense/ftdense.h: (FT26D6, FT20D12): New typedefs

* src/dense/ftdense.c: dense_render_line, dense_render_glyph now
use fixed-point numbers for calculation

Disabled SIMD for now
2022-11-19 12:58:14 +05:30
Anurag Thakur bdeb70bc18 [dense] Add SIMD support to rasterizer
* src/dense/ftdense: Use SSE4.1 for final accumulation step
(FT_SSE4_1): Macro which checks if SSE4.1 is available

* src/dense/rules.mk: Enable linking for SSE4.1
2022-11-19 12:34:43 +05:30
Anurag Thakur 03cc2183e0 [dense] Enable module compilation
* src/dense/ftdense.c: Redefine FT_SWAP to fix compilation error

* src/include/freetype/config/ftmodule.h: Added ft_dense_renderer_class

* src/dense/dense.c: Build single object of module

* modules.cfg: Added 'dense' RASTER_MODULE

* src/dense/module.mk, src/dense/rules.mk: Added Makefile

* CMakeLists.txt: Added 'dense.c' to compilation files
2022-11-19 11:06:36 +05:30
Anurag Thakur 4b77d947c5 [dense] Add drawing functions to rasterizer
* src/dense/ftdense.c: (dense_render_line, dense_render_quadratic,
dense_render_cubic, dense_render_glyph, dense_raster_render, Lerp):
New Functions
2022-11-19 10:45:39 +05:30
Anurag Thakur f126946b6a [dense] Add rasterizer functions
* src/dense/ftdense.c: (ONE_PIXEL, TRUNC, UPSCALE, DOWNSCALE,
FT_SWAP, FT_MIN, FT_MAX, FT_ABS): New Macros

(dense_move_to, dense_line_to, dense_conic_to): Added outline
decomposing functions

(dense_raster_new, dense_raster_done, dense_raster_reset,
dense_raster_set_mode, dense_raster_render): Added interface
functions
2022-11-19 10:28:46 +05:30
Anurag Thakur a3c327aa41 [dense] Add 'dense' renderer
* src/dense/ftdenserend.c: Add 'dense' renderer along with its interface
functions.

(ft_dense_set_mode, ft_dense_transform, ft_dense_get_cbox, ft_dense_init,
ft_dense_done, ft_dense_render)
2022-11-19 01:24:19 +05:30
Anurag Thakur 3b3c13d967 [dense] Populate headers for 'dense' module
* src/dense/ftdenserend.h (ft_dense_renderer_class): New Structures

* src/dense/ftdense.h (dense_worker): New Structure
(dense_render_line, dense_render_quadratic, dense_render_cubic): New
function declarations
(ft_dense_raster): Export dense raster funcs

* src/dense/ftdenseerrs.h: Add module error setup
2022-11-19 00:54:43 +05:30
Anurag Thakur 10f72058a3 [dense] Add files for new 'dense' module
Breakdown of what the files will contain

* src/dense/ftdenserend.c, src/dense/ftdenserend.h: The 'dense' renderer.

* src/dense/ftdense.c, src/dense/ftdense.h: The rasterizer for the
'dense' renderer.

* src/dense/ftdenseerrs.h: Common error defines.

* src/dense/dense.c: For building a single object of the entire module.
2022-11-18 13:18:54 +05:30
Johan Matsson 0f43a0e7eb * src/autofit/afloader.c (af_loader_load_glyph): Fix dereference.
This must happen after the NULL check.

Taken from

  https://github.com/freetype/freetype/pull/2
2022-11-16 07:54:39 +01:00
Alexei Podtelezhnikov 47e61d02e6 * src/pcf/pcfutil.c ({Two,Four}ByteSwap): Use builtins or shifts.
We trust glibc which uses shifts or builtins to swap bytes.  This
must be more efficient.
2022-11-14 22:53:14 -05:00
Werner Lemberg e6fda039ad * src/truetype/ttgxvar.c (tt_hvadvance_adjust): Integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50462
2022-11-14 19:18:19 +01:00
Loïc Yhuel 63ccaef07a [meson] Use generated ftmodule.h
ftmodule.h is generated at the root of the build directory, but FT_CONFIG_MODULES_H
(freetype/config/ftmodule.h) is used instead.
This makes the build fail when disabling modules in modules.cfg.

* meson.build (harfbuzz_dep): Add '-DFT_CONFIG_MODULES_H=<ftmodule.h>'.
2022-11-14 14:43:04 +01:00
Loïc Yhuel b37b8d2a70 [meson] Fix generated ftmodule.h
The sdf module wasn't recognized, so the generated ftmodule.h had "None_renderer_class".

* builds/meson/parse_modules_cfg.py: Handle sdf in RASTER_MODULES.
2022-11-14 14:43:04 +01:00
Dominik Röttsches ba4bd5b994 Add `TT_CONFIG_OPTION_NO_BORING_EXPANSION` configuration macro.
This gives users a possibility to deactivate new features not (yet) in the
OpenType standard.

* include/freetype/config/ftoption.h, devel/ftoption.h
(TT_CONFIG_OPTION_NO_BORING_EXPANSION): New macro.

* src/truetype/ttgxvar.c (ft_var_load_avar): Use it to disable 'avar'
version 2.0 support.
2022-11-12 17:11:36 +01:00
Behdad Esfahbod e97cb9e8da [truetype] Improve bounds checks for `ItemVariationStore`.
* src/truetype/ttgxvar.c (tt_hvadvance_adjust): Move bounds check ...
(tt_var_get_item_delta): ...  to this function, because it is safer.  For
example, the 'avar' table 2.0 codepath was not performing a bounds check at
all.
2022-11-12 16:45:44 +01:00
Behdad Esfahbod 9be958ca39 [truetype] In `ItemVariationStore`, value 0xFFFF for `dataCount` is valid.
It corresponds to outer indices of 0 to 0xFFFE.

* src/truetype/ttgxvar.c (tt_var_load_item_variation_store): Remove invalid
code.
2022-11-12 16:41:20 +01:00
Alexei Podtelezhnikov 109179c70e [pcf] Improve CMap efficiency and readability.
* src/pcf/pcfdrivr.c (pcf_cmap_char_{index,next}): Check and walk
the encoding array indexes.
2022-11-10 23:25:48 -05:00
Sam James e82371bf6e Fix `-Wstrict-prototypes`.
* builds/unix/configure.raw: Fix `-Wstrict-prototypes`.
Clang 16 warns on these and they will be dropped in C23.

* builds/unix/freetype2.m4: Ditto.

Signed-off-by: Sam James <sam@gentoo.org>
2022-11-10 05:38:55 +01:00
Ben Wagner 9154707f6b [truetype] Check avar_segment before access
* src/truetype/ttgxvar.c (tt_done_blend): check `avar_segment` before
accessing to free its `correspondence`.

Reported as:

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53062
2022-11-09 19:15:26 +00:00
Ben Wagner d38407f79e [truetype] Restore behavior of ft_var_load_hvvar
* src/truetype/ttgcvar.c (ft_var_load_hvvar): restore previous behavior

In a previous change [0] the behavior of `ft_var_load_hvvar` was changed
to not load the item variation store if it was at offset 0, but not
return an error when this happened. This broke any users, like
`tt_hvadvance_adjust`, that rely on successful completion of
`ft_var_load_hvvar` to imply that returned table's `itemStore` had been
initialized. This lead such users to dereference NULL.

This change appears to have been unintentional and unrelated to the
actual avar2 changes. As a result, fix these NULL dereferences by
restoring the code to always attempt to initialize the `itemStore`.

[0] ae4eb996 "[truetype] Add support for `avar` table 2.0 format."

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53061
2022-11-09 19:02:22 +00:00
Werner Lemberg 978fdb292a docs/CHANGES: Updated. 2022-11-08 08:27:52 +01:00
suzuki toshiya bccf1cd6b4 [build] use AC_CHECK_PROG() macro for libpng-config detection
* builds/unix/configure.raw: use AC_CHECK_PROG() instead of `which` to find `libpng-config`.
2022-11-08 14:31:23 +09:00
suzuki toshiya 32cfab4be7 [build] fix for make multi
Fix "make multi" by MR !223

* include/freetype/internal/services/svmm.h: include ftmm.h to define FT_Get_MM_Func.
* src/truetype/ttgxvar.h: include ftmmtypes.h to use GX_AVarTable properly.
* src/base/ftmac.c: include ftdebug.h to use FT_THROW() properly.
2022-11-08 14:23:37 +09:00
Alexei Podtelezhnikov e00afdb35b * src/pfr/pfrsbit.c (pfr_lookup_bitmap_data): Accelerate the search.
This is mostly for consistency because PFR fonts with bitmap strikes
do not seem to exist.
2022-11-07 21:36:32 -05:00
Alexei Podtelezhnikov 6139f2b647 [bdf, pfr, psnames] Accelarate charmap searches.
The binary searches within charmaps can be accelerated because they
often contain dense continuous blocks of character codes. Within such
blocks, you can predict matches based on misses.  This method has been
deployed in `bdf` since 0f122fef34; we only refactor it there.  We now
use it in `pfr` and `psnames`, which speeds up the unicode charmap
access by about 50% in PFR and Type 1 fonts.

* src/bdf/bdfdrivr.c (bdf_cmap_char_{index,next}): Refactor.
* src/pfr/pfrcmap.c (pfr_cmap_char_{index,next}): Predict `mid` based
on the mismatch distance.
* src/psnames/psmodule.c (ps_unicodes_char_{index,next}): Ditto.
2022-11-06 13:12:47 -05:00
Behdad Esfahbod ae4eb996ab [truetype] Add support for `avar` table 2.0 format.
See

  https://github.com/harfbuzz/boring-expansion-spec/blob/main/avar2.md

for the specification.

Currently, this is implemented only in most recent OS versions on Apple
platforms and in the HarfBuzz library, but it is expected to be added to the
OpenType standard soon.

* src/truetype/ttgxvar.h (GX_AVarTableRec): New structure.
(GX_BlendRec): Use it to replace `avar_segment` with `avar_table`.

* src/truetype/ttgxvar.c (ft_var_load_avar): Load new table version.
(ft_var_to_normalized, tt_done_blend): Extend for new format.
(ft_var_load_hvvar, ft_var_to_design): Updated.
2022-11-04 19:44:36 +01:00
Werner Lemberg dea2e6358b Replace '1/64th' (and similar entries) with '1/64' in docs and comments. 2022-10-24 07:01:21 +02:00
Ivan Panchenko 05e1b37e3d * include/freetype/*: Fix documentation typos. 2022-10-24 06:52:06 +02:00
Alexei Podtelezhnikov ffbbf3df3e * src/truetype/ttgload.c: Cosmetic changes. 2022-10-21 15:55:30 +00:00
Alexei Podtelezhnikov 1bfaca0635 [cff, truetype] Simplify SVG metrics scaling.
Use pre-calculated scaling factors. Also, the advance widths used
to be rounded, which was incorrect.

* src/cff/cffgload.c (cff_slot_load): Use `x_scale` and `y_scale`.
* src/truetype/ttgload.c (TT_Load_Glyph): Ditto.
2022-10-21 12:14:52 +00:00
Werner Lemberg 0ec85f71a8 * subprojects/zlib.wrap: Update to zlib version 1.2.13. 2022-10-20 13:55:41 +02:00
Dominik Röttsches 0b62c1e43d [sfnt] Additional bounds checks for `COLR` v1 table handling.
* src/sfnt/ttcolr.c (read_paint): Add `colr` argument, necessary for...
... another use of `ENSURE_READ_BYTES`.
Update callers.
(tt_face_get_paint_layers): Ensure that the 4-byte paint table
offset can be read.

This is a follow-up to !124 and issue
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52404
2022-10-18 19:55:25 +02:00
Werner Lemberg af46fcc15a [gzip] Update sources to zlib 1.2.13. 2022-10-18 19:43:52 +02:00
Alexei Podtelezhnikov b8882a3ed6 * src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Simplify calculations. 2022-10-18 15:58:02 +00:00
Werner Lemberg c943d408e0 Minor formatting. 2022-10-18 11:41:00 +02:00
Dominik Röttsches 04272824e0 [sfnt] Guard individual `COLR` v1 paint field reads.
* src/sfnt/ttcolr.c (ENSURE_READ_BYTES): New macro.
(read_paint): Use it – after the start pointer `p` has been checked for
whether it allows reading the format byte, each successive paint table field
read need to be bounds-checked before reading further values.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52404
2022-10-18 08:37:05 +02:00
Xiang Xiao 8493877e78 * builds/toplevel.mk: Prefix all paths with `$(TOP_DIR)/`.
This is useful for builds that are not started from the root directory.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 08:49:53 +02:00
Liu Kunpeng(柳鲲鹏) bb59c3c958 * src/base/ftsynth.c (FT_GlyphSlot_Slant): New API with custom slant.
* include/freetype/ftsynth.h (FT_GlyphSlot_Slant): Declare it.
2022-10-16 22:10:19 -04:00
Alexei Podtelezhnikov 3ab1875cd2 Note the lack of floating-point data types. 2022-10-14 22:06:23 -04:00
Werner Lemberg 5182264a40 [cff] Remove `FT_CONFIG_OPTION_NO_GLYPH_NAMES`.
This ancient option stayed completely undocumented.  Given that the 'cff'
driver requires the 'psnames' module, it makes no sense today to have this
macro.

* src/cff/cffdrivr.c (cff_services), src/cff/cffobjs.c (cff_face_init):
Remove corresponding conditional code.
2022-10-10 12:41:49 +02:00
Werner Lemberg 0d66abca4b Synchronize `ftoption.h` flavours. 2022-10-10 12:41:19 +02:00
Werner Lemberg 141d979af7 Minor comment changes. 2022-10-10 12:25:51 +02:00
Alexei Podtelezhnikov 15f6873495 Improve FT_Get_Name_Index docs and place it next to FT_Get_Glyph_Name. 2022-10-04 23:36:09 -04:00
Alexei Podtelezhnikov 0417527d5b [autofit] Reset the face charmap directly.
There is no need to validate the original charmap in `FT_Set_Charmap`.
It can be reset directly.

* src/autofit/afglobal.c (af_face_globals_compute_style_coverage):
Use direct assignment.
* src/autofit/af{latin,cjk,indic}.c (af_latin_metrics_init): Ditto.
2022-10-03 19:23:26 -04:00
Alexei Podtelezhnikov 1b6dce84f9 * src/type1/t1afm.c (T1_Read_PFM): Set charmaps directly.
As with the previous commit, we can avoid the validation checks
of `FT_Set_Charmap` and set it directly when choosing from the
available list.
2022-10-03 19:18:48 -04:00
Alexei Podtelezhnikov 8faf57dd17 * src/cache/ftccmap.c (FTC_CMapCache_Lookup): Avoid `FT_Set_Charmap`.
Set charmap aggressively without all validations of `FT_Set_Charmap`
because we take it from the available array and only temporarily.
Even CMap Format 14 will gracefully return 0.
2022-10-03 17:13:30 +00:00
Alexei Podtelezhnikov b93f20ab7a * src/cache/ftcbasic.c (ftc_basic_family_get_count): Remove redundancy. 2022-10-03 15:10:12 +00:00