Commit Graph

212 Commits

Author SHA1 Message Date
Qunxin Liu 8c5c81746d [subset] fix find_duplicate_features
We should check each feature against all other features with the same
tag for duplicates.
2021-09-22 15:35:38 -06:00
Qunxin Liu 37379f8f7d [subset] fox for (Chain)ContextFormat3: subset lookupRecord
skip copying a lookupRecord if lookup referenced in the lookupRecord is
not retained after subset
2021-09-08 13:55:21 -06:00
Behdad Esfahbod fad452bffb [set] Move main functionality into hb_bit_set_t
To add inversion on top in hb_invertible_set_t and use that as hb_set_t.
2021-08-17 10:47:18 -06:00
Behdad Esfahbod 30579f5a37 [set] Document & use open-ended del_range() 2021-07-29 11:19:13 -06:00
Behdad Esfahbod 2337f0d047 Internally use hb_malloc/.../hb_free instead of malloc/.../free
Redefining those stock names as macros was conflicting with gcc 10
headers.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3044
2021-07-08 10:54:09 -07:00
Garret Rieger 085aa65e09 [subset] Convert offset serialization in gsubgpos and gdef to serialize_serialize(). 2021-06-14 16:47:45 -07:00
Behdad Esfahbod bc33b87f5e [set] Use references, not pointers, in internal C++ API 2021-06-09 11:54:12 -06:00
Garret Rieger 8b686afeb5 [subset] add unlikely(). 2021-04-06 12:34:44 -06:00
Garret Rieger 64122b5a44 [subset] don't visit lookup if covered glyph set has failed.
If covered glyph set is in error then the same lookup can be recursed into repeatedly potentially causing a fuzzer timeout. Fixes: https://oss-fuzz.com/testcase-detail/5416421032067072.
2021-04-06 12:34:44 -06:00
Garret Rieger c35d786397 [subset] never drop the 'pref' feature.
Never ever drop feature 'pref', even if it's empty. Harfbuzz uses it to choose the shaper for Khmer.
2021-04-01 16:27:35 -06:00
Garret Rieger b10741ca7f [subset] when closing glyphs in context lookups don't use a current glyph set if a lookup is already applied. 2021-03-31 21:03:33 -06:00
Behdad Esfahbod 5639e253f9 Add Array16Of<> 2021-03-31 16:04:43 -06:00
Behdad Esfahbod 5efe360986 Rename (Unsized)OffsetListOf 2021-03-31 15:33:22 -06:00
Behdad Esfahbod 6c4e0491d7 s/OffsetArrayOf/Array16OfOffset16To/g 2021-03-31 15:31:32 -06:00
Behdad Esfahbod 9b4b58493b Fixup for recent OffsetTo<> changes 2021-03-31 13:27:21 -06:00
Behdad Esfahbod ad28f973f3 Rename offset types to be explicit about their size
Add Offset16To<>, Offset24To<>, and Offset32To<> for most use-cases.
2021-03-31 13:00:07 -06:00
Garret Rieger adca4ce071 [subset] fixes https://oss-fuzz.com/testcase-detail/6173520787800064.
Caused by incorrect bounds check in glyph closure for context lookups.
2021-03-30 15:44:41 -06:00
Garret Rieger 9f77a0c1ff [subset] use hb_set_clear to avoid calling clear() on null pool set. 2021-03-30 15:12:52 -06:00
Garret Rieger 752e393ad2 [subset] avoid calling clear on null pool set. 2021-03-30 15:12:52 -06:00
Behdad Esfahbod 9ed5f04a70 [subset] Simplify recent out-of-memory fixes
By checking return status of map->set().
2021-03-29 18:14:30 -06:00
Garret Rieger 52df6b9fd8 [subset] check for set insertion success. 2021-03-29 17:41:07 -06:00
Garret Rieger c6adb90a27 [subset] fix nullptr deref. 2021-03-29 17:41:07 -06:00
Qunxin Liu 56ca435787 [subset] fix for collect_features and remove_redundant_lamngsys
previously remove_redundant_sys () is missing in harfbuzz, after
redundant langsys removal, some features are removed as well in
prune_features() in fonttools. This change is trying to get the same
result between harfbuzz and fonttools.
2021-03-17 14:24:04 -07:00
Qunxin Liu 0e1c0fa404 [subset] optimize glyph closure method: step 5
add testcase and some fixes
2021-03-17 15:22:07 -06:00
Qunxin Liu b8a58a0c0b [subset] optimize glyph closure method: step 4
optimize recurse_lookups in Context/ChainContext
glyph closure, only the glyphs that the parent lookup
can apply the recursion to can participate in recursing
the lookup.
2021-03-17 15:22:07 -06:00
Qunxin Liu b4fc593c3c [subset] optimize glyph closure method: step1
Previous GSUB glyph closure is done by recursively visiting
all reachable lookup tables that apply to any glyphs in the
current/input glyph set, but actually only the glyphs that
the parent lookup can apply the recursion to can participate
in recursing the lookup. This is step 1 for glyph closure
optimization:
1. Add stack of currently active glyph set pointers into hb_closure_context_t
2. Update closure() method in simple GSUB tables to use
this stack in order not to change current glyph set at different stages
of recursion
3. Add function may_have_non_1to1() to GSUB tables
2021-03-17 15:22:07 -06:00
Behdad Esfahbod 8450f43ae1 [buffer] HB_NODISCARD next_glyph() 2021-03-15 16:01:35 -06:00
Behdad Esfahbod 34a1204f10 [buffer] HB_NODISCARD output_glyph()
Also, generalize and use replace_glyphs() in morx where output_glyph() was used
in a loop.
2021-03-15 16:01:35 -06:00
Behdad Esfahbod cac6c86d2f [buffer] HB_NODISCARD move_to() 2021-03-15 13:56:46 -06:00
Behdad Esfahbod 3f1998a065 [buffer] HB_NODISCARD replace_glyph() 2021-03-15 13:33:44 -06:00
Behdad Esfahbod 2902529b92 [subset] Fix HB_TINY build
Fixes https://github.com/harfbuzz/harfbuzzjs/issues/34#issuecomment-789247723
2021-03-02 15:05:39 -07:00
Behdad Esfahbod 83b66bfb66 Another try to fix narrowing error
../src/hb-ot-layout-gsubgpos.hh: In instantiation of ‘void OT::ChainRule::serialize_array(hb_serialize_context_t*, OT::HBUINT16, Iterator) const [with Iterator = hb_map_iter_t<hb_array_t<const OT::IntType<short unsigned int> >, const hb_map_t*&, (hb_function_sortedness_t)0, 0>; typename hb_enable_if<hb_is_iterator_of<Lhs, typename Lhs::item_t>::value>::type* <anonymous> = 0; OT::HBUINT16 = OT::IntType<short unsigned int>]’:
../src/hb-ot-layout-gsubgpos.hh:2341:30:   required from here
../src/hb-ot-layout-gsubgpos.hh:2326:15: error: narrowing conversion of ‘(unsigned int)g’ from ‘unsigned int’ to ‘short unsigned int’ inside { } [-Werror=narrowing]
       c->copy (HBUINT16 {g});
       ~~~~~~~~^~~~~~~~~~~~~~

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-23 13:04:38 -07:00
Behdad Esfahbod f4f35a4d5f [constexpr] Use initializer instead of assignment 2021-02-22 22:32:42 -07:00
Behdad Esfahbod 6d94194497 Use auto in range-for-loop more 2021-02-19 17:10:06 -07:00
Garret Rieger 08a4997fde [subset] Add subset support for Extension lookups (GPOS 9, GSUB 7). 2021-02-11 13:41:31 -07:00
Behdad Esfahbod dfa9d7acdc [minor] Use serializer->propagate_error() to simplify code 2021-02-11 11:19:51 -07:00
Behdad Esfahbod d7e2a51de2 [minor] Add unlikely() when checking for error 2021-02-11 10:55:03 -07:00
Behdad Esfahbod 1da75afbe8 [minor] Add unlikely() 2021-02-10 00:03:41 -07:00
Behdad Esfahbod 6e1afac64b [minor] Rename internal variable
To address review comment:
https://github.com/harfbuzz/harfbuzz/pull/2699#discussion_r573370781
2021-02-09 18:48:46 -07:00
Behdad Esfahbod 6a3fd94f3b
Merge pull request #2699 from googlefonts/gpos_8
[subset] Add a more complex layout subsetting test case and fix the issues it exposed.
2021-02-09 20:49:04 -05:00
Garret Rieger 8f47dd5779 [subset] don't set lookup visited in closure_lookups_context_t::recurse.
- Lookup::closure_lookups also checks if the lookups visited and sets the lookup to visited. If we set visited in 'recurse' then Lookup::closure_lookups will fail to recurse into the children of the lookup.
- Also when copying ChainRule's skip LookupRecord's that point to lookups which aren't retained. This matches FontTool's behaviour.
2021-02-09 20:34:52 -05:00
Behdad Esfahbod 53806e5b83 Tiny improvement on previous commit
Functionally the same.
2020-11-25 11:51:37 -07:00
Dominik Röttsches a5f6f869e8 Drop layout table if layout lookup accelerator allocation failed
If the table is kept, when the table is present but only the accelerator
allocation failed, then we run into nullptr dereferences downstream in
hb_ot_map_t::apply when trying to access proxy.accels[i].

