Commit Graph

51 Commits

Author SHA1 Message Date
Behdad Esfahbod 2520a82df9 s/LArrayOf/Array32Of/g 2021-03-31 15:41:54 -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 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
Ebrahim Byagowi 25cf687443
Use dagger in OffsetTable::get_table_tags (#2477) 2020-06-19 14:06:50 -07:00
Ebrahim Byagowi 2dda6dd744 minor, tweak spacing
turn 8 spaces to tab, add space before Null/Crap
2020-04-20 16:18:29 +04:30
Behdad Esfahbod 858b627984 [machinery] Remove CastR<>() 2019-12-10 13:18:32 -06:00
Ebrahim Byagowi 0558413f27 Minor, tweak spaces 2019-10-01 13:50:11 +03:30
Ebrahim Byagowi a0b4ac4dce Turn 8 spaces to tab across the project
According to the current code style of the project
2019-08-27 02:40:41 +04:30
Ebrahim Byagowi a6065d05cf Don't call memcpy when a table is empty 2019-07-10 23:38:07 +04:30
Behdad Esfahbod 41248cce0e Remove MIN/MAX in favor of hb_min/hb_max 2019-05-07 20:54:31 -07:00
Ebrahim Byagowi 92588782d7
Remove space between right angle brackets now that we have C++11 (#1689) 2019-04-30 13:05:10 -07:00
Behdad Esfahbod 07776b6096 More tweaks to previous commit
Delete assignment operator of OffsetTo<> instead of Offset<>.

In simple ArrayOf<>::sanitize() assert that Type has assignment operator.
Ideally we should SFINAE this and fallback to calling Type::sanitize()
if assignment operator is not available.  But we don't have a case of
that in the codebase.
2019-04-15 16:43:34 -04:00
Behdad Esfahbod 95df00aec1 Hide a few static methods
Looks like static methods that do not get inlined end up exported.
We have a lot more.  Need to protect all at some point.  Wish there
was an easier way, like the visibility flag we pass that automatically
hides all inline methods.

Was exposed by check-symbols.sh when compiling on OS X 10.14 with:

$ make CPPFLAGS=-Oz CXXFLAGS=-flto=thin LDFLAGS=-lc++
2019-04-12 17:51:14 -04:00
Behdad Esfahbod b986c6a321 [C++11] Remove IntType::set() in favor of operator= 2019-03-29 20:21:21 -07:00
Behdad Esfahbod 6e1c3eaf70 Fix sign comparison error 2019-01-28 14:12:41 -05:00
Behdad Esfahbod b1152d5e66 Use NNOffsetTo<> 2019-01-17 18:17:04 -05:00
Behdad Esfahbod 474a12058d [array/vector] Rename len to length 2018-12-21 18:53:01 -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
Behdad Esfahbod 0d0fe9df46 [arrays] Remove need of stride in Supplier<> 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 d77a098b73 [arrays] Improve bfind() interface
Much more useful now. :)
2018-11-24 10:06:13 -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 e2ffb33a53 Remove lsearch for small TableDirectorys 2018-11-23 16:24:28 -05:00
Behdad Esfahbod 72462eb765 Add UnsizedArrayOf::as_array() instead of hb_array() template 2018-11-02 11:46:42 -04: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 abfbba1911 Add hb_array<>()
Simplifies transient object creation.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1301
2018-10-22 21:27:45 -07:00
Behdad Esfahbod d7865107ea Remove const from hb_array_t details
Will come in through <T> if desired.
2018-10-22 16:24:16 -07:00
Bruce Mitchener 257d0e5aa3 Fix typos. 2018-10-19 19:24:05 +03:30
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 67449c3933 Don't dereference offset before check_struct() 2018-09-14 10:58:00 +02:00
Behdad Esfahbod ca746f261e [dfont] Also check dataLen range in sanitize
Just to disagree with myself re being done with this code...
2018-09-13 20:35:21 +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 180a88a96c [dfont] Some more 2018-09-13 19:26:44 +02:00
Behdad Esfahbod 0ab0f1e5ac [dfont] Push methods further down 2018-09-13 19:13:01 +02:00
Behdad Esfahbod 8c9bdcc1fe [dfont] Minor 2018-09-13 19:08:22 +02:00
Behdad Esfahbod 4479d3a2ed [dfon]t Sanitize OpenTypeFontFace 2018-09-13 19:06:50 +02:00
Behdad Esfahbod 3fba41906f [dfont] Minor 2018-09-13 18:49:16 +02:00
Behdad Esfahbod bf852f0e62 [dfont] Make test pass
Offset 0 is not null in this context.
2018-09-13 18:47:53 +02:00
Behdad Esfahbod 82f4d776c2 [dfont] Minor 2018-09-13 18:27:20 +02:00
Behdad Esfahbod dbb764dceb [dfont] Clean up sanitize()
I don't think I broke anything.  Fuzzers will let me know..
2018-09-13 17:21:00 +02:00
Behdad Esfahbod bd75fd45cd [dfont] Some renaming, plus add link to reference doc 2018-09-11 18:32:25 +02:00
Behdad Esfahbod 4134ec1307 [dfont] Sanitize only sfnt resources as OpenTypeFontFile 2018-09-11 17:56:03 +02:00
Behdad Esfahbod 6b5e4d07ad [dfont] Minor 2018-09-11 17:26:24 +02:00
Behdad Esfahbod d5c509272f [dfont] Fix test expecatation and minor touch up
I have no way to authoritatively know, but looks like test font only has one
face.  So, adjust test expectation instead.
2018-09-11 17:18:21 +02:00
Behdad Esfahbod 9479ffefbf [dfont] Re-enable and fix offset handling
Fixes https://github.com/harfbuzz/harfbuzz/pull/1085
2018-09-11 16:41:26 +02:00
Behdad Esfahbod a1814e2bec Whitespace 2018-09-11 14:45: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 22acd424ca [serialize] Add a couple small methods 2018-08-31 16:41:18 -07:00