Commit Graph

7893 Commits

Author SHA1 Message Date
Anurag Thakur b1f9f98e45 [dense] Add support for rendering prelines
* src/dense/ftdense.c: Add dense_render_line2 function, that takes
a PreLine as argument.

FT_Outline_Decompose call in dense_render_glyph replaced by a loop
that renders PreLines

* src/dense/ftdenserend.c: Add support for shifting PreLines as
per target bitmap
2023-10-10 03:41:29 +05:30
Anurag Thakur c1804c48a9 [dense] Add support for preloading in ft_open_face_internal
* src/base/ftobjs.c: Add code for loading glyph data into
face->glyph_aray after ft_open_face_internal has succeeded
2023-10-10 03:39:47 +05:30
Anurag Thakur 2254ce1906 [dense] Add code for curve flattening at load time
src/base/ftobjs.c: Add Lerp, conic_to2, ft_decompose_outline functions
2023-10-10 03:38:02 +05:30
Anurag Thakur b2f570a2bb [dense] Implement FT_New_Face2 and fix glyph loading
* include/freetype/freetype.h: Add filed "size" to FT_Open_Args

* src/base/ftobjs.c: Use slot from face's glyph_array in FT_Load_Glyph
Implement FT_New_Face2
2023-10-10 03:35:20 +05:30
Anurag Thakur e7c4fb9d13 [dense] Add FT_Refresh_Glyph
* include/freetype/freetype.h: Declare FT_Refresh_Glyph

* src/base/ftobjs.c: Implement FT_Refresh_Glyph
2023-10-10 03:31:03 +05:30
Anurag Thakur d074c39cd9 [dense] Modified FT_FaceRec, FT_GlyphSlotRec and FT_Raster_Params
* include/freetype/freetype.h: Add glyph_array filed to FT_FaceRec,
prelines, prel_shifted fileds to GlyphSlotRec

* include/freetype/ftimage.h: Add prelines filed to FT_raster_Params
2023-10-10 03:28:13 +05:30
Anurag Thakur c33e0b82de [dense] Add FT_PreLine struct
* include/freetype/freetype.h: Add FT_PreLineRec struct and its handle FT_PreLine
2023-10-10 03:26:28 +05:30
Anurag Thakur 45de1dba73 [dense] Declare FT_New_Face2
* include/freetype/freetype.h: Add FT_New_Face2 function to be used
for preloading optimization
2023-10-10 03:24:09 +05:30
Anurag Thakur 3b3c46629e [dense] Add ARM NEON support and improve SSE perf
* src/dense/ftdense.c: Add FT_NEON flag, implement ARM NEON support
in dense_render_glyph, improve SSE performance

* src/dense/rules.mk: Replacse -msse4.1 with -march=native
2023-10-10 03:20:48 +05:30
Anurag Thakur 1bf65eff60 [dense] Add compilation fixes for meson
* builds/meson/parse_modules_cfg.py: Add dense module

* meson.build: Add SSE flags to ft2_defines, -lm to link_args

