Commit Graph

206 Commits

Author SHA1 Message Date
Behdad Esfahbod ed023f66df Enable -Wformat-signedness
And fix the codebase.
2023-01-12 17:04:24 -07:00
Behdad Esfahbod cfb672f1e5 [glyf] Revert sign of advance widths back 2023-01-12 11:59:18 -07:00
Behdad Esfahbod 65d3db375c [subset-plan] Simplify user_axes_location allocation 2023-01-11 12:36:54 -07:00
Behdad Esfahbod 75b33cb04b [subset-plan] Simplify hmtx_map / vmtx_map allocation 2023-01-11 12:24:35 -07:00
Behdad Esfahbod 33ce3a0d44 [subset] Minor adjust a couple types 2023-01-11 12:21:26 -07:00
Behdad Esfahbod c8486b6301 [open-type] Add to_int to fixed types
To make sure we don't accidentally forget to_float().
As we did recently in COLRv1 code.
2023-01-07 14:15:17 -07:00
Behdad Esfahbod 2eacc37e08 [vector] Add internal API for exact-size allocation
Use it from a couple of places.
2022-12-31 12:30:31 -07:00
Behdad Esfahbod ae208963df Add hb-limits.hh 2022-12-26 12:30:39 -07:00
Behdad Esfahbod f3985d9482 [paint] Fix drawing non-color glyphs 2022-12-23 13:37:59 -07:00
Matthias Clasen c221933977 [paint] Preserve foreground information 2022-12-23 13:37:59 -07:00
Matthias Clasen 6387004cad [paint] Simplify api
Drop the hb_paint_context_t struct from the API, and
only pass the font where we need it.
2022-12-23 13:37:59 -07:00
Matthias Clasen 71bd5a0dfc [paint] Resolve colors
We don't need to pass the index/alpha pairs to
client callbacks, and can just resolve the colors
internally.

Update test results.
2022-12-23 13:37:59 -07:00
Matthias Clasen 9be01b6bff [paint] Pass hb_paint_context_t along
Replace the font argument with a hb_paint_context_t
that carries the font, the palette index and the
foreground color.

The hb_font_paint_glyph() api now takes the palette
index and the foreground color as extra arguments.

Update all callers and regenerate test results.
2022-12-23 13:37:59 -07:00
Matthias Clasen 97224f3b63 [paint] Pass font to all callbacks
This will lead to easier implementations.

At the same time, we change the push_clip_glyph
callback to use the font as-is, no unscaling needed.

Update all callers and expected test results.
2022-12-23 13:37:59 -07:00
Matthias Clasen 686e627bdf [paint] Set up root transform in one place
Instead of spreading this in all the tables,
make hb_paint_funcs_t provide a push/pop_root_transform
that does all the setup.
2022-12-23 13:37:59 -07:00
Behdad Esfahbod 601a596ca0 [paint] Fix include path 2022-12-23 13:37:59 -07:00
Matthias Clasen 2edd771cf5 glyf: Implement paint_glyph 2022-12-23 13:37:59 -07:00
Behdad Esfahbod 9a0ebd2b2a [glyf] Fix slant-scaling in GlyphHeader too 2022-12-22 10:21:50 -07:00
Behdad Esfahbod b0abbfd868 [font] Centralize glyph-extents scaling
Needs more testing...

