Commit Graph

9396 Commits

Author SHA1 Message Date
Garret Rieger f0c78e0282 [subset] don't drop features referenced in a feature variation substitution. 2021-04-01 15:26:02 -06:00
Garret Rieger dae99b7769 [subset] don't keep FeatureVariationRecord's with no subsittutions. 2021-04-01 15:26:02 -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
Garret Rieger 8ef4257dc8 [sanitize] change max ops to track number of bytes processed.
Counting bytes as the operations is likely to be a better proxy for how
much work processing the table will cost vs. the current approach of
counting the number of sub-objects.

This should allow checks for max features, max scripts, etc. to be removed.

I tested this change against the full collection of fonts at https://github.com/google/fonts
and a max ops factor of 3 was sufficient to successfully sanitize all of them.
2021-03-31 19:03:30 -06:00
Behdad Esfahbod 70110f6aaa Modify OffsetTo<>::sanitize() overflow check
The code in question was introduced in 70eb2ff682.
Rewrite it to not call sanitizer check_range() as we want to use
check_range() for byte accounting.

Part of https://github.com/harfbuzz/harfbuzz/pull/2923
2021-03-31 17:04:02 -06:00
Behdad Esfahbod 4dba749d83 Add SortedArray{16,32}Of<> 2021-03-31 16:09:39 -06:00
Behdad Esfahbod 5639e253f9 Add Array16Of<> 2021-03-31 16:04:43 -06:00
Behdad Esfahbod 2520a82df9 s/LArrayOf/Array32Of/g 2021-03-31 15:41:54 -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 1fc6b69aed s/UnsizedOffsetArrayOf/UnsizedArray16OfOffsetTo/g 2021-03-31 15:30:35 -06:00
Behdad Esfahbod 2a54c9f744 . 2021-03-31 15:26:42 -06:00
Behdad Esfahbod c539afb08b [CFF] Use NNOffsetTo<> instead of OffsetTo<>
I'm pretty sure that's what is intended.
2021-03-31 13:28:25 -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 c5c13006a1 [subset] fix memory leaks found in https://oss-fuzz.com/testcase-detail/5179935334465536 2021-03-31 12:37:45 -06:00
Behdad Esfahbod bd2950b393 Make VariationStore::get_delta(outer, inner) private 2021-03-31 11:36:36 -06:00
Behdad Esfahbod 934675a429 Use VarIdx in VariationDevice 2021-03-31 11:34:41 -06:00
Behdad Esfahbod 0f7f7536b9 [hvar] Change variation-index types from "unsigned int" to uint32_t 2021-03-31 11:31:49 -06:00
Behdad Esfahbod 9ffc46b8ff Add VarIdx 2021-03-31 11:26:18 -06:00
Behdad Esfahbod 2179281c40 Add Offset24 2021-03-31 11:20:21 -06:00
Andrzej Perczak cab9d5a57d hb-config: Include config-override earlier
Currently config-override.h is included at the end of this file. This caused a problem for me while undefing HB_DISABLE_DEPRECATED, namely HB_IF_NOT_DEPRECATED was defined before actual undef took place and broke the whole build. I believe it would break builds for some other defines, too. Moving config-override.h include right after predefined configs is more sane and fixes all potential problems with includes.
2021-03-30 20:50:02 -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
Behdad Esfahbod a8f9f85a91 [map] Return success from ->set() 2021-03-29 18:13:22 -06:00
Garret Rieger 8741914a80 [subset] fix memory leak when map insert fails. 2021-03-29 18:02:32 -06:00
Behdad Esfahbod 2397689387 Remove hb_success_t
Was not rolled-out yet.  So just expand.
2021-03-29 17:49:16 -06:00
Behdad Esfahbod 7a2eda7817 Move code around 2021-03-29 17:49:12 -06:00
Behdad Esfahbod bcb57dccaa [sanitize] Add short-circuit to ArrayOfM1
Like the sibling ArrayOf types.
2021-03-29 17:49:08 -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
Garret Rieger 9a3537e5f6 [subset] invert err() return value. Undo previous change to check_success. 2021-03-29 17:15:22 -06:00
Garret Rieger cdba5d44c2 [subset] fix incorrect handling of return value in check_success in the error case. 2021-03-29 17:15:22 -06:00
Behdad Esfahbod 05e845c49a Make previous commit gcc-only 2021-03-29 16:02:10 -07:00
Behdad Esfahbod b5e4032392 -Wno-unused-result
GCC doesn't let one turn off the warning using "(void) foo()".
People have introduced macros that do "unused << foo()" instead.
Until we do something similar, silence gcc.

