Commit Graph

7582 Commits

Author SHA1 Message Date
Anurag Thakur 7d097d692c Partially move parameters to existing types 2022-07-13 01:06:15 +05:30
Anurag Thakur 7996f488e5 Temp fix for upside-down bitmap 2022-07-12 18:31:20 +05:30
Anurag Thakur 171a542175 Logging for testing 2022-07-12 17:19:37 +05:30
Anurag Thakur b66a91728b Added commentary 2022-07-12 16:38:40 +05:30
Anurag Thakur 9fd24008ae Added cmake build 2022-07-12 16:38:40 +05:30
Anurag Thakur dffb269d06 Remove printfs 2022-07-12 16:38:40 +05:30
Anurag Thakur 44892f8212 Integration prototype successful 2022-07-12 16:38:40 +05:30
Anurag Thakur 43a66f774c Trying to get it to work attempt #1 2022-07-12 16:38:40 +05:30
Anurag Thakur e66db7ec5c Compilation fix attempt #1 2022-07-12 16:38:38 +05:30
Anurag Thakur d019c05e9f Finish importing code, integration pending 2022-07-12 16:37:51 +05:30
Anurag Thakur 12ffde24a1 Added things 2022-07-12 16:37:01 +05:30
Anurag Thakur e68cdd5f9e Populate errors header for 'dense' renderer 2022-07-12 16:37:01 +05:30
Anurag Thakur a4cf05ea5c Add files for new 'dense' module 2022-07-12 16:37:01 +05:30
Dominik Röttsches 275b116b40 [sfnt] Support variable 'COLR' v1 `PaintVarSkew*`.
* src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration values
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW`,
`FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER`, and
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_SKEW_CENTER`.
(read_paint): Handle new enumeration values.
2022-07-09 05:59:45 +02:00
Dominik Röttsches 44fd524ee4 [sfnt] Support variable 'COLR' v1 `PaintVarRotate*`.
* src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration values
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE` and
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_ROTATE_CENTER`.
(read_paint): Handle new enumeration values.
2022-07-09 05:59:45 +02:00
Dominik Röttsches 603fef28a6 [sfnt] Support 'COLR' v1 variable `PaintVarScale*`.
* src/sfnt/ttcolr.c: (FT_PaintFormatInternal): New enumeration values
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE`,
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_CENTER`,
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM`, and
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_SCALE_UNIFORM_CENTER`.
(read_paint): Handle new enumeration values.
2022-07-09 05:59:41 +02:00
Dominik Röttsches d134b9e37b [sfnt] Support for 'COLR' v1 variable translate.
* src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration value
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSLATE`.
(read_paint): Handle new enumeration value.
2022-07-09 05:44:58 +02:00
Dominik Röttsches 8ec531c26c [sfnt] Support for 'COLR' v1 variable transforms.
* src/sfnt/ttcolr.c (FT_PaintFormat_Internal): New enumeration value
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_TRANSFORM`.
(read_paint): Handle new enumeration value.
2022-07-09 05:43:28 +02:00
Dominik Röttsches 9c4ad2a901 [sfnt] Deltas for 'COLR' v1 gradient coordinates.
* src/sfnt/ttcolr.c (read_paint) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Read and
apply deltas to radial, linear, and sweep gradient coordinates such as 'p0',
'p1', 'p2', 'center', 'radii', and 'angles'.
2022-07-09 05:41:27 +02:00
Dominik Röttsches 3414fef74f [sfnt] Support variable 'COLR' v1 color lines.
* include/freetype/ftcolor.h (FT_ColorStopIterator): Add field
`read_variable` to indicate whether a variation index base should be read.