Some rounding was removed, namely in cff1 and cff2.
2022-12-22 07:32:15 -07:00
Behdad Esfahbod 97b8ada865 [varc] Reset component coordinates to that of the font
Fixes https://github.com/harfbuzz/boring-expansion-spec/issues/78
2022-12-21 19:52:20 -07:00
Behdad Esfahbod 9b5b4da0e4 [varc] Set coordinates as absolute values 2022-12-20 09:58:04 -07:00
Behdad Esfahbod 80e68f09c5 [VarC] Change rotation/skew representation
Fixes https://github.com/harfbuzz/boring-expansion-spec/issues/77
2022-12-19 19:17:04 -07:00
Behdad Esfahbod 03a1685693 [VarC] Change representation of scale from 4.12 to 6.10
Fixes https://github.com/harfbuzz/boring-expansion-spec/issues/76
2022-12-19 17:12:09 -07:00
Jordan Petridis 79285a9983
VarC: cast ints (#3934)
msvc is rightfully complaining that the types on the sides of
the ternary are not matching:

```
C:\pango\subprojects\harfbuzz\src\OT\glyf\VarCompositeGlyph.hh(317): error C2446: ':': no conversion from 'const OT::HBUINT16' to 'const OT::HBUINT8'
```
2022-12-13 11:14:20 -07:00
Behdad Esfahbod bd7cb384cf [VarC] Remove unused variable 2022-12-12 14:10:48 -07:00
Behdad Esfahbod 1b278c7658 [VarC] Update for new format
https://github.com/harfbuzz/boring-expansion-spec/issues/71
2022-12-12 13:57:05 -07:00
Behdad Esfahbod 6bb478eeeb [VarC] Clamp after addition 2022-12-12 11:39:06 -07:00
Behdad Esfahbod 80a5011eb6 [VarC] Fix coord setting
Those are additive.
2022-12-12 11:37:59 -07:00
Behdad Esfahbod 9ab2c8034e Revert "[glyf] Use component phantom points after transformation"
This reverts commit a756bd1944.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3929
2022-12-11 12:04:29 -07:00
Behdad Esfahbod bf2e817549 [VarComposites] Support GID24 2022-12-09 23:15:26 -07:00
Behdad Esfahbod 10d38dcdfd [varc] Change format slightly
Fixes https://github.com/harfbuzz/boring-expansion-spec/issues/70
2022-12-09 19:19:57 -07:00
Behdad Esfahbod 5cf0b9ae7d [varc] Mark as experimental feature with HB_NO_VAR_COMPOSITES 2022-12-09 18:59:43 -07:00
Behdad Esfahbod 82b4f3791e [coord-setter] Don't modify font coords 2022-12-09 18:46:33 -07:00
Behdad Esfahbod e9e503b80b [Glyph] Pass down coords to get_points 2022-12-09 18:42:46 -07:00
Behdad Esfahbod 8e46870093 [gvar] Take coords in instead of font in apply_deltas_to_points 2022-12-09 18:35:30 -07:00
Behdad Esfahbod 3caa42a4a7 Fix build after rebase 2022-12-09 14:48:41 -07:00
Behdad Esfahbod bbe59e4211 Whitespace 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 13deea7cbd [glyf/VarComposite] Clamp axis coordinates 2022-12-09 14:45:29 -07:00
Behdad Esfahbod a975be4c07 [glyf/VarComposite] Minor rename 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 1e71db2d26 [glyf/VarComposite] Fix transformation 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 1233be61d8 [glyf/VarComposite] Remove unneeded resize 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 1a906162cb [glyf/coord-setter] Fix memory issue 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 7efd68da39 [glyf/VarComposite] Set coordinates
Code is untested but complete!
2022-12-09 14:45:29 -07:00
Behdad Esfahbod 4ec7781497 [glyf] Move coord-setter to its own file 2022-12-09 14:45:29 -07:00
Behdad Esfahbod dadb4ed71d [glyf/VarComposite] More, almost there 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 0a939b48a6 [glyf/VarComposite] Implement more 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 65cc3b5e2b [glyf/VarComposite] More 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 60d959a6e7 [glyf/VarComposite] Add use_my_metrics() 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 575d99406a [glyf] Flesh out VarCompositeGlyph 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 21f671bc45 [glyf] Add stub VarCompositeGlyph 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 435c5eeffe [glyf] Split composite-iter 2022-12-09 14:45:29 -07:00
Behdad Esfahbod 1024a013fd [glyf] Add CoordSetter 2022-12-09 14:45:29 -07:00
Behdad Esfahbod aa7f5e3742 [subset] Conditionalize call to hb_font_set_variations 2022-12-04 15:33:18 -07:00
Behdad Esfahbod 6f133ccfde [glyf] Fix build with HB_NO_VERTICAL 2022-11-24 12:59:55 -07:00
Garret Rieger 81640fdffe [subset] fix leaked font in glyf::subset(...) 2022-11-23 13:41:52 -07:00
Behdad Esfahbod 1e8f1ac677 [subset-glyf] Micro-optimize array access 2022-11-23 13:20:48 -07:00
Behdad Esfahbod 356d135ed6 [subset-glyf] Reduce roundf calls
Saves 7% on MPLUS1-Variable/6000 benchmark.
2022-11-23 13:20:48 -07:00
Garret Rieger 463ae07e99 [subset] In the preprocess subset call always use long loca.
Long loca is needed so that we can store the trimmed glyph bytes to allow us to safely skip trimming in the later subset.
2022-11-23 12:52:55 -07:00
Behdad Esfahbod 299ec902eb [glyf] Move instanciation to serialize() 2022-11-22 16:03:02 -07:00
Behdad Esfahbod d8d881f22d [subset-glyf] Don't create a second glyf accelerator 2022-11-22 15:24:16 -07:00
Behdad Esfahbod 7560930070 [glyf] Add _create_font_for_instancing 2022-11-22 15:22:25 -07:00
Behdad Esfahbod 40634ceeb0 [glyf] Adjust data types 2022-11-22 15:07:16 -07:00
Behdad Esfahbod ba0d28ea36 [glyf] Fix font error check 2022-11-22 15:01:48 -07:00
Behdad Esfahbod 04c525019c [glyf] Use a malloc instead of calloc 2022-11-22 14:54:55 -07:00
Behdad Esfahbod 024aa81805 [glyf] Micro-optimize encode_coord 2022-11-22 14:51:42 -07:00
Behdad Esfahbod b6694597f9 [glyf] Micro-optimize encode_flag() 2022-11-22 14:49:01 -07:00
Behdad Esfahbod d47cfe7936 [glyf] Minor use operator ++ 2022-11-22 14:45:04 -07:00
Behdad Esfahbod 03e6bde790 [glyf] Minor adjustment to lastflag handling
No logic change.
2022-11-22 14:40:50 -07:00
Behdad Esfahbod 0ca9fda889 [glyf] Remove misplaced comment 2022-11-22 14:39:10 -07:00
Behdad Esfahbod 4afcdf675b More hb_memcpy 2022-11-22 12:56:48 -07:00
Behdad Esfahbod 1758ee6646 [glyf] Minor write loop more idiomatically 2022-11-22 10:55:16 -07:00
Behdad Esfahbod b567ce51d3 [subset] Don't trim glyf's again if preprocessed
Speeds up M1/10000 benchmark by 30%!
2022-11-22 10:55:08 -07:00
Behdad Esfahbod f2b5db700f [vector] Remove .sub_array () 2022-11-16 21:22:57 -07:00
Behdad Esfahbod 477d71724c [glyf] Limit points in a glyf to 10000 roughly
Only enforced when components are being expanded.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3838
2022-10-26 13:11:47 -06:00
Behdad Esfahbod a756bd1944 [glyf] Use component phantom points after transformation 2022-10-13 17:18:19 -06:00
Behdad Esfahbod 82d19c08fc Revert "[glyf/Composite] Remove phantom points when not needed anymore"
This reverts commit 527e63a3bd.
2022-10-13 17:17:03 -06:00
Behdad Esfahbod 527e63a3bd [glyf/Composite] Remove phantom points when not needed anymore 2022-10-13 17:13:40 -06:00
Garret Rieger 8f1bf23cc9 [subset] optimize glyf subsetting w/ retain gids.
When retain gids is enabled the subset plan may require the output of many empty glyphs. This change optimizes the glyf subsetting code when the number of retained glyphs << number of output glyphs. Unnessecary lookups to the glyph map are reduced by iterating through the glyph map instead of the output glyph set.
2022-09-29 15:44:49 -06:00
Qunxin Liu e94fe2adf3 [instance] minor optimizations to glyf instancing 2022-09-29 12:14:43 -06:00
Qunxin Liu b90ce34a25 [instance] fix for non-empty .notdef glyph metrics update
we need pass in source glyph's outline data to calculate boundaries, and
then drop the outline data if notdef-outline is specified.

Also disable shifting points for instancing in get_points () API
2022-09-29 12:14:43 -06:00
Qunxin Liu 8f84c58a34 [instance] don't copy phantom points from component
No need to consider USE_MY_METRICS for instancing
2022-09-01 09:44:28 -07:00
Qunxin Liu 58dbc00162 [instance] Fix compiling Composite glyph bytes
The x/y offset encoded with int8 originally might overflow after deltas
are applied. So we cannot just copy and update old values.
2022-09-01 09:44:28 -07:00
Qunxin Liu 8b7e2a1373 [instance] we need to update hmtx/vmtx values even for empty glyphs
Update metrics using the 4 phantom points
2022-09-01 09:44:28 -07:00
Behdad Esfahbod 84d33a1ed8 [glyf] Fix compiler warning 2022-08-23 13:13:13 -06:00
Qunxin Liu ac0e22fa8e [instance] update glyf/hmtx/vmtx tables 2022-08-22 09:29:37 -07:00
Behdad Esfahbod b57ea3b053 Revert "[iter] Use && in uses of is_source_of"
This reverts commit ccbba667a9.
2022-08-05 14:29:27 -06:00
Behdad Esfahbod ccbba667a9 [iter] Use && in uses of is_source_of 2022-08-05 11:51:51 -06:00
Behdad Esfahbod 8fb7cc1c63 [iter] Use && in is_sink_of uses 2022-08-05 11:49:29 -06:00
Behdad Esfahbod e51526bf06 [CompositeGlyph] Add HB_NO_BEYOND_64K 2022-07-28 09:53:30 -06:00
Behdad Esfahbod 7549d447ba [>64k:glyf] Implement composites for >64k
Implements https://github.com/be-fonts/boring-expansion-spec/issues/42
2022-07-12 13:42:52 -06:00
Behdad Esfahbod 09de94788b [>64k:glyf] Hid composite glyphIndex 2022-07-12 13:42:52 -06:00
Behdad Esfahbod b0cb9a1a63 Make get_leading_bearing return bool
Fixes https://github.com/harfbuzz/harfbuzz/issues/3496

Part of supporting >64k glyphs correctly.
2022-07-03 15:32:32 -06:00
Behdad Esfahbod 115e1a03e7 [glyf] Relax condition for matching number of coords 2022-07-03 14:45:12 -06:00
Behdad Esfahbod 800760c5bd [glyf] Rename get_extents functions for clarity 2022-07-03 13:21:06 -06:00
Behdad Esfahbod ab327f93b7 [glyf] Fix another bug with scaling
Of advances this time.

That codepath is never exercised though, if font has HVAR table.
2022-07-03 13:17:03 -06:00
Behdad Esfahbod f46ddeba48 [hmtx/glyf] Rename side-bearing functions for clarity 2022-07-03 13:12:49 -06:00
Behdad Esfahbod b2d60cbd6e [glyf] Rename advance functions for clarity 2022-07-03 12:56:48 -06:00
Behdad Esfahbod 35c00c1216 [hmtx] Rename advance functions for clarity 2022-07-03 12:54:17 -06:00
Behdad Esfahbod 6b82d4faa1 [glyf] Make an optional argument non-optional 2022-07-03 12:45:27 -06:00
Behdad Esfahbod 3ef590808f [glyf] Internal flip a variable 2022-07-03 12:44:24 -06:00