Clang on the other hand understands "(void) foo()".
2021-03-29 15:57:36 -07:00
Qunxin Liu 95230e291d [subset] support subsetting GSUB8 2021-03-29 15:54:11 -06:00
David Corbett d18915f920 Reformat gen-tag-table.py 2021-03-28 10:21:46 -07:00
Garret Rieger 3c8273ab68 Check for alloc failures on the gsub/gpos_langsys maps in subset plan creation. 2021-03-25 16:53:56 -06:00
Behdad Esfahbod 29708e959a [aat] Fix offsetToIndex math for out-of-bounds values
Previously, some bad font data was accidentally being interpretted as
legit if it happened to not fall out of memory bounds. The intention
of the code was what this commit does.  I'm surprised we weren't getting
a "arithmetic between signed and unsigned values" warning / error
before.
2021-03-22 15:22:15 -07:00
Garret Rieger 46bf03d691 [subset] add NODISCARD to error checking methods on serializer. 2021-03-18 14:35:36 -07:00
Garret Rieger 3827a3eb56 [subset] rename serializer::set_error() to err(). 2021-03-18 11:20:03 -07:00
Garret Rieger f561fa6e4c Change priority queue to use (priority, value) instead of (value, priority). 2021-03-18 11:13:47 -07:00
Garret Rieger b14475d2ae [subset] further changes to serializer error handling.
- Rename enum type and enum members.
- in_errors() now returns true for any error having been set. hb-subset now looks for offset overflow only errors to divert to repacker.
- Added INT_OVERFLOW and ARRAY_OVERFLOW enum values.
2021-03-18 10:51:26 -07:00
Garret Rieger 73ed59f7a6 [subset] store errors in the serializer as a flag set.
Make check_assign/check_equal specify the type of error to set.
2021-03-17 15:58:34 -07:00
Garret Rieger b9ecc7420d [subset] init offset_overflow in hb_serialize_context_t. 2021-03-17 15:53:58 -07:00
Garret Rieger cf79fc342d [subset] limit priority bumps to 16. 2021-03-17 15:53:58 -07:00
Garret Rieger e2f14e81bd [subset] fix memory leaks in test-repacker. 2021-03-17 15:53:58 -07:00
Garret Rieger d3e2ba7c01 [subset] comment cleanup in hb-repacker.hh 2021-03-17 15:53:58 -07:00
Garret Rieger 832f2b599b [subset] Refactor _subset () to reduce nesting and eliminate the use of 'goto'. 2021-03-17 15:53:58 -07:00
Garret Rieger bb5c80a7c2 [subset] add error tracking to the repacker.
Also check for allocation failures as needed.
2021-03-17 15:53:58 -07:00
Garret Rieger 6e9468fcfb [subset] cleanup memory leaks in the repacker. 2021-03-17 15:53:58 -07:00
Garret Rieger a7a86a6eb4 [subset] Add prioritization offset resolution.
Vertices can now be prioritized to force them to sort closer to their parent. The resolver will attempt to use this for overflows on non-shared vertices.
2021-03-17 15:53:58 -07:00
Garret Rieger b452b2c76c [subset] refactor repacker graph to cache edge count and distances of vertices. 2021-03-17 15:53:57 -07:00
Garret Rieger 75414e82b5 [subset] Add table duplication overflow resolution. 2021-03-17 15:53:57 -07:00
Garret Rieger 8286bd8094 [subset] use vectors instead of hashmaps throughout the repacker since all keys will be mapped for these use cases. 2021-03-17 15:53:57 -07:00
Garret Rieger 519ae96617 [subset] switch sort_shortest_distance() to use priority queue. 2021-03-17 15:53:57 -07:00
Garret Rieger 5d3511e5b1 [subset] Change compute_distances() to use a priority queue. 2021-03-17 15:53:57 -07:00
Garret Rieger 59ac0a0d0a [subset] Use priority for comparison in heap. 2021-03-17 15:53:57 -07:00
Garret Rieger 4c8dd41ed9 [subset] re-write compute distances to use an array lookup for the distance map. 2021-03-17 15:53:57 -07:00
Garret Rieger 5c4e0ffd97 [subset] Add a basic priority queue datastructure (binary heap). 2021-03-17 15:53:57 -07:00
Garret Rieger dd8e5d0e1b [subset] Only run the repacker for GSUB/GPOS. 2021-03-17 15:53:57 -07:00
Garret Rieger aaa7873d42 [subset] add topological sort by closest distance via Dijkstra's algorithm. 2021-03-17 15:53:57 -07:00
Garret Rieger 8ebe5d734f Implement will_overflow (). 2021-03-17 15:53:57 -07:00
Garret Rieger 6b1ea4cbe7 [subset] hook up the repacker to run if offset overflows are encountered during subsetting. 2021-03-17 15:53:57 -07:00
Garret Rieger f4c78cc7dd [subset] Implement Kahn's algo for topological sorting instead of BFS. 2021-03-17 15:53:57 -07:00
Garret Rieger 00f393dc3f [subset] finish up BFS sort implementation. 2021-03-17 15:53:57 -07:00
Garret Rieger 1584d3cb8f [subset] Start a proof of concept implementation of the GSUB/GPOS offset overflow resolver. 2021-03-17 15:53:57 -07: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 62423504ee [subset] optimize glyph closure method: step 3
Add function intersects_coverage_glyphs that collects
set of matching glyphs in Coverage table
2021-03-17 15:22:07 -06:00
Qunxin Liu ef78d0f923 [subset] optimize glyph closure method: step 2
Add function intersects_class_glyphs that collects
set of glyphs matching class in ClassDef table
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
Garret Rieger 2df39bcae7 [subset] don't allocate a set to use as a glyph filter for PairPosFormat2. 2021-03-16 14:49:35 -07:00
Garret Rieger bb54e1047d [subset] Also filter class1 by coverage when collecting variation indices for PairPosFormat2. 2021-03-16 14:49:35 -07:00
Garret Rieger 190b7a98f8 [subset] Update PairPosFormat2 subsetting to match fontTools updated subsetting (https://github.com/fonttools/fonttools/pull/2221)
- subset class def 1 against the coverage table.
- Don't re-use class 0 in class def 2.
- Ignore class 0 glyphs for the purposes of determing format 1 vs format 2 encoding for ClassDef.

Add an additional test case which demonstrates these issues.
2021-03-16 14:49:35 -07:00
Khaled Hosny 03538e872a 2.8.0 2021-03-16 19:28:35 +02:00
Behdad Esfahbod 9e397ff2fb [buffer] Fix order of HB_INTERNAL HB_DISCARD
Sucks that has to be specified in this order. But that is what it is for now.

Was only exhibiting problem on C++>=17 since that's when the [[nodiscard]]
was introduced.
2021-03-15 16:51:17 -06:00
Behdad Esfahbod 8450f43ae1 [buffer] HB_NODISCARD next_glyph() 2021-03-15 16:01:35 -06:00
Behdad Esfahbod f4bc7673db [buffer] Implement copy_glyph() in terms of output_info() 2021-03-15 16:01:35 -06:00
Behdad Esfahbod f73982a699 [buffer] Implement replace_glyph() in terms of replace_glyphs(1,1)
I get exact same binary size with this, suggesting that compiler is
optimizing these as needed.
2021-03-15 16:01:35 -06:00
Behdad Esfahbod 862f913489 [buffer] Implement output_glyph() in terms of replace_glyphs(0,1)
To my surprise, saves ~20kb in my build (non-size-optimized) build.
The output_glyph() method is never used in the fast paths, so doesn't
matter if is not fully optimized for the special case it is.
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 e6be9eb4fb [buffer] HB_NODISCARD output_info() 2021-03-15 14:12:10 -06:00
Behdad Esfahbod 2a0dbb3ee5 [buffer] HB_NODISCARD copy_glyph() 2021-03-15 14:10:39 -06:00
Behdad Esfahbod b05e5d9a79 [buffer] HB_NODISCARD next_glyphs() 2021-03-15 14:08:08 -06:00
Behdad Esfahbod 4ae8aab83b [buffer] HB_NODISCARD has_separate_output() 2021-03-15 14:01:52 -06:00
Behdad Esfahbod 8d3701f507 [buffer] HB_NODISCARD in_error() 2021-03-15 14:01:32 -06:00
Behdad Esfahbod 41e05479b6 [buffer] HB_NODISCARD shift_forward() 2021-03-15 14:00:00 -06:00
Behdad Esfahbod 83b3784d1d [buffer] HB_NODISCARD make_room_for() 2021-03-15 13:59:14 -06:00
Behdad Esfahbod c355508a89 [buffer] HB_NODISCARD ensure_glyphs() / ensure_unicode() 2021-03-15 13:58:30 -06:00
Behdad Esfahbod bc22305b6a [buffer] HB_NODISCARD ensure_inplace() 2021-03-15 13:57:18 -06:00
Behdad Esfahbod cac6c86d2f [buffer] HB_NODISCARD move_to() 2021-03-15 13:56:46 -06:00
Behdad Esfahbod 05d2d37f9a [buffer] HB_NODISCARD ensure() 2021-03-15 13:56:46 -06:00
Behdad Esfahbod d8028a0762 [buffer] HB_NODISCARD enlarge() 2021-03-15 13:34:36 -06:00
Behdad Esfahbod 3f1998a065 [buffer] HB_NODISCARD replace_glyph() 2021-03-15 13:33:44 -06:00
Behdad Esfahbod 607979d12f [buffer] HB_NODISCARD replace_glyphs() 2021-03-15 13:23:48 -06:00
Behdad Esfahbod 906c9928bb [buffer] Return success status from buffer ops that can fail
Previous error-handling philosophy was that user doesn't need to
immediately know whether operation failed. But as can be seen after
we added malloc-failing fuzzing, there's just so many places in the
code that a failure of these operations needs to be mitigated before
further operations. So I'm moving towards returning success here,
and possibly making it nodiscard.
2021-03-15 13:13:45 -06:00
Behdad Esfahbod a5b8e7db4d [hangul] Improve error handling
I did a review; changed some "return"s to "break"s, which should be identical.
Removed one check just before "continue" because not necessary.
The added error check is the actual fix.

Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31755
2021-03-15 12:46:58 -06:00
Behdad Esfahbod 99767f9386 [hangul] Whitespace 2021-03-15 12:36:59 -06:00
Behdad Esfahbod 3622120fab [subset] Make ClassDef format2 .intersects() return false if range value 0
We treat Class0 as "doesn't intersect".  That's the only meaningful
interpretation. If one allos Class0 to mean "intersects", then the
intersects() result should be true iff glyphset is non-empty.

Related to https://github.com/harfbuzz/harfbuzz/issues/2703
2021-03-10 12:21:43 -07:00
David Corbett e19de65eae
Update hb-ot-tag-table.hh (#2890) 2021-03-08 10:12:47 -08:00
Khaled Hosny 7686ff854b
[ot] Keep substituted Default_Ignorables (#2886)
Don’t replace Default_Ignorables with zero-width space if they are
substituted or multiplied, not just when ligated.

After this change, HarfBuzz output matches that of Uniscribe and
CoreText for the new tests.

Fixes https://github.com/harfbuzz/harfbuzz/issues/2883
2021-03-04 13:09:32 -08:00
Behdad Esfahbod 5efa04c890 [Makefile] Rebuild .def files if config changed
I was getting check-symbols failure because my previous build was
without CoreText, and after reconfiguring with CoreText, the old
harfbuzz.defs file was not being regenerated.
2021-03-02 16:30:13 -07:00
Behdad Esfahbod d351bbf0fb [Makefile] Remove unused variable HBNODISTHEADERS
Not sure what it was used for before.
2021-03-02 16:30:13 -07:00
Behdad Esfahbod fd489433a8 [indic] Fix cluster-merging logic with cluster-level=1
Was producing non-monotonic cluster numbers because our faulty logic
was not merging clusters if something from before base and after base
had switched positions.

Fixes https://github.com/harfbuzz/harfbuzz/issues/2272
2021-03-02 16:30:09 -07: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 7cb22ba7eb
Include C headers with their C++ names (#2882)
Remove unnecessary includes.

Fixes build with some known broken SDKs (Nintendo Switch?)

https://en.cppreference.com/w/cpp/header

Fixes https://github.com/harfbuzz/harfbuzz/pull/2881
2021-03-01 11:44:06 -08:00
Behdad Esfahbod 486da35cc0 m Add comments to IntType cast out operator
Okay, bots seem to be happy. Merging.
2021-02-23 13:58:35 -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 6c4bb60829 Fix narrowing errors with recent changes 2021-02-22 23:05:55 -07:00
Behdad Esfahbod d6bd00a488 Revert back IntType out cast to signed/unsigned
Previous commit didn't fix the bots. Putting it back now that I
understand why I initially did the "Wide" casts.  But only doing
it for out-cast this time.  This causes "narrowing" warnings
whenever we are converting signed/unsigned to smaller HBUINT16
etc.  But those are valuable warnings.  We should address those
separately instead of ignoring.

Maybe we should start using uint16_t more liberally in the
internal subsetter function signatures then.
2021-02-22 22:42:50 -07:00
Behdad Esfahbod 0983601399 Add back wider cast to IntType
My local clang12 is fine, but many bots are not:

../src/hb-ot-cff1-table.hh: In instantiation of ‘bool CFF::Charset1_2<TYPE>::sanitize(hb_sanitize_context_t*, unsigned int) const [with TYPE = OT::IntType<unsigned char>]’:
../src/hb-ot-cff1-table.hh:554:13:   required from here
../src/hb-ot-cff1-table.hh:377:60: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if (unlikely (!ranges[i].sanitize (c) || (num_glyphs < ranges[i].nLeft + 1)))
                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Enabling the extra cast operator mentioned in previous commit to see if
that fixes this case.

Again, I'd be happy to say "use 1u instead of 1" if this was universally
erred on.  But since some compilers happily compile this while others
err, it would be a huge headache. Let's see...

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 22:33:17 -07:00
Behdad Esfahbod 567cedcc5f Narrow down cast operators on IntType
Say for USHORT, we were implementing casts from and to unsigned.
With this change, we cast from and to uint16_t only.  This allows
compiler more opportunities to catch possible narrowing issues in
the code.

It needed a couple of fixes in the codebase though, because
previously, if a USHORT was participating in arithmetic with signed
numbers, eg. "u + 1", the result would have been unsigned.  With
this change, it would be signed.  The correct fix is to update the
code to read "u + 1u".

That said, I think about conditionally adding back the cast
out to signed/unsigned, to facilitate better type deduction.
But I couldn't think of a real situation where that would help
with anything.  So I didn't add.  Here's what it was:

  template <typename Type2 = hb_conditional<hb_is_signed (Type), signed, unsigned>,
           hb_enable_if (sizeof (Type) < sizeof (Type2))>
  operator hb_type_identity_t<Type2> () const { return v; }

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 22:32:42 -07:00
Behdad Esfahbod f4f35a4d5f [constexpr] Use initializer instead of assignment 2021-02-22 22:32:42 -07:00
Behdad Esfahbod cc16b26ef4 [constexpr] IntType
See https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 21:59:56 -07:00
Behdad Esfahbod 8b2f9adf29 m Simplify Tag operator char* 2021-02-22 17:42:24 -07:00
Behdad Esfahbod 021a1725ed
Merge pull request #2874 from harfbuzz/constexpr2
Some more cleanup towards using constexpr to simplify our internal datastrcutures.

https://github.com/harfbuzz/harfbuzz/pull/2874
2021-02-22 17:40:22 -07:00
Behdad Esfahbod b368a0736b [atomic] Remove IBM/AIX implementation
The C++11 implementation shall be enough for everyone.
2021-02-22 17:24:09 -07:00
Behdad Esfahbod 52f9126960 [atomic] Remove Windows implementation
Since we require C++11 now, there's no point to do a macro version check.
Which means we don't hit the MSVC issue defining __cplusplus wrongly.
2021-02-22 17:22:09 -07:00
Behdad Esfahbod a666fe64a9 [atomic] Comment 2021-02-22 17:21:27 -07:00
Behdad Esfahbod 3528a21e8d [atomic] Remove Apple implementation
Continuation of https://github.com/harfbuzz/harfbuzz/pull/676
2021-02-22 17:19:43 -07:00
Behdad Esfahbod 140797d4a2 [constexpr] hb_atomic_int_t 2021-02-22 17:19:26 -07:00
Behdad Esfahbod 2ec802b42a [object] Simplify reference_count_t 2021-02-22 17:18:47 -07:00
Behdad Esfahbod 12a283d513 m[ft] No need to use atomic ops for cached_x_scale
We have added a mutex since, so no need for atomicity.
2021-02-22 12:51:09 -07:00
Behdad Esfahbod a3c35aee30 m Move HB_SCRIPT_MYANMAR_ZAWGYI 2021-02-20 15:45:34 -07:00
Behdad Esfahbod c55bf55154 Remove HB_CONST_FUNC and HB_PURE_FUNC
They are not necessary for inline functions.
2021-02-20 15:45:12 -07:00
Behdad Esfahbod cba9893ac5 m[algs] Move roundf() here 2021-02-20 15:44:47 -07:00
Behdad Esfahbod f0947717ff m[machinery] Move HB_VAR_ARRAY here 2021-02-20 15:44:25 -07:00
Behdad Esfahbod 69464e9da0 [algs] Another try at fixing BEInt constexpr
../src/hb-algs.hh:120:3: error: body of constexpr function ‘constexpr BEInt<Type, 2>::operator Type() const [with Type = short unsigned int]’ not a return-statement
2021-02-20 15:42:44 -07:00
Behdad Esfahbod ff7bf88192 m[algs] Fix BEInt -Wnarrowing errors 2021-02-20 15:39:29 -07:00
Behdad Esfahbod a89d9f25b4 m Err on -Wnarrowing instead of -Wc++11-narrowing
On clang, -Wnarrowing is synonym for -Wc++11-narrowing.
On gcc it isn't. So, use the widely-available one
2021-02-20 15:38:05 -07:00
Behdad Esfahbod e208f80449 Make constexpr BEInt<Type, 2>::operator Type() C++11-compatible
Multiple return values not permitted until C++14
2021-02-20 15:31:43 -07:00
Behdad Esfahbod c2fc2aa44c [atomic] Remove Solaris intrinsics 2021-02-20 15:20:33 -07:00
Behdad Esfahbod 7099a6dca1 [atomic] Remove old Intel primitives implementation 2021-02-20 15:20:06 -07:00
Behdad Esfahbod 711c241f6c m[mutex] Remove busyloop mutex implemenation
Don't know why I ever added this. :)
2021-02-20 15:16:59 -07:00
Behdad Esfahbod 47f01c0726 m[algs] Move BEInt here 2021-02-20 15:14:50 -07:00
Behdad Esfahbod e5b7bc424d m Add default value to BEInt<> Size template parameter 2021-02-20 15:14:15 -07:00
Behdad Esfahbod 2caae4a59a m Move class traits 2021-02-20 15:13:52 -07:00
Behdad Esfahbod c2dbd6cc0f Remove static_assert of sizeof basic sized int types 2021-02-20 15:11:47 -07:00
Behdad Esfahbod e1706ffecd m [algs] Move flags here 2021-02-20 15:11:26 -07:00
Behdad Esfahbod 017f6b0d24 m Move static_assert_expr<> 2021-02-20 15:11:14 -07:00
Behdad Esfahbod 61f8d0e57d m Rename ASSERT_STATIC_EXPR_ZERO to static_assert_expr 2021-02-20 15:08:19 -07:00
Behdad Esfahbod 59cfffb1af m Change ASSERT_STATIC_EXPR_ZERO template arg type to bool 2021-02-20 15:07:28 -07:00
Behdad Esfahbod 1981d83d7f [constexpr] HB_MARK_AS_FLAG_T 2021-02-20 15:07:14 -07:00
Behdad Esfahbod a4a99de0eb [constexpr] bswap 2021-02-20 15:07:07 -07:00
Behdad Esfahbod f8ebe1dacd [constexpr] BEInt 2021-02-20 15:06:12 -07:00
Behdad Esfahbod 2fbd34f89a m[set/map] Add operator bool()
Probably should use in places..
2021-02-19 18:40:48 -07:00
Behdad Esfahbod bf75a0a03a m[dispatch] Use inline class member initialization
Let's see how bots like this...
2021-02-19 18:40:48 -07:00
Behdad Esfahbod 82928d9cf6 m[blob] Move immutable check to C API boundary
Similarly to 08ed9e3f77
2021-02-19 18:40:48 -07:00
Behdad Esfahbod 4020c6b286 m[blob] An empty blob can always be made writable 2021-02-19 18:40:48 -07:00
Behdad Esfahbod 2d39031f7b [buffer/set/map] Move immutable check only to C API boundary
The immutable objects are a concept only enforced by the C API.
So move checks only to that region.

This does assume that the rest of the code is careful not getting
into these internal methods on immutable objects, which something
we do, but have no way of enforcing (currently).

.
2021-02-19 18:40:48 -07:00
Behdad Esfahbod 6d83d44052 m[set] Recover set from error in .reset() 2021-02-19 18:40:48 -07:00
Behdad Esfahbod 445efe8d04 m[vector] Recover vector from error in .reset() 2021-02-19 18:40:48 -07:00
Behdad Esfahbod 21433fa563 m[buffer] In hb_buffer_append() don't change until allocation success 2021-02-19 18:40:48 -07:00
Behdad Esfahbod 0f61a6213a m[vowels] Simplify
If we didn't "process" anything, swap_buffers() becomes a no-op.
2021-02-19 18:40:48 -07:00
Behdad Esfahbod 3b91e0b592 m[buffer] Rename internal variable 2021-02-19 18:40:48 -07:00
Behdad Esfahbod 9fcba109bf [buffer] Make swap_buffers() copy rest 2021-02-19 18:40:48 -07:00
Behdad Esfahbod 86993c09a1 Ignore -Wrange-loop-analysis
Fixes https://github.com/harfbuzz/harfbuzz/issues/2834
2021-02-19 17:10:06 -07:00
Behdad Esfahbod 6d94194497 Use auto in range-for-loop more 2021-02-19 17:10:06 -07:00
justvanrossum 79e4f436e7 Apply rounding correctly when calculating glyph extents for CFF and CFF2; adjust expected test results 2021-02-19 16:53:21 -07:00
justvanrossum d01ebeae21 calculate extents based on scaled then rounded values; undo two of the earlier test result adjustments 2021-02-19 16:53:21 -07:00
justvanrossum 1d8a89504b do not round added deltas; fixes #2866 2021-02-19 16:53:21 -07:00
Behdad Esfahbod 103ed7da83 [subset] Use dagger
Better fix for https://github.com/harfbuzz/harfbuzz/pull/2858
2021-02-19 16:48:30 -07:00
Behdad Esfahbod d8ea552d10 [aat] Improve unsafe-to-break logic
Reduces false-positives.  See comments for new logic.

Fixes https://github.com/harfbuzz/harfbuzz/issues/2860

Adjusts run-tests.sh to allow unhashed absolute filenames.
2021-02-19 16:23:22 -07:00
Behdad Esfahbod cf203936d7 [aat] Unbreak builds
Some compilers don't like this:

../src/hb-aat-layout-common.hh:732:9: error: declaration of 'using StateTable = struct AAT::StateTable<Types, EntryData>' changes meaning of 'StateTable' [-fpermissive]
732 |   using StateTable = StateTable<Types, EntryData>;
2021-02-18 12:03:26 -07:00
Behdad Esfahbod b6fdaa6948 [minor:aat] Use injected class name 2021-02-18 11:16:37 -07:00
Behdad Esfahbod e27420bb18 [minor:aat] Simplify template reference 2021-02-18 11:15:46 -07:00
Behdad Esfahbod 7b8a8adb7d [aat] Fix unsafe-to-break marking when end-of-text action kicks in
The state we are dealing with here is the previous state; so it should
cause unsafe_to_break before current glyph.

I'm surprised this wasn't caught by any tests. Guess we don't have any
fonts with fancy end-of-text forms.
2021-02-18 09:47:24 -07:00
Behdad Esfahbod aa80c7c8b4 [aat] Add buffer->successful check before buffer->next_glyph() 2021-02-18 09:31:46 -07:00
Behdad Esfahbod bcd10bf274 [normalize] Add buffer success check before ->next_glyph()
Speculative fix for:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27843
2021-02-17 13:58:56 -07:00
Behdad Esfahbod 505b3fc6cf [harfbuzz.cc] Fix OffsetTable name clash with Mac headers
There's no easy way to undo a "using namespace" in our sources, so by the time
we get to include hb-coretext.cc from harfbuzz.cc, we already have "using namespace OT"
active, which clashes with Mac headers.

Error was:
$ gcc -O3 -Wall -arch i386 -DHAVE_CORETEXT=1 -c harfbuzz.cc -o harfbuzz.o -std=c++11
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/TextUtils.h:288:3: error:
      reference to 'OffsetTable' is ambiguous
  OffsetTable     offsets,
  ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/IntlResources.h:115:41: note:
      candidate found by name lookup is 'OffsetTable'
typedef OffPair                         OffsetTable[3];
                                        ^
./hb-open-file.hh:81:16: note: candidate found by name lookup is 'OT::OffsetTable'
typedef struct OffsetTable
               ^
1 error generated.
2021-02-17 11:34:47 -07:00
Behdad Esfahbod 6a9f576fd4 [coretext] Silence CoreText deprecation warning
As suggested by Ned, just ignoring it.

warning: 'CTGetCoreTextVersion' is deprecated: first deprecated in macOS 11.0 - Use
      -[NSProcessInfo operatingSystemVersion] [-Wdeprecated-declarations]
2021-02-17 11:31:32 -07:00
Behdad Esfahbod 8e53c7c125 [coretext] Fix more CGFloat double-promotion warnings
The warning is:
warning: implicit conversion increases floating-point precision: 'CGFloat' (aka 'float') to
      'double' [-Wdouble-promotion]
2021-02-17 11:12:56 -07:00
Garret Rieger 5ca353a2d0 [subset] fix heap buffer overflow found by fuzzer. 2021-02-16 12:43:02 -07:00
David Corbett 751ed68fee [indic] Fix shaping of U+0B55 ORIYA SIGN OVERLINE
Fixes https://github.com/harfbuzz/harfbuzz/issues/2849
2021-02-14 12:47:34 -05:00
Behdad Esfahbod 7a60f4e3a4 [subset] Remove debug burden
Fixes https://github.com/harfbuzz/harfbuzz/issues/2360
2021-02-12 14:14:17 -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 bbbea3dbd8 [minor] Rewrite set operation in OS/2 subsetting
This patch could be nicer:
https://github.com/harfbuzz/harfbuzz/pull/2572/files

Just tiny touchup now.
2021-02-11 12:23:33 -07:00
Behdad Esfahbod cdb9197b41 [khmer] Remove more unused code
Prodded by https://github.com/harfbuzz/harfbuzz/pull/2583

These are leftovers from when we forked Khmer shaper from the Indic shaper.
2021-02-11 11:33:47 -07:00
Behdad Esfahbod dfa9d7acdc [minor] Use serializer->propagate_error() to simplify code 2021-02-11 11:19:51 -07:00
Behdad Esfahbod 5faae8260a [post] Remove unneeded error check 2021-02-11 10:58:02 -07:00
Behdad Esfahbod d7e2a51de2 [minor] Add unlikely() when checking for error 2021-02-11 10:55:03 -07:00
Behdad Esfahbod c7d232ce4e
Merge pull request #2701 from googlefonts/Mark-To-Ligature_grieger
[subset] GPOS 5 MarkToLigature subsetting support
2021-02-10 18:13:38 -07:00
Khaled Hosny 7b9e23f28b [introspection] Fix g-ir-scanner syntax errors
Fixes https://github.com/harfbuzz/harfbuzz/issues/2851
2021-02-10 23:37:43 +02: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 836814a571 [array] Swap order of args to hb_equal()
Prioritizes Key::cmp() over table's cmp.
2021-02-09 18:48:05 -07:00
Behdad Esfahbod 98374cebe1 Conditionalize IntType::cmp() so it never fails to compile
Useful with lfind() since that calls hb_equal() which SFINAEs which
cmp() to use.
2021-02-09 18:48:05 -07:00
Behdad Esfahbod ed04174a64 Whitespace 2021-02-09 18:48:05 -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
josephshen d9e0244cdf remove duplicate file names 2021-02-02 09:23:41 -08:00
Behdad Esfahbod dad41c07e4 [use] Typo 2021-02-01 11:30:39 -08:00
Behdad Esfahbod 63a716c540 [indic] Use lfind() 2021-02-01 11:30:39 -08:00
Behdad Esfahbod 921b4e46b0 [algs] Add hb_equal()
Use in hb_array_t::lfind()
2021-02-01 11:30:39 -08:00
Behdad Esfahbod f4ed3bf20b [indic] Remove categorization of Khmer Ra
Khmer goes through its own shaper these days.
2021-02-01 11:30:39 -08:00
Behdad Esfahbod 676d1e6adf [indic] Spell out INDIC_TABLE_ELEMENT_TYPE 2021-02-01 11:30:39 -08:00
Behdad Esfahbod 769c2b19a3 [indic/khmer/myanmar/use] Minor shuffling of found_syllable() macros 2021-02-01 11:30:39 -08:00
Behdad Esfahbod 59721c2f37 [use] Move data table into same compilation unit 2021-02-01 11:30:39 -08:00
Behdad Esfahbod d9b167da3d [use] Remove hb-ot-shape-complex-use.hh
Inline into ragel machine.
2021-02-01 11:30:39 -08:00
Behdad Esfahbod 3bb2653a5e [use] Reuse category numbers exported from ragel machine
Part of https://github.com/harfbuzz/harfbuzz/pull/2726
2021-02-01 11:30:39 -08:00
Behdad Esfahbod c417e0d2f9 [indic/khmer/myanmar/use] Move enum category around
Such that the generated -machine.hh headers are independent.
2021-02-01 11:30:39 -08:00
Behdad Esfahbod 675b6c2994 [indic/khmer/myanmar/use] Remove unused dump-*-data programs
In prep for streamlining tables.
2021-02-01 11:30:39 -08:00
Behdad Esfahbod 0a5c631140 [use] Rename internal enum joinint_form_t members
To ease upcoming change.
2021-02-01 11:30:39 -08:00
Behdad Esfahbod 880fdb7460 [indic/khmer/myanmar/use] Export categories from Ragel source
Not hooked up yet.

Part of alternative approach to
https://github.com/harfbuzz/harfbuzz/pull/2726
2021-02-01 11:30:39 -08:00
ckitagawa b198d94489 use {} rather than {0} 2021-01-25 14:07:52 -08:00
ckitagawa 2e50b517e1 Nicer more idiomatic fix 2021-01-25 14:07:52 -08:00
ckitagawa 8f6559a373 [subet/COLR] Default initialize firstLayerIdx 2021-01-25 14:07:52 -08:00
Behdad Esfahbod a650243d39 [sanitize] Fix typo 2021-01-24 13:30:06 -07:00
Behdad Esfahbod 881ad720fe [algs] Remove passthru declaration
Let compiler figure it out.
2021-01-21 14:27:45 -07:00
Behdad Esfahbod ca0b7afee9 [set] Use hb_fill() 2021-01-21 12:22:00 -07:00
Behdad Esfahbod 5fce8898e0 [iter] Allow passing rvalue iters to hb_fill() 2021-01-21 12:15:10 -07:00
Behdad Esfahbod 6463ee02d6 Speed up ClassDef/Coverage intersect methods
Just avoiding overhead as measured by Garret.
Should rewrite as dagger in the future and confirm that it has the
same benefits. Later on, rewrite as lfind() maybe.

Fixes https://github.com/harfbuzz/harfbuzz/issues/2826
2021-01-21 11:16:04 -08:00
Garret Rieger 33368a12b7 uint32_t to unsigned in hb-set.hh 2021-01-21 12:12:05 -07:00
Garret Rieger 2a0d0b901f Make set clear work even when set is in failed state. 2021-01-21 12:12:05 -07:00
Garret Rieger 0ba73e980c [ENOMEM] handle allocation failures during page compaction. 2021-01-21 12:12:05 -07:00
Garret Rieger a4c3732f59 [ENOMEM] fix set clear() causing corruption if the set is in_error(). 2021-01-21 12:12:05 -07:00
Khaled Hosny 9b8be9643c [docs] Ignore hb-gobject headers
Fixes https://github.com/harfbuzz/harfbuzz/issues/2797
2021-01-20 14:23:37 -08:00
Khaled Hosny 051a3c7b9a [docs] Fix typo 2021-01-20 14:22:15 -08:00
Khaled Hosny a44dd339f9 [docs] Missing param docs 2021-01-20 14:22:15 -08:00
Khaled Hosny 478d169c0f [docs] Document more deprecated symbols 2021-01-20 14:22:15 -08:00
Khaled Hosny ca0a7a8384 [docs] Document hb_ot_math_constant_t somehow 2021-01-20 14:22:15 -08:00
Khaled Hosny 3ba1e7e783 [docs] Document HB_OT_TAG_DEFAULT_LANGUAGE/SCRIPT 2021-01-20 14:22:15 -08:00
Khaled Hosny 4bfa0b3c02 [docs] Fix hb_color_get_* docs 2021-01-20 14:22:15 -08:00
David Corbett 2cdc92c0c2 [use] Move most joining scripts to USE 2021-01-18 12:06:23 -08:00
Behdad Esfahbod 5c73c9082b [syllabic] Fix signed/unsigned comparision errors 2021-01-18 12:00:58 -08:00
Behdad Esfahbod e3d4c29727 [indic/khmer/myanmar] Minor: Fix mask
Seems like a typo. No behavior change.
2021-01-18 12:00:58 -08:00
Behdad Esfahbod 0ddade44cf [syllabic] Merge various insert_dotted_circles implementations
Fixes https://github.com/harfbuzz/harfbuzz/issues/1810
2021-01-18 12:00:58 -08:00
Behdad Esfahbod e8e9fd9556 [syllabic] Add hb-ot-shape-complex-syllabic.cc/hh
Empty for now.

Part of https://github.com/harfbuzz/harfbuzz/issues/1810
2021-01-18 12:00:58 -08:00
Behdad Esfahbod 8af85c4e86 Remove hb-ot-shape-complex-machine-index.hh file
Inline code into USE header.
2021-01-18 12:00:58 -08:00
Behdad Esfahbod 9dd61c5b78 Rename internal buffer var use
Part of https://github.com/harfbuzz/harfbuzz/issues/1810
2021-01-18 12:00:58 -08:00
Behdad Esfahbod 3c5b7886eb Revert "Avoid category duplication between C++ and Ragel"
This reverts commit 67ea8133d3.

Merged accidentally on https://github.com/harfbuzz/harfbuzz/pull/2726
2021-01-15 19:26:04 -07:00
David Corbett 67ea8133d3 Avoid category duplication between C++ and Ragel 2021-01-15 18:24:52 -08:00
David Corbett c8c5e52aba [use] Update overrides to 2021-01-04
This uses the data files from
<ed7b825ddb/USE>.
2021-01-06 05:45:01 +02:00
Khaled Hosny 1fb7f3bda6 [docs] Document various HB_SCRIPT_*
Need to have something for all of them to keep GTK-Doc happy.
2020-12-30 19:21:49 -08:00
Khaled Hosny ea0907abf9 [docs] Document version macros 2020-12-30 19:21:49 -08:00
Khaled Hosny 5e9f05ff3f [docs] Expand memory modes docs
Per Behdad suggestions.
2020-12-30 19:21:49 -08:00
Khaled Hosny 5151c2b668 [introspection] Replace deprecated allow-none
Use optional or nullable as appropriate.
2020-12-30 19:21:49 -08:00
Khaled Hosny a64d56a3e5 [introspection] nullable is for pointers 2020-12-30 19:21:49 -08:00
Khaled Hosny 9936490c04 [docs] Invalid use of "optional" annotation
It is valid only for out and inout parameters.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1787
2020-12-30 19:21:49 -08:00
Khaled Hosny bf5b4b71c5 [docs] Duplicated documentation 2020-12-30 19:21:49 -08:00
Khaled Hosny 3d7a361648 [docs] Miscellaneous missing docs 2020-12-30 19:21:49 -08:00
Khaled Hosny a31a51cdec [docs] Complete hb-ft docs a bit 2020-12-30 19:21:49 -08:00
Khaled Hosny 8c492d5c32 [docs] Complete hb-ot-math docs a bit 2020-12-30 19:21:49 -08:00
Khaled Hosny 3f7ffd1b3d [docs] Complete hb-unicode docs a bit 2020-12-30 19:21:49 -08:00
Khaled Hosny 2fdab788ad [docs] Complete hb-buffer docs a bit 2020-12-30 19:21:49 -08:00
Khaled Hosny 492a5a9096 [docs] Complete hb-aat docs a bit 2020-12-30 19:21:49 -08:00