Commit Graph

5805 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov d7c72ff919 [raster] Use bitwise dropout mode interpretation.
* src/raster/ftraster.c (Vertical_Sweep_Drop, Horizontal_Sweep_Drop,
Draw_Sweep, Render_GLyph): Interpret dropout mode using bit masks.
2023-11-20 22:46:36 -05:00
Alexei Podtelezhnikov 050a320764 [raster] Keep only bottom y-turns.
This results in noticeable performance improvement.

* src/raster/ftraster.c (Insert_Y_Turns): All bottom y-turns are still
sorted and stored; only the maximum top y-turn is recorded now. The
function is renamed.
(End_Profile): Updated accordingly.
(Convert_Glyph): Reserve space for the top value.
2023-11-15 23:41:56 -05:00
Alexei Podtelezhnikov fa59e0d64c * src/raster/ftraster.c (End_Profile): Reduce branching.
(InsNew): Tweak condition.
2023-11-15 16:55:57 +00:00
Alexei Podtelezhnikov c580926f35 * src/raster/ftraster.c (Draw_Sweep): Use more natural loop. 2023-11-15 15:17:50 +00:00
Alexei Podtelezhnikov b0265ccd33 [raster] Dissolve a loop.
* src/raster/ftraster.c (End_Profile): Set initial `X` here...
(Draw_Sweep): ... instead of here; delay the `start` decrement.
2023-11-14 23:32:06 -05:00
Alexei Podtelezhnikov 6dc2ecb757 * src/raster/ftraster.c: Comments. 2023-11-14 23:06:41 -05:00
Alexei Podtelezhnikov aec7e717fb [raster] Stylistic changes.
* src/raster/ftraster.c (Line_To): Code it similar to curves;
shortcut the flat lines here...
(Line_Up): ... instead of here.
2023-11-14 16:47:34 +00:00
Alexei Podtelezhnikov d1b3ef7704 [raster] Revise overshoot setting.
* src/raster/ftraster.c (New_Profile, End_Profile): Deal with overshoots
locally.
(Line_To, Conic_To, Cubic_To): Update callers.
2023-11-14 15:54:52 +00:00
Alexei Podtelezhnikov 667aad581a * src/raster/ftraster.c (Conic_To, Cubic_To): Fix recent regression. 2023-11-14 15:10:52 +00:00
Alexei Podtelezhnikov 6e7ef1687f * src/raster/ftraster.c (Increment): Minor tweak. 2023-11-13 22:07:42 -05:00
Alexei Podtelezhnikov e9359e29be [raster] Get rid of the fresh flag.
* src/raster/ftraster.c (black_TWorker): Remove the fresh flag.
(New_Profile): Set the starting scanline here based on the current
coordinate and initialize the joint crossing if necessary.
(Line_Up, Bezier_Up): Do not deal with fresh and joint starts at all.
(Line_Down, Bezier_Down): Simplify.
(Conic_To, Cubic_To): Update the current coordinate after each
subsection.
2023-11-12 23:01:49 -05:00
Alexei Podtelezhnikov d5e8686dd8 [raster] Get rid of the joint flag.
* src/raster/ftraster.c (Line_Up, Bezier_Up): Deal with the scanline
joints directly based on the initial y-coordinate.
(New_Profile, black_TWorker): Remove the boolean flag.
2023-11-11 21:10:29 -05:00
Alexei Podtelezhnikov 9cd403bc9f * src/raster/ftraster.c (Line_Up, Bezier_Up): Check "between" earlier. 2023-11-11 10:18:53 -05:00
Alexei Podtelezhnikov 028b0d5c1b * src/raster/ftraster.c (Line_Up): Updated and fixed up.
This largely synchronizes the entries into `Line_Up` and `Bezier_Up`.
Minor bugs in the remainder calculations and accumulations are fixed.
2023-11-10 23:25:26 -05:00
Alexei Podtelezhnikov d5973932d0 * src/raster/ftraster.c (End_Profile, Convert_Glyph): Clean up. 2023-11-09 22:52:14 -05:00
Alexei Podtelezhnikov e9a81e4dd8 * src/raster/ftraster.c (Bezier_Up): Improve joint and loop. 2023-11-09 22:31:36 -05:00
Alexei Podtelezhnikov 6338f2a681 [raster] Harmonize target bitmap navigation.
* src/raster/ftraster.c (black_TWorker): Store signed maximum indexes
in both directions instead of unsigned dimensions of the original bitmap.
(*_Sweep_*, Render_Glyph, ft_black_render): Updated all users.
2023-11-06 18:56:38 -05:00
Alexei Podtelezhnikov e920273774 * src/raster/ftraster.c (Bezier_Up): Improve flow. 2023-11-05 23:12:56 -05:00
Alexei Podtelezhnikov 8a2ca26b41 [raster] Reshuffle code for readability.
* src/raster/ftraster.c (Render_Glyph): Setup the rendering pool here.
(ft_black_render): Setup the target bitmap helpers here.
2023-11-05 22:34:16 -05:00
Alexei Podtelezhnikov 9e86fb806d [raster] Improve profile accounting during sweeping.
* src/raster/ftraster.c (TProfile): Get rid of `countL`.
(Draw_Sweep): Use `start` for countdown to activation.
(Horizontal_Sweep_Drop, Vertical_Sweep_Drop): Rely on `height` and
`offset` to verify profile ends for the stub detection.
2023-11-03 23:59:05 -04:00
Alexei Podtelezhnikov 32081d8123 [raster] Consolidate profile increment to the next line.
* src/raster/ftraster.c (s/Sort/Increment): Rename this function to
reflect its true purpose, delete exhausted profiles here...
(Draw_Sweep): ... instead of here.
2023-11-03 23:10:41 -04:00
Alexei Podtelezhnikov 046c4fc7be [raster] Instantly remove profiles from linked lists.
* src/raster/ftraster.c (DelOld): Remove loopy function.
(Draw_Sweep): Implement instant profile removal.
2023-11-03 22:34:37 -04:00
Alexei Podtelezhnikov (Алексей Подтележников) 6d6607b8b3 [raster] Modify the split condition.
While curving close to a pixel center, vertical and horizontal pass
might split the curve differently and cause a rare dropout.  This
makes the split condition invariant of the sweep direction and more
robust.