* src/dense/ftdense.c: Fixes for compilation errors
2023-10-10 03:17:34 +05:30
Anurag Thakur cf779f5fbf [dense] Add -msse4.1 to compile with CMake
* CMakeLists.txt: Add -msse4.1 to ${CMAKE_C_FLAGS}
2023-10-10 03:15:13 +05:30
Anurag Thakur 724e81ef5b [dense] Add optimization for division
* src/dense/ftdense.c: FT_UDIV, FT_UDIVPREP macros taken from smooth
rasterizer, help optimize fixed-point division
2023-10-10 01:46:43 +05:30
Anurag Thakur 668bc29ff0 [dense] Add optimization for vertical lines
* src/dense/ftdense.c: Optimize line drawing when a vertical line is encountered
2023-10-10 01:46:43 +05:30
Anurag Thakur bca7bda1e7 [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
2023-10-10 01:46:43 +05:30
Anurag Thakur 3e56c9bf62 [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
2023-10-10 01:46:37 +05:30
Anurag Thakur 70d6a8ef1a [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
2023-08-09 01:32:15 +05:30
Anurag Thakur 2504e2de84 [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
2023-08-09 01:32:15 +05:30
Anurag Thakur 5e681678f6 [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
2023-08-09 01:32:15 +05:30
Anurag Thakur f2ff1dc37e [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
2023-08-09 01:32:15 +05:30
Anurag Thakur abce0cab72 [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)
2023-08-09 01:32:15 +05:30
Anurag Thakur f681099918 [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
2023-08-09 01:32:15 +05:30
Anurag Thakur a78906fb4e [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.
2023-08-09 01:32:15 +05:30
Ben Wagner 3829fdaae5 Avoid overflow in COLR bounds checks.
The values read into `base_glyphs_offset_v1` and `layer_offset_v1` may
be in the range 0xFFFFFFFD-0xFFFFFFFF. On systems where `unsigned long`
is 32 bits adding 4 to such values will wrap and pass bounds checks but
accessing values at such offsets will be out of bounds.

On the other hand `table_size` has already been tested to be at least
`COLRV1_HEADER_SIZE` (34) so it is safe to subtract 4 from it.

* src/sfnt/ttcolr.c (tt_face_load_colr): subtract 4 from `table_size`
instead of adding 4 to font data offsets in bounds checks

Fixes: https://crbug.com/1469348
2023-08-04 11:41:23 -04:00
Alexei Podtelezhnikov 95a872085e * src/base/ftobjs.c (open_face_from_buffer): Silence `maybe-uninitialized`.
We never call this function without a `driver_name` (#1245).
2023-08-01 22:48:31 -04:00
Alexei Podtelezhnikov b2584c738f [truetype] Reduce v40 footprint.
*  src/truetype/ttgload.c (TT_HInt_Glyph, tt_loader_set_pp,
tt_loader_init): Refactor code.
2023-07-28 22:35:58 -04:00
Alexei Podtelezhnikov 1ecfd21990 [truetype] Remove Infinality for good (remaining bits).
* src/truetype/ttobjs.h: Remove remaining fields.
* src/truetype/ttinterp.c: Do not initialize them.
* include/freetype/internal/tttypes.h: Remove descriptions.
2023-07-27 16:12:28 +00:00
Alexei Podtelezhnikov 5b7e45ac34 [truetype] Remove Infinality for good.
Remove everything `#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY`,
which was undefined for a while now.

* include/freetype/internal/tttypes.h: Ditto.
* src/truetype/truetype.c: Ditto.
* src/truetype/ttdriver.c: Ditto.
* src/truetype/ttgload.c: Ditto.
* src/truetype/ttinterp.c: Ditto.
* src/truetype/ttinterp.h: Ditto.
* src/truetype/ttobjs.c: Ditto.
* src/truetype/ttsubpix.[ch]: Remove files.
* src/truetype/rules.mk: Don't mention "ttsubpix.c".
2023-07-27 15:06:38 +00:00
Jouk Jansen 9e3c5d7e18 * vms_make.com: Provide separate library compiled with C++.
Some types on OpenVMS x86_64 (for example, `long') have different sizes
depending on whether compiled with either C or C++.  In particular,
X-Windows applications crash if linked with the C++ version.

This patch makes `vms_make.com` create a second version of the FreeType
library compiled with C++ if OpenVMS is running on the x86_64 platform.
2023-07-21 21:36:57 +02:00
Jouk Jansen f7ae7e88e9 * vms_make.com: Fix typos. 2023-07-21 21:33:20 +02:00
Jouk Jansen 7c542d02bf * src/smooth/ftgrays.c (FT_SSE2): Fix definition for VMS. 2023-07-21 21:31:28 +02:00
Jouk Jansen 5769f13a6b vms_make.com: Make use of additional libraries optional.
Check whether `.olb` files are present.

Also check for the HarfBuzz library.
2023-07-19 13:41:04 +02:00
Jouk Jansen e8aa5af936 vms_make.com: Add `/warn=noinfo` to `CFLAGS`.
This reduces enormously the informationals while compiling on x86_64 (i.e.,
which `.h` file is inluded form where).
2023-07-19 13:41:04 +02:00
Ben Wagner dd3c9c5fec [woff2] Clean up on large brotli expansion
* src/sfnt/sfwoff2.c (woff2_open_font): set error and goto cleanup

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60711
2023-07-18 13:34:09 -04:00
Werner Lemberg 336503dfd7 [woff2] Avoid allocation bomb.
This is a fix for commit 85167dbd5, reported as

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

* src/sfnt/sfwoff2.c (MAX_SFNT_SIZE): New macro.
(woff2_open_font): Use it to limit the maximum size of an uncompressed WOFF2
font.
2023-07-16 07:40:32 +02:00
Werner Lemberg 3c92e7bfc2 [cff] Fix compiler warning.
* src/cff/cffparse.c, src/cff/cffparse.h: Make `cff_parse_fixed` a local
function.
2023-07-14 18:58:55 +02:00
Ben Wagner 85167dbd50 [woff2] Remove sfnt size guess check
In WOFF the `totalSfntSize` must be correct, however in WOFF2 this value
is now just a hint and a conforming implementation must not reject
otherwise valid data if the `totalSfntSize` turns out not to be exact.

* src/sfnt/sfwoff2.c (woff2_open_font): remove check that uncompressed
woff2 data would fit in the sfnt size guess.

Fixes: #1235
2023-07-14 14:52:20 +00:00
Skef Iterum 26a7f0478b [cff] Make blend operator work with floats in private dicts.
The CFF2 blend operator takes N default values and corresponding
sets of deltas and pushes N values specific to a designspace
location.  CFF has a floating point numeric type and the FreeType
blending code was not converting those into its internal 16.16
Fixed type format.

Fixes #1243.

* src/cff/cffparse.c (do_fixed): Handle floating point numbers.
Also fix scaling overflow check for integer-to-fixed conversion.

* src/cff/cffload.c (cff_blend_doBlend): Updated.
2023-07-14 11:28:24 +02:00
Hin-Tak Leung dec2743e6a * src/truetype/ttgload.c (TT_Hint_Glyph): More mostly cosmetic update.
This is a follow-up to commit 49c74ac02, which creates a new local variable
"exec = loader->exec", and shortening a lot of "loader->exec".  This commit
does two more such changes missed in that first commit.

Signed-off-by: Hin-Tak Leung <htl10@users.sourceforge.net>
2023-07-08 05:39:25 +02:00
Hugh McMaster 355e919746 [gzip] Don't compile internal zlib development files when using system zlib.
`src/gzip/rules.mk` compiles the internal zlib sources even when using the
zlib development files provided by a host system.  If the internal zlib
development files are not present, FreeType fails to build from source.

This patch ensures the internal zlib development files are only
prerequisites when not using zlib development files on a host system.

* src/gzip/rules.mk (GZIP_DRV_SRCS): Define conditionally.
2023-07-06 14:22:15 +02:00
Werner Lemberg e4586d960f * Version 2.13.1 released.
==========================

Tag sources with `VER-2-13-1'.

* docs/VERSION.TXT: Add entry for version 2.13.1.
* docs/CHANGES: Updated.
* docs/release, docs/README, builds/macs/README: 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.13.0/2.13/1/, s/2130/2131/.

* include/freetype/freetype.h (FREETYPE_PATCH): Set to 1.

* builds/unix/configure.raw (version_info): Set to 26:0:20.
* CMakeLists.txt (VERSION_PATCH): Set to 1.

* subprojects/libpng.wrap, subprojects/zlib.wrap, subprojects/dlg: Updated.
2023-06-24 08:11:05 +02:00
suzuki toshiya 5c00a46805 Comment fixes. 2023-06-09 07:36:49 +02:00
Werner Lemberg 86d0ca245a [sdf] Correct handling of empty glyphs.
This is a refinement of commit 7b3ebb9.

* src/sdf/ftsdfrend.c (ft_sdf_render): Goto 'Exit' instead of directly
returning.
(fd_bsdf_render): Ditto, also taking care of setting `FT_GLYPH_OWN_BITMAP`
correctly.
2023-06-09 05:38:49 +02:00
Ben Wagner 4e1c0e8fba Mark FT_Renderer_Class::raster_class as pointer to const
The `FT_DEFINE_RASTER_FUNCS` macro declares a `const FT_Raster_Funcs`.
The address of the definition is taken and assigned to
`FT_Renderer_Class::raster_class` which is currently `FT_Raster_Funcs*`.
Until recently the `const` was cast away and with the removal of the
cast there are now warnings about dropping this `const`. Instead of
adding back the casts, make `FT_Renderer_Class::raster_class` a pointer
to const, as is done with pointers in other interfaces.

* include/freetype/ftrender.h (FT_Renderer_Class_): mark `raster_class`
as const.
2023-06-05 12:06:24 -04:00
Ben Wagner 7bed7a02f4 Fix some `FT_Fixed` vs. `FT_Long` confusion.
`FT_Fixed` and `FT_Long` are both typedef'ed to be `signed long`.  However,
`FT_Fixed` implies that the lower 16 bits are being used to express
fractional values and so these two types should not be confused.

* include/freetype/internal/services/svmm.h (FT_Set_MM_Blend_Func): Use
`FT_Fixed` for `coords`.  Users are passing `FT_Fixed` and implementations
are taking `FT_Fixed`.
(FT_Get_MM_Blend_Func): Ditto.

* src/autofit/afcjk.c (af_cjk_metrics_check_digits): Use `FT_Long` for
`advance` and `old_advance`.  `advance`'s address is passed as `FT_Long*` to
`af_shaper_get_elem`, which writes the advance in em units (not fixed).  The
exact value is not important here as it is only compared to check whether it
has changed.

* src/autofit/aflatin.c (af_latin_metrics_check_digits): Ditto.
2023-06-03 07:02:12 +02:00
Ben Wagner 2fb8eda5d6 */*: Remove many function pointer casts.
In C it is undefined behavior to call a function through a function pointer
of a different type.  This is now detected by the Control Flow Integrity
Sanitizer.  All known issues have already been fixed.  Prevent any
accidental re-introduction by removing function pointer casts when defining
services.  The services will call the service functions through the function
pointers on the service.  As a result the functions must have the same type
so there should be no need to cast.  Removing the casts allows compilers to
warn about assignment to an incompatible function pointer type.
2023-06-03 06:58:09 +02:00
Werner Lemberg b641b607be Minor formatting. 2023-06-03 06:09:30 +02:00
Werner Lemberg 80a507a6b8 Replace `sprintf` with `snprintf`.
Fixes #1233.

* include/freetype/config/ftstdlib.h (ft_sprintf): Replace with...
(ft_snprintf): This new macro.

* src/autofit/afhints.c (af_print_idx): Add argument to pass the buffer
size.
(af_glyph_hints_dump_points, af_glyph_hints_dump_segments,
af_glyph_hints_dump_edges): Updated.

* src/bdf/bdflib.c (BUFSIZE): New macro.
(bdf_parse_properties_, bdf_parse_start_): Use `ft_snprintf`.

* src/tools/ftrandom/ftrandom.c (do_test): Use `snprintf`.
2023-05-23 13:18:01 +02:00
Werner Lemberg 66cc4619d2 docs/DEBUG: Formatting. 2023-05-23 12:54:48 +02:00
suzuki toshiya 562f348192 [doc] Type1 GX (sfnt-wrapped Type1) is not supported.
* docs/formats.txt: Clarify the reference of Type1 GX,
and state that this format is not supported.  This
is because the content `TYP1' table is not exactly same
with the Type1 font format specification; no eexec
encryption is used.  For detail and concrete examples,
see the analysis on:

https://gitlab.freedesktop.org/freetype/freetype/-/issues/1231
2023-05-20 12:52:25 +00:00
Craig White 2342a03a9d Add missing end quote of a string in the example code of FT_Trace_Set_Level 2023-05-19 14:11:57 -04:00