Commit Graph

227 Commits

Author SHA1 Message Date
Behdad Esfahbod 7c4e9080c0 [sanitize] Minor trace format fixup
This likely() is unlikely to make a difference, and obscures
the return_trace() message by writing out "something" instead
of the true/false value.
2022-07-11 21:52:41 -06:00
Behdad Esfahbod 2c67261723 [open-type] Add HBGlyph24 2022-07-08 12:01:26 -06:00
Behdad Esfahbod 486555c691 [open-type] Add Array24Of<> and SortedArray24Of<> 2022-07-08 12:01:07 -06:00
Thomas Devoogdt c657c4e1f8 [meta] fix type traits on gcc 4.9 #3526
Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com>
2022-05-13 11:26:12 -06:00
Behdad Esfahbod 7a078c395a [meta] Use std::conditional instead of hb_conditional() 2021-11-02 00:44:51 -06:00
Behdad Esfahbod 943921cf0c [meta] Use more std type_traits 2021-11-02 00:26:46 -06:00
Behdad Esfahbod 6d555ce82e [meta] Use std::forward instead of hb_forward() 2021-11-02 00:18:22 -06:00
Behdad Esfahbod be42800fc6 [meta] Use std::is_trivially_... instead of internal copies 2021-11-02 00:04:18 -06:00
Behdad Esfahbod 14a2df7bc2 Add stub HBUINT15 2021-09-19 23:06:09 -04:00
Behdad Esfahbod c852b86841 Rename HBGlyphID to HBGlyphID16 2021-09-19 16:30:12 -04:00
Behdad Esfahbod f0a1892ff9 [serialize] Remove unnecessary pointer indirection 2021-07-28 17:36:22 -06:00
Behdad Esfahbod 03cd9c5cba Align lfind() API to match bfind() 2021-07-22 11:38:27 -07:00
Behdad Esfahbod 29c9833e57 Remove Offset::serialize()
Finishing https://github.com/harfbuzz/harfbuzz/pull/2355
2021-07-09 11:58:36 -06:00
Garret Rieger 0da9158f62 [subset] Remove OffsetTo::serialize().
Convert remaining uses of it to serialize_serialize() which correctly uses the object packer.
2021-06-30 14:05:48 -07:00
Garret Rieger 35458b6b66 [subset] Add serialize_serialize to OffsetTo.
Similar to serialize_subset() this will serialize the new object and then link it to the offset.
2021-06-14 12:18:06 -07: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 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
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
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 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
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 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 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 e5b7bc424d m Add default value to BEInt<> Size template parameter 2021-02-20 15:14:15 -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 25c0a792e3 Remove unused+wrong UnsizedArrayOf<> operators
Said compiler is wrong to err since they are unused. But yeah, they
didn't make sense and were copy/paste leftover.

Fixes https://github.com/harfbuzz/harfbuzz/issues/2763
2020-12-10 14:29:47 -07:00
Ebrahim Byagowi 7e3edfa454
minor 2020-07-18 19:03:36 +04:30
Ebrahim Byagowi 08d57d9eca
Add hb_array_t::lfind 2020-06-28 13:13:25 +04:30
Ebrahim Byagowi 385d64eef1 Add a not discardable bool type, hb_success_t 2020-05-07 10:26:45 +04:30
Ebrahim Byagowi 07acd1a042 [subset] Rename src_base args to base to match sanitize methods
So it will become easier to follow that serialize methods signatures should
match with their sanitize methods counterparts.
2020-03-08 23:39:26 +03:30
ariza 188a0a47c2 removed default base; replaced w/ bias if required 2020-03-08 22:59:43 +03:30
ariza 4aa354beba chain second OffsetTo::serialize_copy() to first 2020-02-21 10:17:26 -08:00
ariza 4ca8e0d989 re-implement Tail; rewrote name table with it 2020-02-21 10:17:25 -08:00
Qunxin Liu 82afc75835 [subset] GPOS4 MarkBase subsetting support 2020-02-06 10:46:05 -08:00
Behdad Esfahbod b1dc676eaa [algs] Reduce one more bsearch() impl
Ouch, there were three more left.  Down one.  Two to go.
2019-12-10 12:13:40 -06:00