Commit Graph

251 Commits

Author SHA1 Message Date
Behdad Esfahbod 255085bd59 [iter] Const correctness 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 415f3f4320 Add operator= to IntType, commented out
https://github.com/harfbuzz/harfbuzz/pull/1510
2019-01-20 20:12:12 -05:00
Behdad Esfahbod a685bfe8fc Separate GlyphID from HBUINT16
For stricter enforcement.
2019-01-20 20:12:12 -05:00
Behdad Esfahbod 851fbb23ea [iter] Port Coverage::serialize to hb_is_iterator 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 06a44e2e53 [iter/meta] Match hb_is_iterator<> using SFINAE
By specifying Item type, which is desirable.
2019-01-20 20:12:12 -05:00
Behdad Esfahbod 3d22900f62 [meta] Don't use template default arguments for functions
That's a C++11 extension apparently...
2019-01-20 20:12:12 -05:00
Behdad Esfahbod df138da2e6 [iter/meta] Implement is_iterator
Removes use of auto type deduction again, which was not supported on many bots.
2019-01-20 20:12:12 -05:00
Behdad Esfahbod 442f4a5891 [meta] Move more code here 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 8c6cbbdfa3 [iter/meta] Add hb_is_iterable 2019-01-20 20:12:12 -05:00
Behdad Esfahbod 49161d411f [subset] Take iterator in ArrayOf serialize
Still not satisfied with how I can enforce iterators only, but
seems to work for now.
2019-01-20 20:12:12 -05:00
Behdad Esfahbod 205d72a198 Add NNOffsetTo<> 2019-01-17 18:10:38 -05:00
Behdad Esfahbod 474a12058d [array/vector] Rename len to length 2018-12-21 18:53:01 -05:00
Behdad Esfahbod 879faa2aee Rename 2018-12-21 01:57:40 -05:00
Behdad Esfahbod bd36977392 Rename 2018-12-20 23:14:24 -05:00
Behdad Esfahbod 5b70074edf Add hb_assign(obj, value) 2018-12-20 15:38:59 -05:00
Behdad Esfahbod f1e95e40ed [arrays] Remove hb_supplier_t<> 2018-12-18 16:49:08 -05:00
Behdad Esfahbod cf39c24205 [arrays] Rename Supplier to hb_supplier_t 2018-12-17 22:36:23 -05:00
Ebrahim Byagowi e412008599 Remove redundant void from C++ sources (#1486) 2018-12-17 13:01:01 -05:00
Ebrahim Byagowi 7ace10078c
Minor, fix two more ArrayOf incorrect operator logic 2018-12-17 20:07:04 +03:30
Behdad Esfahbod a1240383aa [arrays] Minor fix 2018-12-17 10:44:14 -05:00
Behdad Esfahbod 3656f56d47 [arrays] Minor 2018-12-16 22:31:13 -05:00
Ebrahim Byagowi b2ebaa9afa Remove redundant 'inline' from methods (#1483) 2018-12-16 14:08:10 -05:00
Behdad Esfahbod ce069d1932 Minor 2018-12-11 23:07:48 -05:00
Behdad Esfahbod ca23b71935 Add default-value for second arg of sub_array() 2018-12-06 10:21:17 -08:00
Behdad Esfahbod 2087f5a2a7 Add casts to hb_array_t<> 2018-12-01 20:04:45 -05:00
Behdad Esfahbod 11d2f49af8 New approach to change BigEndian casts to be int-sized
Fixes spurious warnings like:
Fixes https://github.com/harfbuzz/harfbuzz/issues/1436
2018-12-01 13:12:21 -05:00
Behdad Esfahbod c3a8b047aa Revert "Change BigEndian casts to be int-sized"
This reverts commit eb5ddd32bf.

Broke tests, badly.  To be investigated and reenabled.
2018-12-01 00:26:39 -05:00
Behdad Esfahbod eb5ddd32bf Change BigEndian casts to be int-sized
Fixes spurious warnings like:
Fixes https://github.com/harfbuzz/harfbuzz/issues/1436
2018-12-01 00:03:01 -05:00
Behdad Esfahbod dfad19ad5a Make operator [] take signed int
The built-in operator takes signed int.  So, match it, such that
the built-in is never a better or equally-good match to our operator.
Fixes "ambiguous overload" errors from gcc 4.2 and VS 2008.

See https://github.com/harfbuzz/harfbuzz/issues/1374
2018-11-30 20:56:14 -05:00
Behdad Esfahbod 52ae9867ef [AAT.feat] Use lsearch for looking up SettingName's
They are not sorted.
2018-11-25 01:16:02 -05:00
Behdad Esfahbod 3d30972699 [aat] Skip terminator in VarSizedBinSearchArray<>
Fixes shaping with Apple Chancery on 10.13 again.  In that font,
there was a terminator segment, that was tripping off sanitize().
2018-11-24 23:12:28 -05:00
Behdad Esfahbod 4202a3cde3 Minor 2018-11-24 22:49:50 -05:00
Behdad Esfahbod 3246a8ebbd [arrays] Merge ArrayOf's sub_array into hb_array_t's 2018-11-24 21:32:00 -05:00
Behdad Esfahbod 918b1ee54d [arrays] Add not_found to reference bsearch as well 2018-11-24 10:09:17 -05:00
Behdad Esfahbod d77a098b73 [arrays] Improve bfind() interface
Much more useful now. :)
2018-11-24 10:06:13 -05:00
Behdad Esfahbod 70d80c90fe [arrays] Port ArrayOf.qsort() and hb_vector_t.qsort() to hb_array_t 2018-11-24 09:48:06 -05:00
Behdad Esfahbod 073d837aa2 [arrays] Port ArrayOf.qsort() to hb_array_t's 2018-11-24 09:48:06 -05:00
Behdad Esfahbod 7c1600dcd9 [arrays] Add (unused) SortedUnsizedArrayOf<> 2018-11-24 09:48:06 -05:00
Behdad Esfahbod e700392f5c [arrays] Port SortedArrayOf.bsearch/bfind to hb_sorted_array_t's 2018-11-24 09:48:06 -05:00
Behdad Esfahbod e604306f28 [arrays] Port hb_vector_t.bsearch/bfind to (new) hb_sorted_array_t's 2018-11-24 09:48:06 -05:00
Behdad Esfahbod 268eca2492 [arrays] Port (unused) ArrayOf.lsearch() to hb_array_t's 2018-11-24 09:48:06 -05:00
Behdad Esfahbod 3e26c8d2b1 [arrays] Update ArrayOf.lsearch()
Currently unused apparently
2018-11-24 09:48:06 -05:00
Behdad Esfahbod 30cb45b3ea Change ArrayOf.bsearch() return semantics
Towards consolidating all array bsearch/...
2018-11-24 00:48:26 -05:00
Behdad Esfahbod bb2a206508 Assert that item-type of arrays have static size 2018-11-24 00:31:40 -05:00
Behdad Esfahbod c514f65181 [arrays] Add as_array() to ArrayOf<> 2018-11-23 16:04:56 -05:00
Behdad Esfahbod 4d4fd64ff4 Allow non-nullable OffsetTo<> to non-Null'able objects 2018-11-22 18:07:36 -05:00
Behdad Esfahbod f47a60a754 Mark UnsizedArrayOf<> as UNBOUNDED
Since min_size is 0, Null() still accepts this type.
2018-11-22 17:53:29 -05:00
Behdad Esfahbod 2737aa81e5 Fix up recent change
Fixes https://github.com/harfbuzz/harfbuzz/issues/1300
2018-11-22 01:44:27 -05:00
Behdad Esfahbod fffea5aff7 Minor 2018-11-22 01:25:34 -05:00
Behdad Esfahbod 9714e114b8 Fix recent commits 2018-11-16 16:52:42 -08:00
Behdad Esfahbod 0328a1ce41 Revert b4c6113032
Was causing more trouble than it solved.  We use unsigned for indexing,
and it's not helpful to allow that wrapping to negative integers on
32bit machines.  The only way we could work around it would have been
by accepting int64_t arg, but that's overkill.

Ignore the MSVC 2008 build issue.  We don't support that compiler.
2018-11-16 16:48:28 -08:00
Behdad Esfahbod 52f61cdb87 Detect over/under-flow in UnsizedArray::operator[]
Was causing bad substitutions in mort table because of WordOffsetToIndex()
producing negative numbers that were cast to unsigned int and returned as
large numbers (which was desirable, so they would be rejected), but then
they were cast to int when passed to this operator and acting as small
negative integers, which was bad...

Detect overflow.  Ouch, however, now I see this still fails on 32-bit.
Guess I'm going to revert an earlier change.
2018-11-16 16:41:59 -08:00
Ebrahim Byagowi 11aa0468ac [subset] minor, adjust spaces 2018-11-16 00:02:47 +03:30
Behdad Esfahbod e014405a21 Rename check_array(array, a, b) to check_range() 2018-11-12 14:23:31 -05:00
Behdad Esfahbod 1d66cdcf77 Better fix for MSVC 2008
Follow up on b4c6113032

Fixes https://github.com/harfbuzz/harfbuzz/issues/1374
2018-11-10 19:57:51 -05:00
Behdad Esfahbod b4c6113032 Try fixing MSVC 2008 build
Fixes https://github.com/harfbuzz/harfbuzz/issues/1374
2018-11-10 16:35:39 -05:00
Ebrahim Byagowi b8b00fb3c6
[aat] Support Lookup<OffsetTo<>>, needed by just and lcar (#1368) 2018-11-08 18:53:14 +03:30
Behdad Esfahbod d0163afb7b Revert "Add operator char * to the naked array types as well"
This reverts commit db889c182e.

Was resulting in ambigious overloads...
2018-11-03 21:38:30 -04:00
Behdad Esfahbod db889c182e Add operator char * to the naked array types as well 2018-11-03 16:04:19 -04:00
Behdad Esfahbod 04b82b181d Remove pointer cast operators from ArrayOf<>
ArrayOf<>, unlike UnsizedArrayOf<>, has data before the array.
This was confusing.  Remove.
2018-11-02 13:47:33 -04:00
Behdad Esfahbod 91de9dfcf3 Fix &array_of<> 2018-11-02 12:16:51 -04:00
Behdad Esfahbod 72462eb765 Add UnsizedArrayOf::as_array() instead of hb_array() template 2018-11-02 11:46:42 -04:00
Behdad Esfahbod 1cf075ecb6 Add get_size to UnsizedArrayOf 2018-11-02 11:38:00 -04:00
Behdad Esfahbod 28b68cffe4 [mort] Implement / adjust Contextual substitution 2018-10-30 23:54:29 -07:00
Behdad Esfahbod ea0e51d1b1 Add HB_NO_CREATE_COPY_ASSIGN 2018-10-29 16:00:23 -07:00
Behdad Esfahbod a256a92b3f Make Array types uncopyable-unassignable
Finally!  Catches hard-to-find errors like this:

-    const SortedArrayOf<SVGDocumentIndexEntry> docs = this+svgDocEntries;
+    const SortedArrayOf<SVGDocumentIndexEntry> &docs = this+svgDocEntries;

We implement this for our array types.  This, in turn, trickles down
into all types that embed the arrays.  So, as long as we define all
open-ended structs in terms of Array types (all can be done using
UnsizedArrayOf), this achieves the goal of making uncopyable all
structs that are variable-sized.  Yay!
2018-10-29 11:40:21 -07:00
Behdad Esfahbod e8ff27c208 Minor 2018-10-28 18:33:10 -07:00
Behdad Esfahbod 6562172381 [sbix] Use LOffsetLArrayOf<> 2018-10-28 18:33:10 -07:00
Ebrahim Byagowi c7a4e3dfb5 [svg] Add public API
* hb_ot_color_has_svg
* hb_ot_color_glyph_svg_create_blob
2018-10-26 09:16:44 +03:30
Behdad Esfahbod 21ede867df Fix possible overflow in bsearch impls
From bungeman.

Fixes https://github.com/harfbuzz/harfbuzz/pull/1314
2018-10-25 13:19:58 -07:00
Behdad Esfahbod 8c78ced95b Unbreak builds 2018-10-22 21:49:42 -07:00
Behdad Esfahbod 8d689f8a7b Add hb_array<>() specialization for UnsizedArrayOf
Related https://github.com/harfbuzz/harfbuzz/issues/1301
2018-10-22 21:33:18 -07:00
Behdad Esfahbod 07386ea410 Remove const and references when binding Null()
Fixes https://github.com/harfbuzz/harfbuzz/issues/1299

Removes anomaly I was seeing in cpal table trying to use implicit Null(NameID).
2018-10-22 21:21:17 -07:00
Behdad Esfahbod f3336580dd [color] Use hb_array_t in CPAL
Doesn't work though, ouch :(.  Need to figure out if it's unreasonable
to expect Null(T) inside hb_array_t<T> to see the later specialization
of Null for NameID.
2018-10-22 16:24:16 -07:00
Behdad Esfahbod 3bf91bd269 [color] Rewrite colr access
COLR table has one function: return layers for a glyph, and we expose exactly
that, so should just wire it through.  Also use sub_array() for verifiable
safety.

Also, BaseGlyphRecord's null object is enough.  We don't need to special-case
the not-found.
2018-10-22 14:21:23 -07:00
Behdad Esfahbod f7c0b4319c [aat] Implement LookupFormat10 2018-10-19 15:23:49 -07:00
Behdad Esfahbod 87205ef935 [aat] Make sure Lookup offset is never nulled
It has unbounded size...

Fixes https://oss-fuzz.com/v2/testcase-detail/5718889451749376
2018-10-16 15:41:00 -07:00
Behdad Esfahbod 2c824d3644 [aat] Fix two wrongs that made a right before!
Unfortunately our static asserts (DEFINE_SIZE_STATIC) don't actually
fail when used in templates, thanks to SFINAE.  Le sighs.

Probably fixes https://oss-fuzz.com/v2/testcase-detail/5740171484463104
2018-10-11 16:43:05 -04:00
Behdad Esfahbod 22955b23cd [kerx] Start fleshing out Format6 2018-10-10 19:58:20 -04:00
Behdad Esfahbod 4c3b19d52e Support HBUINT32 BinSearchArrayOf 2018-10-07 22:30:42 -04:00
Behdad Esfahbod 456a68c506 Move code 2018-10-07 22:28:45 -04:00
Behdad Esfahbod 606bf57430 Revert forcing use of single-parameter static_assert()
Some clang versions define static_assert as a macro apparently, so we cannot
redefine it...

This reverts commit 94bfea0ce6.
This reverts commit 4e62627831.
2018-09-16 19:34:39 +02:00
Behdad Esfahbod 4e62627831 Enforce single-param static_assert() only
So we don't accidentally break it again.
2018-09-16 18:09:36 +02:00
Behdad Esfahbod ebd50b3c83 Fix static_assert 2018-09-16 17:57:12 +02:00
Behdad Esfahbod 10642b3fbf Disallow null-enabled offsets to unsized structures...
...like UnsizedArrayOf<>.

This fixes a class of crasher bugs, mostly with color and AAT tables.  We
cannot use nullable offsets to varsized data that does not declare min_size,
because it's nost safe to use our fixed-size null pool for types that have
their size external.  So, use non_null'able offsets for these.

A further enhancement would be to make use of min_size in Null<> itself.
Will try that after.
2018-09-15 19:43:33 +02:00
Behdad Esfahbod f8ccb545c4 [dfont] Disable null-processsing for offsets
An offset to unsized arrayis not safe to be redirected to our fixed-sized
null pool.  Plus, we want to reject, not repair, bad-looking dfonts.
2018-09-14 18:59:53 +02:00
Behdad Esfahbod 3789c557ca [dfont] Solve the mystery +2 offset thing!
Previously, ResourceForkHeader was defined as 30 bytes, having the typeCountM1 as last member.
There was a mysterious offset-by-2 in the code, derived from FontTools and JDK code this was
ported from.

In testing, I observed that typeListZ offset is actually 28.  Suggesting that the typeCountM1
does NOT actually belong to ResourceForkHeader, but belongs to the array itself.  Adjusting for
that resolves the mystery +2 offset hack, so everything is clean and good now.

This, concludes my dfont hacking.  The code looks great now, and I'm happy to leave it.
Fuzzers might disagree though, we will see!
2018-09-13 20:32:13 +02:00
Behdad Esfahbod effc7ced72 Rename HeadlessArrayOf::len to lenP1
So it doesn't accidentally match our templates, etc.
2018-09-13 20:21:54 +02:00
Behdad Esfahbod 29faebe911 Allow Offset<>'s that have no 0==null 2018-09-13 18:47:25 +02:00
Behdad Esfahbod 361fc26861 Fix OffsetTo::sanitize() after reshuffling 2018-09-13 16:47:33 +02:00
Behdad Esfahbod 4c6b0fb5f6 OffsetTo::sanitize() Add version with three user_data 2018-09-13 16:39:30 +02:00
Behdad Esfahbod a73bea69c5 OffsetTo::sanitize() more shuffling 2018-09-13 16:31:31 +02:00
Behdad Esfahbod b482e5231c OffsetTo::sanitize() reshuffling 2018-09-13 16:29:49 +02:00
Behdad Esfahbod bccf3e1827 Minor 2018-09-11 01:04:50 +02:00
Behdad Esfahbod dff2c45f1e Port rest from VAR to UnsizedArrayOf<> 2018-09-11 01:01:08 +02:00
Behdad Esfahbod 9507b05a7a Simplify sanitize->check_array()
Fix a bug in CBDT sanitize, and redundant check in avar.
2018-09-10 23:18:23 +02:00
Behdad Esfahbod fda994e1d4 Use enum instead of "static const" in class scope
Technically, static const needs an out-of-class definition.  Eg:

  CXXLD    libharfbuzz-subset.la
Undefined symbols for architecture x86_64:
  "OT::FeatureVariationRecord::min_size", referenced from:
      bool OT::GSUBGPOS::subset<OT::PosLookup>(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o
      bool OT::GSUBGPOS::subset<OT::SubstLookup>(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o
  "OT::Record<OT::LangSys>::min_size", referenced from:
      OT::Script::subset(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o
  "OT::IntType<unsigned short, 2u>::min_size", referenced from:
      OT::Script::subset(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o
      OT::RecordListOf<OT::Feature>::subset(hb_subset_context_t*) const  in libharfbuzz_subset_la-hb-subset.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[4]: *** [libharfbuzz-subset.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Exited with code 2
2018-09-07 15:02:57 -04:00
Behdad Esfahbod 49c44b58f6 [subset] Fix serialize_subset() calls
Ouch.
2018-09-03 16:37:17 -07:00
Behdad Esfahbod bfa72a9a72 [subset] Towards GSUB/GPOS subsetting
Add subset() call for GSUBGPOS struct and its dependencies.
Not hooked up anywhere.
2018-09-01 18:34:50 -07:00
Behdad Esfahbod d1f29908c2 [subset] Add hb_subset_context_t<> 2018-08-31 16:31:00 -07:00
Behdad Esfahbod c77ae40852 Rename hb-*private.hh to hb-*.hh
Sorry for the noise, downstream custom builders.  Please adjust.
2018-08-25 22:36:36 -07:00