Commit Graph
77 Commits
Author SHA1 Message Date
Garret Rieger 240a7d7b8b Fix incorrect add_object sizes. (#6267) 2026-09-17 18:54:44 -06:00
Garret Rieger 2f291a46ae Convert repacker and graph code to utilize to hb_result_t.
Converts all error handling in the repacker/graph code to use hb_result_t.
2026-09-04 17:08:08 -06:00
Garret Rieger 7eac03d53c Add missing error handling for fallible operations in the repacker. 2026-08-27 14:22:26 -06:00
Garret Rieger 197d38a8a3 [subset] Convert repacker graph traversals to BFS.
None of the traversals require DFS order so BFS can be used instead which eliminates the possibility of stack overflow. For the queue we re-use the existing ordering_scratch_ space to avoid allocating any additional memory. As a bonus this fixes a bug in find_32bit_roots() that was the result of DFS traversal order.

All of the directed traversal methods are unified to a single common implementation.
2026-07-31 18:05:07 -06:00
Qunxin Liu 2c875edbb6 [subset-repack] bug fixes (#6088)
* [subset-repack] fix potential out of bounds accesses

make sure we create a deep copy of the object before we mutate

* [subset-repack] fix is_shared(): only check real parents

* [subset-repack] add tests

* [subset-repack] apply AI proposed change

* address review comments

* [subset-repack] no need to duplicate shared liga_sets beforehand

Since we now would create a memory copy of the object before mutating
it, I think checking and duplicating shared liga_sets is not needed.
2026-07-21 11:49:06 -06:00
Behdad Esfahbod fc85680fec Revert "[subset-repack] bug fixes (#6077)"
This reverts commit 0b590d6b54.
2026-07-21 10:59:48 -06:00
Qunxin Liu 0b590d6b54 [subset-repack] bug fixes (#6077)
* [subset-repack] fix potential out of bounds accesses

make sure we create a deep copy of the object before we mutate

* [subset-repack] fix is_shared(): only check real parents

* [subset-repack] add tests

* [subset-repack] apply AI proposed change

* address review comments

* [subset-repack] no need to duplicate shared liga_sets beforehand

Since we now would create a memory copy of the object before mutating
it, I think checking and duplicating shared liga_sets is not needed.
2026-07-21 10:55:43 -06:00
Qunxin Liu babdb46be3 [repacker] bug fix for splitting shared subtables (#5686)
And fix splitting for ligatureSubst table with shared coverage table
2025-12-19 21:42:20 -07:00
Garret Rieger 54ab8f0df4 [repacker] make repacker object ids stable.
Prior to this change the object id for a vertex in the repacker graph is it's position in the topological ordering. As a result after each sorting the object ids change. This decouples the topological sorting from the object id assignments. A separate ordering list is retained. This simplifies handling around object ids which no longer needs to account for them shifting, and improves performance by eliminating the step of reassigned link object ids after each sort.
2025-09-15 16:34:44 -06:00
Behdad Esfahbod 75f919876f [src/test-*] Use hb_always_assert() which isn't compiled out under NDEBUG
Part of https://github.com/harfbuzz/harfbuzz/issues/5418
2025-07-25 03:00:38 -06:00
Garret Rieger e50d16f6f8 [repacker] During liga splitting re-use orphaned liga sets. 2025-07-10 00:58:49 +00:00
Garret Rieger cad418860a [repacker] fix bug where nodes with incoming virtual links could get orphaned.
When attempting to fix overflows nodes that have incoming edges from more than one parent can be duplicated. However, if all of these incoming links are virtual except for one duplicating it will effectively orphan it (one of the copies will be pointed to only by virtual links). Since parent book keeping is expensive we don't want to separately track virtual/real parents so instead just don't duplicate nodes that have at least one incoming virtual link.
2025-07-09 17:09:05 +00:00
Garret Rieger f5279200f3 [repacker] Add test which hits the move liga set pathway in clone_range(). 2025-07-08 22:50:48 +00:00
Garret Rieger 96fedd88fe [repacker] Fix handling of virtual links in liga table splitting. 2025-07-08 20:36:13 +00:00
Garret Rieger 5b47710f56 [repacker] Start implementing test for liga splitting. 2025-07-07 20:15:30 +00:00
Garret Rieger 69f9c29ec1 [repacker] add tests of serializer repack_last(). 2024-03-29 00:19:16 +00:00
Garret Rieger 01fc4a162f [repacker] Fix repacker test.
With class def size estimation changes this test is now able to pack closer to the limit.
2024-03-09 00:06:54 +00:00
Garret Rieger 7160c5b9e5 [repacker] add tests for multi-duplication.
Further improve the resolution attempt by pre-emptively raising priority of a duplicated shared node.
2023-12-05 16:25:12 -05:00
Garret Rieger 5587247d5b [repacker] create only one extension subtable per physical subtable.
During extension promotion when multiple lookups refer to a shared subtable node create and reuse a single extension subtable for it. Fixes: https://github.com/fonttools/fonttools/issues/3260.
2023-08-23 17:03:54 -06:00
Garret Rieger 554ed06fac [repacker] add cycle detection to the graph sort.
This allows us to bail early if the graph is not acyclic.
2022-12-01 21:52:37 +00:00
Behdad Esfahbod 59c45f6deb Use hb_memcpy instead of memcpy consistently 2022-11-22 12:54:50 -07:00
Garret Rieger 015ca5bc3c [repacker] fix compiler alignment warning. 2022-08-18 21:52:55 +00:00
Garret Rieger 683c5dd21e [repacker] further reduce base count. 2022-08-18 20:57:04 +00:00
Garret Rieger 5ddf41fc9c [repacker] speed up MarkBasePos test case by using a smaller basecount. 2022-08-18 20:28:05 +00:00
Garret Rieger a3ed9f9099 [repacker] fix graph comparison, and mark base pos generation for the tests. 2022-08-17 23:39:11 +00:00
Garret Rieger 19c51ed35c [repacker] Get mark base pos test working. 2022-08-17 19:15:55 +00:00
Garret Rieger 8c3db8bdfd [repacker] more progress on MarkBasePos tests. 2022-08-17 00:36:23 +00:00
Garret Rieger 1405f96b6f [repacker] change run_resolve_overflow_test to check for graph equivalence.
Replaces a check for an exact match on the final serialized bytes. The previous check enforced equivalent topological sorting between result and expected, but we only really care that the graph's are equivalent and don't overflow.
2022-08-15 23:48:00 +00:00
Garret Rieger 0e48a65d32 [repacker] estimate size of classDef1 and coverage during PairPos2 split point analysis. 2022-08-05 20:19:11 +00:00
Garret Rieger e1ab355056 [repacker] correct lookup link insertion. 2022-08-05 01:25:16 +00:00
Garret Rieger a733a9afa5 [repacker] insert new subtables immediately after the subtable they split from in the lookup. 2022-08-05 00:32:47 +00:00
Garret Rieger fdd1952c75 [repacker] PairPosFormat2 splitting - fix coverage and classdef splitting.
The old code was splitting based on coverage index, but should have been splitting on class value.
2022-08-04 19:21:16 +00:00
Garret Rieger 51a5060273 [repacker] add test for splitting a PairPos2 w/ device tables. 2022-08-03 22:30:42 +00:00
Garret Rieger 54fab21cb1 [repacker] get basic pair pos 2 split test working. 2022-08-03 21:57:37 +00:00
Garret Rieger 60d6ffb375 [repacker] always duplicate classDef2 when splitting a PairPos2.
Splits are done in a way that it shouldn't be possible to share the classDef2 between split PairPos2's so pre-emptively duplicate it.
2022-08-03 21:01:23 +00:00
Garret Rieger 6be152420f [repacker] add basic test for PairPos2 splitting. 2022-08-03 19:02:20 +00:00
psykose 04d28d94e5 [repacker] fix signedness of char in tests 2022-08-01 11:48:57 -06:00
Garret Rieger 674f0194a3 [repacker] add extension pairpos split test. 2022-07-29 22:21:31 +00:00
Garret Rieger 1d2516f037 [repack] get basic pairpos split test working. 2022-07-29 22:21:31 +00:00
Garret Rieger 4e7360f78d [repacker] begin adding tests for PairPosFormat1 splitting. 2022-07-29 22:21:31 +00:00
Garret Rieger f56e66f3f0 [repacker] for ext promotion choose lookups from highest subtables per byte to lowest.
Attempts to roughly maximize the number of subtables that are non-ext.
2022-07-26 12:22:17 -06:00
Garret Rieger 9d0b2da51b [repacker] count subtable size in each group of consecutive layers for extension promotion decisions.
Enforce that the following groups are all <64k in size:
- LookupList + Lookups
- Lookups + SubTables
- SubTables + Descendants
2022-07-26 12:22:17 -06:00
Garret Rieger 7de136f8a8 [repacker] add ext promotion test. 2022-07-26 12:22:17 -06:00
Garret Rieger 6fad6b4113 [repacker] add tests for special casing of 24bit offsets. 2022-07-06 19:18:27 +00:00
Garret Rieger 7078560e33 [repacker] extract graph serialization code into a seperate file. 2022-06-24 17:16:50 -06:00
Garret Rieger 20b02a672d [repacker] Begin splitting up the repacker implementation into several files. 2022-06-24 17:16:50 -06:00
Garret Rieger b32ca2a292 [subset-perf] remove sort_kahn from repacker.
Without an optimized FIFO queue implementation it's nearly as slow as the now optimized sort_shortest_distance.
2022-05-20 09:41:18 -06:00
Garret Rieger 441877f56a [repacker] add test case for using max priority to resolve an overflow. 2021-12-09 17:46:52 -07:00
Garret Rieger fa966bcc29 [repacker] create repacker output buffer after final length is known.
Don't rely on a buffer provided by the caller, as it may not be large enough.
2021-12-06 21:27:28 -07:00
Garret Rieger 9121ed0cec [subset] Improve sharing of Ligature subtables.
Ligature subtables use virtual links to enforce an ordering constraint between the subtables and the coverage table. Unfortunately this has the sideeffect of prevent the subtables from being shared by another Ligature with a different coverage table since object equality compares all links real and virtual. This change makes virtual links stored separately from real links and updates the equality check to only check real links. If an object is de-duped any virtual links it has are merged into the object that replaces it.
2021-12-01 08:37:04 -07:00