* src/sfnt/ttcolr.c: (FT_PaintFormat_Internal): New enumerations
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_LINEAR_GRADIENT`
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_RADIAL_GRADIENT`, and
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_SWEEP_GRADIENT`.
(read_color_line): New parameter `read_variable`; update callers.
(read_paint): Handle new enumerations.
2022-07-08 11:51:07 +02:00
Dominik Röttsches 7c151abb69 [sfnt] Apply variation deltas to `PaintVarSolid`.
* src/sfnt/ttcolr.c (FT_PaintFormat_Internal_): New enumeration
`FT_COLR_PAINTFORMAT_INTERNAL_VAR_SOLID`.

(get_deltas_for_var_index_base) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: New
function to retrieve an array of delta values, which will be used for most
of 'COLR' v1 variation formats (in follow-up commits).

(read_paint): Add `face` parameter; update caller.
Handle `FT_COLR_PAINTFORMAT_INTERNAL_VAR_SOLID`.
2022-07-07 19:48:19 +02:00
Dominik Röttsches 8a9192f68e [sfnt] Check safety of cast to `TT_Driver` before accessing member.
* src/sfnt/ttcolr.c (VARIABLE_COLRV1_ENABLED): Access
`enable_variable_colrv1` only if driver class matches.
2022-07-07 19:36:49 +02:00
Stephen Holdaway d5d048bbfe doc: Clarify description of `FT_Stream_IoFunc`.
The existing documentation comments on `FT_Stream_IoFunc` hinted at the dual
seek/read behavior required for custom stream implementations to work, but
it didn't explicitly explain it.  Without looking at the internals of
FreeType, it was easy for someone to assume their implementation should
handle both seek and read operations all the time.  If this is done, you get
a variety of errors, but mostly just `Unknown_File_Format` (error code
0x02).
2022-07-06 12:55:40 +02:00
Dominik Röttsches 31b14fd4dc [sfnt] Load variation store for 'COLR' v1.
* src/sfnt/ttcolr.c: Include `ttobjs.h` temporarily.
(VARIABLE_COLRV1_ENABLED): New temporary macro to detect whether variable
COLRv1 is enabled.
(Colr): New fields `var_store` and `delta_set_idx_map`.
(tt_face_load_colr, tt_face_free_colr) [VARIABLE_COLRV1_ENABLED]: Load and
free variation store data using the functions from the Multiple Masters
service.
2022-07-04 16:34:02 +02:00
Chris Liddell 1a242558be [base] Improve error handling in `FT_GlyphLoader_CheckPoints`.
If `FT_GlyphLoader_CreateExtra` returns an error (and a couple of other
places), `FT_GlyphLoader_CheckPoints` would propagate the error immediately,
rather than cleaning up the partially set up `FT_GlyphLoader`.  As a
consequence, a subsequent attempt to create a glyph could result in a crash.

* src/base/ftgloadr.c (FT_GlyphLoader_CheckPoints): Ensure all the error
conditions exits are consistent, eventually calling `FT_GlyphLoader_Reset`.
2022-07-03 06:58:23 +02:00
Thomas Sondergaard 55a97b0cb1 CMakeLists.txt: Provide both 'freetype' and 'Freetype::Freetype' targets.
FreeType can be located by consuming projects that use
`find_package(Freetype)` either via the old `MODULE` path (which uses
`FindFreetype.cmake` supplied by CMake), or via the new `CONFIG` path (which
uses `freetype-config.cmake` as supplied by this project).  Up to this point
the CMake module has supplied the target `Freetype::Freetype` and the config
file provided by this project the target `freetype`.  Now we supply both
`freetype` and `Freetype::Freetype` so that consuming projects can always
use the target `Freetype::Freetype` regardless of what path was taken by
`find_package(Freetype)`.

Fixes #1165.
2022-07-03 06:48:15 +02:00
Werner Lemberg 31005d98a4 include/freetype/ftmm.h: Improve documentation. 2022-07-02 09:34:13 +02:00
Dominik Röttsches bec4ef415e [base] Round values in `FT_MulAdd_Fix`.
This avoids regressing Blink layout tests and makes `FT_MulAdd_Fix` delta
retrieval implementation consistent with the previous implementation, which
used `FT_fixedToInt` and included rounding.

* src/base/ftcalc.c (FT_MulAdd_Fix): Implement it.
Also fix remaining `temp` initialization compilation issue.

Fixes #1169.
2022-07-01 14:01:08 +02:00
Werner Lemberg de27955c2a Minor formatting. 2022-07-01 06:33:50 +02:00
Dominik Röttsches 0607e0e959 Fix initialisation of temp variable in new FT_MulAddFix
src/truetype/ttgxvar.c (FT_MulAddFix): Initialise `temp`.
2022-06-30 10:55:50 +03:00
Dominik Röttsches dece953516 [truetype] Perform variation store delta computation with 64-bit precision.
* include/freetype/internal/ftmmtypes.h (FT_ItemVarDelta): Make type
explicitly 32-bit.
* include/freetype/internal/services/svmm.h
(FT_Var_Get_Item_Delta_Func): Change return type to `FT_ItemVarDelta`
* truetype/ttgxvar.h (tt_var_get_item_delta): Change return type to
`FT_ItemVarDelta`.
* truetype/ttgxvar.c (tt_var_get_item_delta): Store scalars and deltas
to intermediate array, perform computation using new method
`FT_MulAddFix`.
2022-06-29 20:27:11 +02:00
Dominik Röttsches 15fef219d6 New function `FT_MulAddFix` to compute the sum of fixed-point products.
This function, based on the code of `FT_MulFix`, uses 64-bit precision
internally for intermediate computations.

* include/freetype/internal/ftcalc.h, base/ftcalc.c (FT_MulAddFix):
Implement it.
2022-06-29 20:12:04 +02:00
Werner Lemberg 2db58e061e CMakeLists.txt: Move inclusion of `FindPkgConfig` down.
It must come after `CMAKE_TOOLCHAIN_FILE`.

Fixes #1167.
2022-06-22 12:16:00 +02:00
Dominik Röttsches 117df36b4c [sfnt] Upgrade stop_offset to FT_Fixed from FT_F2Dot14 2022-06-22 09:33:20 +00:00
Alexei Podtelezhnikov 5e48c88d57 * docs/CHANGES: Announce impending Infinality removal. 2022-06-21 17:34:29 +00:00
Alexei Podtelezhnikov 9006ff7d10 * ttgload.c (TT_Process_Composite_Glyph): Fix a signedness warning. 2022-06-21 17:10:56 +00:00
Werner Lemberg 2848378be5 s/fixed point/fixed-point/ 2022-06-21 17:08:04 +02:00
Werner Lemberg 40c6f97326 .gitlab-ci.yml: Correctly upgrade `meson`. 2022-06-21 14:45:42 +02:00
Dominik Röttsches 4b6f92e6b3 Proposal: Feature control for variable COLRv1
* include/freetype/ftdriver.h (variable-color-v1 property): Add documentation
for variable-colr-v1 property.
* src/truetype/ttdriver.c (tt_property_set): Ingest variable-control property
when called, set to enable_variable_colrv1 driver flag.
* src/truetype/ttobjs.h (TT_DriverRec): Add enable_variable_colrv1 flag.
2022-06-21 12:25:46 +03:00
Xavier Claessens b861b24157 [meson] Disable FreeType in HarfBuzz fallback.
This avoids cyclic subproject configuration when the 'harfbuzz' feature is
enabled, or `--wrap-mode=forcefallback` is used, but HarfBuzz is built as a
subproject.  HarfBuzz does the same and disables HarfBuzz support when
configuring FreeType as a subproject.

* meson.build (harfbuzz_dep): Implement it.

* subprojects/harfbuzz.wrap: New file.

* .gitlab-ci.yml [windows meson]: Use latest version of the meson 0.59
  series, which has a necessary bug fix to make CI work.
2022-06-21 08:09:16 +02:00
Alexei Podtelezhnikov 47103b2f19 [truetype] Clean up phantom point accounting.
This formalizes that the phantom points appended in the outline
do not increase its point count, nor are they tagged or included
in any additional contours.  Only their coordinates are stored.
They are counted in the glyph zone, however.

* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Infer `n_points`
from the outline size plus four phantom points.
* src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Remove this
argument.
* src/truetype/ttgload.c (tt_prepare_zone): Add phantom four.
(TT_Process_Simple_Glyph, load_truetype_glyph): Update all callers.
2022-06-18 23:09:17 -04:00
Alexei Podtelezhnikov 705f416184 [truetype/GX] Clean up phantom point adjustment.
This moves phantom point and advance variation adjustment next to
calculations. The logic stays the same, HVAR and VVAR take priority.

* src/truetype/ttgload.c (load_truetype_glyph): Move it from here...
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): ... to here
and check for HVAR and VVAR presence outside the main loop.
2022-06-18 23:02:26 -04:00
Ben Wagner f7daf9d293 [stream] Fix reading s32 when long is s64
`FT_READ_LONG`, `FT_GET_LONG`, and related macros did not return
negative values when `long` is more than 32 bits. `FT_Stream_ReadULong`
would read four bytes into the LSB of an `FT_ULong` and return that.
Since this can never set the MSb of the `FT_ULong` when `FT_ULong` is
more than 32 bits the cast to `FT_Long` never resulted in a negative
value.

Fix this by modifying `FT_Stream_Read*` to return a type of the same
size as the bytes it is reading and changing the `FT_READ_*` and
`FT_GET_*` macros to cast to the same type returned by `FT_Stream_Read*`
but with the correctly signed type (instead of casting to what is
assumed to be the type of `var` which will happen automatically anyway).

There exist a few cases like with the `OFF3` variants where there isn't
generally a type with the correct size. `FT_PEEK_OFF3` works around this
loading the bytes into the three most significant bits and then doing a
signed shift down. `FT_NEXT_OFF3` also already worked correctly by
casting this signed value to another signed type. `FT_Stream_GetUOffset`
works correctly but one must be careful not to attempt to cast the
returned value to a signed type. Fortunately there is only
`FT_GET_UOFF3` and no `FT_GET_OFF3`.

All of these cases are handled correctly when reading values through
`FT_Stream_ReadFields` since it generically computes the signed value
through an `FT_Int32`. This change is essentially doing the same for
these macros.

* include/freetype/internal/ftstream.h (FT_NEXT_*, FT_GET_*, FT_READ*):
Update macros and return types to use fixed size types for fixed size
values.

* src/base/ftstream.c (FT_StreamGet*, FT_StreamRead*): Dito.

Issue: #1161
2022-06-18 12:58:23 -04:00
Alexei Podtelezhnikov d9b8a69e9a [truetype/GX] Fix an old typo.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Vertical
advance is measured along y-coordinate.
2022-06-16 22:13:25 -04:00
Alexei Podtelezhnikov 9c706dcca7 [truetype/GX] Clean up advance adjustment (Brrr).
* src/truetype/ttgload.c (load_truetype_glyph): Remove remaining code.
2022-06-16 16:11:51 +00:00
Ben Wagner 9079521002 [type1] Directly search for eexec in private dict
This code originally just searched for `eexec`. This was later modified
to check that the `eexec` found is valid (not in a string or comment).
This was done by searching for `eexec` as before and then, for each
`eexec` found, searching from the beginning using the correct parsing to
see if the `eexec` was still found. If the private dictionary is large
and contains many copies of `eexec` which are not valid, the initial
part of the private dictionary is scanned once for each, potentially
leading to n^2 parsing time.

Instead of finding an initial `eexec` and then re-parsing to discover if
it is valid, drop the initial search for `eexec` and just parse to find
a valid `eexec`. This is strictly faster since the validation must
happen anyway and avoids restarting from the beginning each time an
`eexec` is found in the data.

* src/type1/t1parse.c (T1_Get_Private_Dict): avoid n^2 parsing

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1328883
2022-06-16 14:51:57 +00:00
Alexei Podtelezhnikov d6fc8c6ba0 [truetype/GX] Clean up advance adjustment.
* src/truetype/ttgload.c (TT_Process_Simple_Glyph, load_truetype_glyph):
Move the advance adjustment from here...
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): ... to here and
simplify arguments.
* src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Update prototype
with fewer arguments.
2022-06-15 18:28:50 -04:00
Ben Wagner 8bb7722a53 [gzip] Handle inflate returning Z_NEED_DICT
When `inflate` returns `Z_NEED_DICT` this is currently not reported as
an error and callers may assume that the decompression succeeded when it
did not. In particular, a compressed table in a woff file may not
actually be decompressed and written as expected, leaving the backing
memory for the expanded table uninitialized.

* src/gzlip/ftgzip.c (FT_Gzip_Uncompress): treat `Z_NEED_DICT` as
indicating invalid data since there is no means to provide a dictionary.

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335712
2022-06-14 04:49:29 +00:00
Ben Wagner 58395dd200 [woff] Don't allocate table entries until needed
* src/sfnt/sfwoff.c (woff_open_font): delay allocating space for the
table entries until they are actually written out with the data.
2022-06-13 15:32:28 -04:00
Alexei Podtelezhnikov 8b6bcc92c5 * src/sfnt/sfwoff2.c (woff2_open_font): Partial revert.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47981.
2022-06-12 09:04:13 -04:00