* src/raster/ftraster.c (Bezier_Up): Modify the split condition.
2023-11-03 03:09:54 +00:00
Alexei Podtelezhnikov (Алексей Подтележников) f2e76e8356 [raster] Remove the jitter exception.
The jitter exception used to be applied when two neighboring pixels
were barely inside the outline. One the left one was turned on then,
which contradicts the OpenType specifications.  Intended to remove
glitches, it caused disappearing lines and was softened by adding an
exception to the exception (#54589).

* src/raster/ftraster.c (Vertical_Sweep_Span): Drop the jitter exception.
2023-11-03 03:09:54 +00:00
Alexei Podtelezhnikov dc519d06ea [raster] Simplify dropout detection.
* src/raster/ftrater.c (Draw_Sweep): Use a single dropout condition.
2023-10-31 15:01:32 +00:00
Alexei Podtelezhnikov 4e2d1f040c [raster] Simplify sweeping entry and exit.
* src/raster/ftraster.c (Draw_Sweep): Use y-turns to set the range,
correctly set the initial position, directly loop through y_turns,
and remove a 5-gray remnant at exit.
2023-10-30 22:46:32 -04:00
Alexei Podtelezhnikov 55d0287cfc [raster] Switch to routine Int instead of Short.
This is mostly cosmetic and removes a few casts, plus Short is
promoted to Int in calculations anyway.

* src/raster/ftraster.c (Vertical_Sweep_Init, Vertical_Sweep_Span,
Vertical_Sweep_Drop, Horizontal_Sweep_Init, Horizontal_Sweep_Span,
Horizontal_Sweep_Drop, Draw_Sweep): Mostly s/Short/Int/ and remove
casting.
2023-10-25 23:23:30 -04:00
Alexei Podtelezhnikov 8c5ec8dd63 [raster] Increase the raster pool density.
This only helps to delay the pool overflow and bisections to larger
sizes and benefits only very intricate glyphs at reasonable sizes.

* src/raster/ftraster.c (TProfile): Use Int instead of Long or PLong
when it is sufficient.
(New_Profile, End_Profuile, Bezier_Up, Sort): Updated accordingly.
2023-10-23 22:48:34 -04:00
Alexei Podtelezhnikov a0e10a87f5 [raster] Slightly improve the pool design.
* src/raster/ftraster.c (TProfile): Include the variable array member
and repackage with pointers first.
(New_Profile): Advance the top using the variable array pointer.
2023-10-23 17:47:10 -04:00
Alexei Podtelezhnikov d1e894b1f1 [raster] Clean up sweeping.
* src/raster/ftraster.c (Draw_Sweep): Zero initialize the working
lists directly and remove unnecessary y-turn checks.
(Init_Linked): Removed.
2023-10-22 13:08:36 -04:00
Alexei Podtelezhnikov 09ae6eb677 * src/raster/ftraster.c (Insert_Y_Turn): Improve flow. 2023-10-22 08:13:35 -04:00
Alexei Podtelezhnikov fab53f7b1f * src/pcf/pcfutil.c (BSWAP16): Limit clang support.
These ancient builtins have been supported by clang since 2013. We
condition it somewhat stricter but still around 2017.  This is more
portable than `__has_builtin`. Fixes #1260.
2023-10-21 19:08:20 -04:00
Alexei Podtelezhnikov 4e61303a3b [raster] Small optimizations.
* src/raster/ftraster.c (New_Profile): Set important fields only and
delay setting `gProfile` until...
(End_Profile): ... it is checked to be valid here.
(Convert_Glyph): Updated.
2023-10-18 23:13:13 -04:00
Alexei Podtelezhnikov a35da2c093 * src/raster/ftraster.c (Convert_Glyph): Remove redundant check. 2023-10-18 18:44:00 +00:00
Alexei Podtelezhnikov 3fa5c84565 [raster] Fix linked profiles in contour loops.
This fixes a subtle bug when the last profile in a contour was not
properly short-circuited if it was still empty at `End_Profile`.
We finalize all linking in `Finalize_Profile_List` now and do nothing
else there.  The turns are added in `End_Profile`.

* src/raster/ftraster.c (Insert_Y_Turn): Moved up unchanged.
(End_Profile): Take care of turns but set only preliminary linking.
(Finalize_Profile_Table): Take care of linking and null-termination.
(Convert_Glyph): Adjusted accordingly.
2023-10-17 23:56:23 -04:00
Alexei Podtelezhnikov 749b8f9d34 * src/raster/ftraster.c: Improve tracing. 2023-10-14 22:28:06 -04:00
Alexei Podtelezhnikov 153c038e3c [raster] Improve profile accounting.
* src/raster/ftraster.c (End_Profile): Do not initiate next profile.
(New_Profile): Fully initiate new profile.
(Convert_Glyph): Clean up variables, initialize `fProfile` here.
2023-10-13 15:22:32 +00:00
Alexei Podtelezhnikov f09c5e58c2 * src/raster/ftraster.c (Convert_Glyph): Fix null-dereference. 2023-10-13 13:44:39 +00:00
Alexei Podtelezhnikov c7fa00bf4e [raster] Fix pool overflow checking.
* src/raster/ftraster.c (New_Profile, End_Profile): Check for overflow
immediately.
(Convert_Glyph, Render_Single_Pass): Fix boundaries.
2023-10-13 00:16:02 -04:00
Alexei Podtelezhnikov 14bcb2867a [raster] Miscellaneous clean-ups.
* src/raster/ftraster.c (New_Profile): Use NULL.
(End_Profile): Optimize variables.
(Convert_Glyph): Do not initialize `cProfile` yet.
(Render_Single_Pass): Tracing.
2023-10-12 22:44:46 -04:00
Alexei Podtelezhnikov 322e580bd0 * src/smooth/ftgrays.c: Move the sweep functions...
... out of the setjmp/longjmp scope for readability.
2023-10-09 22:22:24 -04:00
Alexei Podtelezhnikov 84cd2e9897 * src/raster/ftraster.c: Tracing updates. 2023-10-09 22:11:41 -04:00
Alexei Podtelezhnikov 7b308a29dd * src/smooth/ftgrays.c (gray_render_conic) [SSE2]: Improve flow. 2023-09-28 22:56:15 -04:00
Alexei Podtelezhnikov e0e5b838e5 * src/gxvalid/gxvcommn.h (GXV_USHORT_TO_SHORT): Removed. 2023-09-25 22:26:15 -04:00
Alexei Podtelezhnikov 49781ab72b Comment typos. 2023-09-24 20:09:17 -04:00
Alexei Podtelezhnikov 73490681a7 * src/base/ftcalc.c (FT_MOVE_SIGN): Enclose assignments. 2023-09-24 19:39:10 -04:00
Alexei Podtelezhnikov c4073d8251 [psaux] Use `FT_SqrtFixed`.
* src/psaux/cffdecode.c <cff_op_sqrt>: Call `FT_SqrtFixed`.
* src/psaux/psintrp.c <cf2_escSQRT>: Ditto.
2023-09-19 22:29:14 -04:00
Alexei Podtelezhnikov 95b0fe2a6d [base] Reintroduce `FT_SqrtFixed`.
The general square root calculations are not necessary in FreeType.
For vector normalization or length, FreeType uses special functions.
It is, however, required in the legacy CFF specifications.

* src/base/ftcalc.c (FT_SqrtFixed): New function that uses either
Babylonian or bit-wise algorithm, whichever is faster for the given
situation.
* include/freetype/internal/ftcalc.h (FT_SqrtFixed): Declare it.
2023-09-19 22:26:32 -04:00
Alexei Podtelezhnikov babe6af167 * src/base/ftcalc.c /* FT_SqrtFixed */: Fix defunct overflow. 2023-09-18 15:01:26 +00:00
Alexei Podtelezhnikov d7b63a966b * src/tools/apinames.c (read_header_file): Typos. 2023-09-14 13:00:07 +00:00
Alexei Podtelezhnikov 6eb5f2be40 Update 2 files
- /src/base/ftcalc.c
- /include/freetype/internal/ftcalc.h
2023-09-13 17:02:31 +00:00
Ben Wagner 16f311d725 [base] Fix typo to correct predicate for call
* src/base/ftobj.c (FT_Get_Color_Glyph_Paint): check
`get_colr_glyph_paint` before calling `get_colr_glyph_paint` and not
`get_colr_layer`
2023-09-12 18:35:01 -04:00
Alexei Podtelezhnikov 7d45cf2c8f * src/psaux/cffdecode.c (cff_op_sqrt): Correct upper limit. 2023-09-11 20:45:16 -04:00
Alexei Podtelezhnikov 18eb93556c * src/psaux/cffdecode.c (cff_op_sqrt): Improve initial guess. 2023-09-11 17:00:49 -04:00
Alexei Podtelezhnikov 30b0ce7303 src/psaux/psintrp.c (cf2_escSQRT): Improve initial guess.
The worst number of iterations decreased from 11 to 5.
2023-09-11 16:34:36 +00:00
Alexei Podtelezhnikov 17db21f3fc * src/type1/t1afm.c (t1_get_index): Restore `strlen` call.
This reverts commit 8ed6d97446
and fixes
   https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62246
2023-09-10 22:34:17 -04:00
Alexei Podtelezhnikov 446720a29e * src/cff/cffparse.c (CFF_Field_Handler): Some s/0/NULL/. 2023-09-09 23:01:13 -04:00
Alexei Podtelezhnikov 8d0897b37d [type1, cid, type42] Post-cleanup.
* include/freetype/internal/psaux.h (T1_FIELD_ZERO): Terminating macro.
* src/cid/cidload.c (cid_parse_dict): Use while-loop.
* src/type1/t1load.c (parse_dict): Ditto.
* src/type42/t42parse.c (t42_parse_dict): Ditto.
2023-09-09 22:20:00 -04:00
Alexei Podtelezhnikov 3302e2f60c Update forgotten array termini.
* src/cid/cidload.c (cid_field_records): Account for added `len`.
* src/type1/t1load.c (t1_keywords): Ditto.
* src/type42/t42parse.c (t42_keywords): Ditto.
2023-09-09 17:24:34 -04:00
Alexei Podtelezhnikov 7ad9d57c3b [type1, cid, type42] Streamline dictionary parsing.
When matching the keywords, we avoid calculating their lengths by
checking the stored values. This itself is a sufficient pre-check
before diving into `memcmp`. Therefore, we remove explicit check of
the first characters.

* include/freetype/internal/psaux.h (T1_FieldRec): Store length.
* src/cid/cidload.c (cid_parse_dict): Use `memcmp` and stored length.
* src/type1/t1load.c (parse_dict): Ditto.
* src/type42/t42parse.c (t42_parse_dict): Ditto.
2023-09-09 15:19:06 -04:00
Alexei Podtelezhnikov 8ed6d97446 * src/type1/t1afm.c (t1_get_index): Avoid `strlen` call.
Instead, we check the terminal zero.
2023-09-09 15:13:55 -04:00
Alexei Podtelezhnikov 68f1b93247 * src/type1/t1driver.c (t1_ps_get_font_value): Avoid redundant null. 2023-09-08 16:23:05 +00:00
Alexei Podtelezhnikov 9c51e21e53 [cff, truetype] Improve prefix and suffix removal.
* src/cff/cffobjs.c (remove_style): Rewrite using pointers.
(remove_subset_prefix): Unwrap loop and use `memmove`.
* src/truetype/ttobjs.c (tt_skip_pdffont_random_tag): Unwrap loop
and avoid `strlen`.
2023-09-07 23:50:35 -04:00
Alexei Podtelezhnikov 4904d1eb1b * src/sfnt/ttpost.c (load_format_20): Micro-optimize. 2023-09-06 22:58:46 -04:00
Werner Lemberg 45903920b9 [autofit] Fix synchronization mistake between FreeType and ttfautohint.
Found by Behdad.

* src/autofit/aflatin.c (af_latin_metrics_init_blues): Fix array size of
`blue_sorted`: FreeType doesn't have artificial blue zones.
2023-09-05 08:09:31 +02:00
Werner Lemberg ad20173942 [autofit] Fix typos.
This also reduces the used heap size by a large factor.

From Behdad.

* src/autofit/afcjk.h (AF_CJKAxisRec): Use `AF_BLUE_STRINGSET_MAX_LEN`.
* src/autofit/aflatin.h (AF_LatinAxisRec): Ditto.
2023-09-04 19:26:31 +02:00
Alexei Podtelezhnikov 000b26a30f * src/sfnt/ttpost.c (load_format_20): Rework tracing. 2023-08-30 23:03:02 -04:00
Alexei Podtelezhnikov 2f7abe4838 Comment added. 2023-08-29 19:18:43 +00:00
Alexei Podtelezhnikov c46c4b8e79 * src/sfnt/ttpost.c (load_format_20): Permit long names.
Fixes #1254.
2023-08-29 17:52:06 +00:00
Werner Lemberg 2d9fce53d4 [gzip] Update sources to zlib 1.13. 2023-08-27 09:47:24 +02:00
Werner Lemberg 920c5502cc * Version 2.13.2 released.
==========================

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

* docs/VERSION.TXT: Add entry for version 2.13.2.
* 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.1/2.13.2/, s/2131/2132/.

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

* builds/unix/configure.raw (version_info): Set to 26:1:20.
* CMakeLists.txt (VERSION_PATCH): Set to 2.
2023-08-25 20:12:52 +02:00
Alexei Podtelezhnikov 0c817334b7 * src/base/ftcalc.c (FT_MulAddFix): Simplify 32-bit rounding. 2023-08-25 17:57:47 +00:00
Werner Lemberg d42679b93d Fix clang warnings.
* src/cffload.c (cff_blend_doBlend): Fix type of `sum`.
* src/truetype/ttgxvar.c (tt_var_load_item_variation_store): Fix type of
  `word_delta_count`.
2023-08-25 18:05:01 +02:00
Alexei Podtelezhnikov 97251fd5aa [base] Improve the matrix degeneracy check.
Also fixes #1251.

* src/base/ftcalc.c (FT_Matrix_Check): To avoid overflow, scale by shifting.
* include/freetype/internal/ftcalc.h (FT_Matrix_Check): Update description.
2023-08-22 11:01:16 +00:00
Ben Wagner a9793feace [base] Avoid UB with memcpy
`FT_NEW_ARRAY(p, 0)` sets `p` to `NULL`. `FT_Stream_ReadAt` with a
memory based stream uses `FT_MEM_COPY` which is `memcpy` which specifies
that it is undefined behavior for either the `src` or `dst` to be
`NULL`. Instead of forcing all callers work around calling
`FT_Stream_Read` when `buffer == NULL && count == 0` do the check in
`FT_StreamRead`. This allows any call with `count == 0` to succesfully
read zero bytes without UB.

* src/base/ftstream.c (FT_Stream_ReadAt): skip `FT_MEM_COPY` when
`count == 0`. (FT_Stream_TryRead): ditto

Fixes: #1250
2023-08-17 13:25:31 -04:00
Werner Lemberg a20de84e16 Fix warnings in tracing messages for 32bit compilation.
Since we now require C99, use `%td` for `ptrdiff_t` and `%zu` for `size_t`.
2023-08-12 11:47:41 +02:00
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 7c542d02bf * src/smooth/ftgrays.c (FT_SSE2): Fix definition for VMS. 2023-07-21 21:31:28 +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 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
Seigo Nonaka 115e927540 [truetype] Reduce heap allocation of `deltaSet` variation data.
`deltaSet` is an array of packed integers that can be 32 bits, 16 bits, or
8 bits.  Before this change, these values were unpacked to 32-bit integers.
However, this can cause big heap allocations, e.g., around 500 KByte for
'NotoSansCJK'.  To reduce this amount, store the packed integers and unpack
them just before passing to the calculation.  At calculation time, due to
the variable length of region indices, temporary heap allocations are
necessary.  This heap allocation is not negligible and visible in `ftbench`
results.  So, use stack-allocated arrays for short array calculations.

Fixes #1230.

* include/freetype/internal/ftmmtypes.h (GX_ItemVarDataRec): New fields
`wordDeltaCount` and `longWords`.

* src/truetype/ttgxvar.c (tt_var_load_item_variation_store): Load packed
data.
(tt_var_get_item_delta): Unpack data before applying.
2023-05-19 06:50:28 +02:00
Werner Lemberg 416d4c25f1 Add new load flag `FT_LOAD_NO_SVG`.
Modern color fonts often contain both an 'SVG' and 'COLR' table.  FreeType
always preferred 'SVG' over 'COLR' (this was a design decision), however,
this might not be the right choice for the user.  The new flags makes
FreeType ignore the 'SVG' table while loading a glyph.

Fixes #1229.

* include/freetype/freetype.h (FT_LOAD_NO_SVG): New macro.

* src/base/ftobjs.c (FT_Load_Glyph), src/cff/cffgload.c (cff_slot_load),
src/truetype/ttgload.c (TT_Load_Glyph): Use it.
2023-05-15 16:04:15 +02:00
Alexei Podtelezhnikov e1a4e081aa [cache] Merge functions.
* src/cache/ftccache.c (FTC_Cache_Init): Merge into...
(ftc_cache_done): ... this function, with unnecessary checks removed.
2023-05-12 22:27:08 -04:00
Alexei Podtelezhnikov 771ff8bd03 [cache] Minor casting and cosmetic updates.
* src/cache/ftcglyph.c (ftc_gcache_{init,done}): Remove casting.
(FTC_GCache_Lookup): Cosmetic variable renaming.
* src/cache/ftcsbits.c (ftc_snode_compare): Formatting.
2023-05-12 22:21:47 -04:00