Commit Graph
89 Commits
Author SHA1 Message Date
Ebrahim Byagowi 677d6646a1 [subset] Make sure the clamp is done in a int64_t space
Otherwise nags about things like this,

In member function ‘int64_t graph::graph_t::vertex_t::modified_distance(unsigned int) const’,
    inlined from ‘void graph::graph_t::sort_shortest_distance()’ at ../src/graph/graph.hh:626:24:
../src/graph/graph.hh:371:20: warning: dangling pointer to an unnamed temporary may be used [-Wdangling-pointer=]
  371 |           hb_clamp (distance + distance_modifier (), (uint64_t) 0, (uint64_t) 0x7FFFFFFFFFF);
      |           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And some of the CI bots fail also like this https://github.com/harfbuzz/harfbuzz/actions/runs/9838686960/job/27159310858?pr=4793

But it probably something else also can be improved which maybe is out of scope for this particular change.
2024-07-08 11:06:53 -06:00
Ebrahim Byagowi 495937f96d [subset] Use hb_clamp instead of consequent hb_min and hb_max calls
As just a minor code tweak to clarify the intention better.
2024-07-08 11:06:53 -06: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 6f64fa75e3 [repacker] improve resolution of overflows to shared nodes.
Prior to this change overflows to shared nodes were handled by duplicating the link from only a single parent on each iteration. However, I've encountered fonts where there is a large number of parents sharing a single child. Using the prior strategy requires large number of overflow resolution iterations to resolve overflows. This changes shared overflow resolution to duplicate the shared child and re-assign multiple overflowing parents in a single iteration. This reduces total packing size in these cases and allows resolution to complete in far fewer iterations.
2023-12-05 16:25:12 -05:00
Behdad Esfahbod 330c32f902 [graph] Another preallocation 2023-11-10 12:27:48 -07:00
Behdad Esfahbod 9c4d3c3c70 [graph] Pre-alloc priority-heap array 2023-11-10 12:26:02 -07:00
Qunxin Liu 1f395cbaf9 [instancer] templatize the priority queue, use custom type for varstore
when instantiating varstore, we need to pop a tuple like
(combined_gain, i, j), if combined gain is the same then we compare the
value of i, and then j. So we'd like to use custom type as the key when
popping from the queue. This would match fonttool's algorithm cause it
uses heappop().
2023-10-13 14:52:27 -06:00
Vincent Torri 17ee3cd7f4 fix warning with unsigned long 2023-09-10 11:34:30 +03: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 ca906e8747 [repacker] fix fuzzer timeout.
Corrects some mistakes in the handling of incoming_edges_ when memory allocation failures happen.
2023-08-17 12:01:44 -06:00
Behdad Esfahbod 91c449a64a [graph] Make space_for non-recursive
It was tail-recursive so perhaps the compiler did the same.
Anyway, make it explicit now.
2023-08-02 14:40:55 -06:00
Behdad Esfahbod 70b3fbed28 [graph] Fix invalid read when map gets resized
I don't fully understand how the old code was wrong, since
*v should be evaluated before the set() method call.
Yet this seems to fix a bug that could be reproduced
with HB_DEBUG_SUBSET_REPACK enabled and the following:

$ hb-repacker-fuzzer test/fuzzing/graphs/clusterfuzz-testcase-minimized-hb-repacker-fuzzer-6419865171525632
2023-08-01 15:16:16 -06:00
Behdad Esfahbod 94d4283b12 [graph] Handle a malloc fail
Fixes https://oss-fuzz.com/testcase-detail/4579249263345664
2023-08-01 15:06:01 -06:00
Behdad Esfahbod 603920e911 [graph] Minor asserts 2023-08-01 14:58:33 -06:00
Behdad Esfahbod 8d00476fbf [graph] Minor restructure a condition 2023-08-01 14:27:37 -06:00
Behdad Esfahbod 7946984b96 [graph] More assert 2023-08-01 14:18:03 -06:00
Behdad Esfahbod 3b386c3773 [graph] Minor assert 2023-08-01 14:15:41 -06:00
Behdad Esfahbod 07e7033076 [graph] Error check 2023-08-01 12:25:45 -06:00
Behdad Esfahbod 7a9aac1ae3 [graph] Fixes to parent handling 2023-08-01 12:17:13 -06:00
Behdad Esfahbod 23838e5a2e [graph] Error handling 2023-07-29 13:20:14 -06:00
Behdad Esfahbod 04f4909257 [graph] Use a move instead of swap 2023-07-28 14:37:52 -06:00
Behdad Esfahbod 3bedb0eeed [graph] Minor rename 2023-07-27 16:04:01 -06:00
Behdad Esfahbod bb1f53c254 [graph] Try fixing infinite loop found by CIFuzz under malloc fail 2023-07-27 13:29:56 -06:00
Behdad Esfahbod db3314c1f8 [graph] Minor space type change 2023-07-27 13:20:32 -06:00
Behdad Esfahbod 6bb61708ed [graph] Try fixing bots 2023-07-27 13:06:30 -06:00
Behdad Esfahbod 1b5abb1781 [graph] Speed-up vertices having only one parent 2023-07-27 12:56:06 -06:00
Behdad Esfahbod f3d0b11d57 [graph] Make parents private 2023-07-27 12:56:06 -06:00
Behdad Esfahbod d3b997ee70 [graph] Use a hb_map_t to keep parents, instead of hb_vector_t
In some fonts, for example Noto Duployan-Regular, nodes can
have over a thousand parents... Speeds up 10% subsetting.
2023-07-27 12:55:57 -06:00
Behdad Esfahbod 326d319f93 [graph] Micro-optimize 2023-07-15 13:14:34 -06:00
Behdad Esfahbod 548230e45e [graph] Early return from a function 2023-07-15 13:13:16 -06:00
Behdad Esfahbod 09706b04fc [graph] Add a pre-alloc to map 2023-07-15 13:11:04 -06:00
Behdad Esfahbod d1ddfc4d10 [graph] Use move instead of swap 2023-07-14 14:52:43 -06:00
Behdad Esfahbod 07cb6bf87a [graph] Minor, type 2023-07-14 13:38:33 -06:00
Behdad Esfahbod 867640af31 Revert "[set] Add test_and_add / test_and_del"
This reverts commit de1237fbf2.

This seems to be a net loss.
2023-07-14 13:09:16 -06:00
Behdad Esfahbod 10b776b0c3 [graph] Micro-optimize 2023-07-14 13:08:19 -06:00
Behdad Esfahbod de1237fbf2 [set] Add test_and_add / test_and_del
Use in graph.
2023-07-14 12:38:56 -06:00
Behdad Esfahbod 7f1ff9c881 [graph] Micro-optimize array access 2023-07-14 12:22:24 -06:00
Behdad Esfahbod 11308c4d1f [graph] Remove manual destruction
Happens automatically by destructor.
2023-06-08 14:51:18 -06:00
Behdad Esfahbod 67b1624727 [set] Simplify a few set iterations as range loop 2023-06-07 16:25:11 -06:00
Garret Rieger 20c564bc76 [repacker] Fix fuzzer memory leak.
https://oss-fuzz.com/testcase-detail/6419865171525632
2023-05-27 01:16:46 +02:00
Behdad Esfahbod 3f9eb03b40 [graph] Micro-optimize 2023-05-01 12:55:29 -06:00
Garret Rieger e4fff64ce3 [repacker] check duplicate() for success.
Fixes fuzzer testcase https://oss-fuzz.com/testcase-detail/5475787333828608.
2023-01-23 18:37:13 -07:00
Behdad Esfahbod ed023f66df Enable -Wformat-signedness
And fix the codebase.
2023-01-12 17:04:24 -07:00
Garret Rieger 35233d2514 [repacker] fix fuzzer reported stack overflow.
Fixes https://oss-fuzz.com/testcase-detail/6014493291577344.
2022-12-07 10:32:56 -07:00
Garret Rieger f1d3489388 [repacker] bail on failure to alloc assigned_bytes set.
Fixes fuzzer issue https://oss-fuzz.com/testcase-detail/5390364397928448.
2022-12-05 14:13:47 -07:00
Garret Rieger 239a5aca02 [repacker] don't allow references to the null object in graph.
Fixes fuzzer issue https://oss-fuzz.com/testcase-detail/6714085985353728
2022-12-05 14:13:47 -07:00
Garret Rieger de5a621322 [repacker] enforce root node having no incoming edges. 2022-12-01 23:37:16 +00:00
Garret Rieger 30e405e470 [repacker] ensure link obj indices are valid. 2022-12-01 22:12:59 +00: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
Garret Rieger 9e99d08470 [repacker] validate link widths during repacker setup. 2022-12-01 20:17:41 +00:00