To fix this, instead of only setting lookup_count of accelerator_t
itself, drop the whole table to avoid hb-ot-map construction assuming
that the lookups will work correctly despite accelerator allocation
having failed.

Fixes:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24490
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24490
2020-11-25 10:18:04 -08:00
Garret Rieger 718bf5aab3 [subset] only keep features reachable from script in the final subset.
Matches fontTools behaviour.
2020-09-29 13:16:01 -07:00
Garret Rieger e583505334 [subset] Use plan->glyphset_gsub instead of plan->glyphset for GSUB/GPOS
This matches fontTools behaviour. glyphset_gsub does not contain gids added from closing over composite glyphs in glyf, since these cannot particpate in GSUB/GPOS processing.
2020-09-29 11:16:15 -07:00
Garret Rieger 940e1c6f98 [subset] ChainContextFormat3 - don't subset glyph sequences.
The backtrack, input, and lookahead sequence must be matched in their entirety so these sequences should not be subset. If any of the coverage tables in a sequence subsets to empty then the whole subtable should be dropped since it's not possible for this lookup to be activated.
2020-09-28 17:22:01 -07:00
Garret Rieger e31c2690f8 [subset] remove unnecessary returns. 2020-09-28 16:51:25 -07:00
Garret Rieger ad241f9917 [subset] check that sub rules in ChainContextFormat 1 and 2 intersect the glyphs set before recursing during closure lookups. 2020-09-28 15:26:13 -07:00
Garret Rieger 9fad540245 [subset] check that sub rules in ContextFormat 1 and 2 intersect the glyphs set before recursing during closure lookups. 2020-09-28 13:24:25 -07:00
Garret Rieger a5c0ec7516 [subset] For [Chain]ContextFormat3 make sure the sub table intersects the retained glyphset before recursing to its lookups.
Otherwise the lookup closure will potentially pull in lookups which cannot be accessed via the retained glyph set.
2020-09-25 14:57:20 -07:00