Commit Graph

256 Commits

Author SHA1 Message Date
Qunxin Liu 37572882e7 [subset] cmap table to use _subset2 and new iterator frameworks 2019-08-05 11:26:34 -07:00
Ebrahim Byagowi 7a9d643c29
Fix unintialized memory read in cmap subset (#1826) 2019-07-11 01:35:07 +04:30
Behdad Esfahbod 3caa32d737 [config] Add HB_NO_CMAP_LEGACY_SUBTABLES
Part of https://vimeo.com/331852453/06eec89c65
2019-06-19 19:59:26 -07:00
Michiharu Ariza 82d4bfb8f3 enable cff subset tests
add Unicode UCS-4 cmap
fix Unicode bits in OS/2
add Unicode cmap sub-table in SourceHanSans-Regular_subset.otf
regenerate cff subset test expected results
2019-06-14 11:08:59 -07:00
Qunxin Liu 993d81b9c5 [subset] Add one ttf file with fvar/STAT tables to integration test
Ignore gvar/MVAR/HVAR table
add support for --nameIDs=* option
2019-05-22 17:20:45 -07:00
Garret Rieger a5fb44a8cb [subset] Fix shadowed 'groups' param in cmap. 2019-05-13 15:04:35 -07:00
Behdad Esfahbod 750d5af48e Make compiler happy with -Og 2019-05-08 12:10:00 -07:00
Behdad Esfahbod 41248cce0e Remove MIN/MAX in favor of hb_min/hb_max 2019-05-07 20:54:31 -07:00
Behdad Esfahbod 699de689e9 Delete default assignment operator Offset<> 2019-04-15 16:00:20 -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 64d0f08938 [cmap] Minor 2019-04-01 16:56:41 -07:00
Behdad Esfahbod b986c6a321 [C++11] Remove IntType::set() in favor of operator= 2019-03-29 20:21:21 -07:00
Behdad Esfahbod 090fe56dc6 Merge branch 'master' into iter 2019-01-25 16:06:52 +01:00
Behdad Esfahbod 447323b85a Better fix for -Wcast-align errors 2019-01-22 12:50:12 +01:00
Behdad Esfahbod 8d05bf7dc0 Fix cast-align error
If compiler doesn't inline StructAtOffset, this was an error since we
only disable cast-align at call-site.  So, move the cast out.

../src/hb-machinery.hh: In instantiation of 'const Type& StructAtOffset(const void*, unsigned int) [with Type = unsigned int]':
../src/hb-font.cc:146:85:   required from here
../src/hb-machinery.hh:63:12: error: cast from 'const char*' to 'const unsigned int*' increases required alignment of target type [-Werror=cast-align]
 { return * reinterpret_cast<const Type*> ((const char *) P + offset); }
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/hb-machinery.hh: In instantiation of 'Type& StructAtOffset(void*, unsigned int) [with Type = unsigned int]':
../src/hb-font.cc:147:79:   required from here
../src/hb-machinery.hh:66:12: error: cast from 'char*' to 'unsigned int*' increases required alignment of target type [-Werror=cast-align]
 { return * reinterpret_cast<Type*> ((char *) P + offset); }
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-01-22 12:34:05 +01:00
Behdad Esfahbod ef00654962 Convert tag enum class consts to static constexpr
Part of https://github.com/harfbuzz/harfbuzz/issues/1553
2019-01-22 12:17:26 +01:00
Behdad Esfahbod 8237809f06 [serialize] Make SortedArrayOf:;serialize() take sorted-iterator 2019-01-20 20:12:12 -05:00
Behdad Esfahbod b900f78088 [pragma] More cast-align whitelist 2019-01-18 10:08:23 -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
Ebrahim Byagowi b2ebaa9afa Remove redundant 'inline' from methods (#1483) 2018-12-16 14:08:10 -05:00
Behdad Esfahbod 6e33a3955d Minor 2018-12-13 16:40:01 -05:00
Ebrahim Byagowi 7ee5c52345
minor style fix, use void in methods on no argument 2018-12-12 15:14:37 +03:30
Behdad Esfahbod 5c4fead734 Convert "static const hb_tag_t" constants to enum 2018-11-29 15:05:47 -05:00
Behdad Esfahbod 861bc75349 [vector] Make pointer cast explicit
Too bad this doesn't help MSVC 2008 build, as explicit operators are
C++11.
2018-11-29 14:34:44 -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 ec83b2228e Add null bytes for CmapSubtableLongGroup 2018-11-23 19:59:31 -05:00
Behdad Esfahbod e4a4555d1e [cmap] Move code around 2018-11-22 22:17:49 -05:00
Ebrahim Byagowi 11aa0468ac [subset] minor, adjust spaces 2018-11-16 00:02:47 +03:30
Behdad Esfahbod da6aa3b033 Add hb_blob_ptr_t.destroy() 2018-11-11 11:40:57 -05:00
Behdad Esfahbod 0e2680a6e8 [cmap] Port to hb_blob_ptr_t
Although didn't need it...
2018-11-11 00:28:47 -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 56ba998cdd [cmap] Push get_nominal_glyphs down into cmap accelerator 2018-11-05 19:49:54 -05:00
Behdad Esfahbod 36d85dce25 [cmap] Use hb_nonnullptr_t 2018-11-05 19:46:29 -05:00
Behdad Esfahbod bb380ec183 [cmap] Make null accelerator safe
Fixes https://github.com/harfbuzz/harfbuzz/issues/1146
2018-11-05 13:47:30 -05:00
Behdad Esfahbod 56e0fd345c Remove last use of hb_auto_t<> 2018-10-29 22:35:44 -07:00
Behdad Esfahbod 3a4e5dd425 Remove a few unnecessary hb_auto_t<>'s
See a85641446c30247c4e948263f0f8c1147ed4efb9
2018-10-29 22:27:20 -07:00
Behdad Esfahbod be87959a67 [cmap] Minor 2018-10-29 15:16:38 -07:00
Behdad Esfahbod 955aa56b11 [vector] Make it act more like pointer
Add pointer cast operator and plus operator.
2018-10-25 16:50:38 -07:00
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
Ebrahim Byagowi 63109432cf Cosmetic and minor changes 2018-10-13 07:23:33 -04:00
Behdad Esfahbod 341206eb60 [vector] Make hb_vector_t relocatable / nestable
Ugly, but...
Fixes https://github.com/harfbuzz/harfbuzz/issues/1227
2018-10-05 18:39:48 +02:00
Behdad Esfahbod dff2c45f1e Port rest from VAR to UnsizedArrayOf<> 2018-09-11 01:01:08 +02:00
Behdad Esfahbod d1f29908c2 [subset] Add hb_subset_context_t<> 2018-08-31 16:31:00 -07:00
Behdad Esfahbod aba0a945c5 [subset] Add hb-subset-input.hh and make hb-subset.hh toplevel include 2018-08-31 13:25:19 -07:00
Behdad Esfahbod 2ccc322cf8 [ot-font] Clean up cmap with gid=0
Fixes https://github.com/harfbuzz/harfbuzz/issues/1145
2018-08-29 16:38:25 -07:00
Behdad Esfahbod 3a0b3a29cc Free up hb-ot-face.hh from includes
There might be a better way to do this, but I couldn't find...
2018-08-26 15:11:24 -07:00
Behdad Esfahbod 963413fc54 WIP 2018-08-26 00:47:55 -07:00
Behdad Esfahbod e6cb938065 [ot-face] Unify accelerators and tables 2018-08-26 00:21:29 -07:00
Behdad Esfahbod 1c48a7ef06 [ot-font] Cache tables on face, not font 2018-08-25 23:57:16 -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
Behdad Esfahbod 82b12bcadd [unicode] Add HB_UNICODE_MAX
New API:
HB_UNICODE_MAX
2018-08-25 22:07:17 -07:00
Behdad Esfahbod 28634db07e [cmap] Fix skipping gid0 in Format4 collect_unicodes() 2018-08-25 21:23:43 -07:00
Behdad Esfahbod ddea4d19cf Add 1-param passthrough constructor to hb_auto_t<>
And use.
2018-08-25 21:08:15 -07:00
Behdad Esfahbod c8cfb702e9 [cmap] Minor 2018-08-25 16:18:00 -07:00
Behdad Esfahbod 1dcf5fb038 [cmap Add hb_subset_collect_variation_unicodes()
To be moved to hb-face.h later.
2018-08-25 16:12:18 -07:00
Behdad Esfahbod 4806b3800d [cmap] Add hb_subset_collect_variation_selectors()
To be moved to hb-face later.
2018-08-25 15:58:40 -07:00
Behdad Esfahbod 3336de2479 [cmap] Remove unused code 2018-08-25 15:41:25 -07:00
Behdad Esfahbod 1becabe06c [cmap] Use bsearch to find subtables 2018-08-25 15:37:56 -07:00
Behdad Esfahbod 02fe03e09a [cmap] Factor out find_best_subtable 2018-08-25 15:33:05 -07:00
Behdad Esfahbod b41c43b4e1 Minor 2018-08-25 15:25:03 -07:00
Behdad Esfahbod 7d382fa276 [cmap] Implement collect_unicodes() for Format0/6/10 2018-08-25 09:42:52 -07:00
Behdad Esfahbod bd0e542525 [cmap] Simplify collect_unicodes()
Don't use accelerator (almost).  Hooks up Format13 as well.
2018-08-25 09:33:30 -07:00
Behdad Esfahbod d60c465627 Rename get_all_codepoints() to collect_unicodes() 2018-08-25 08:48:42 -07:00
Behdad Esfahbod 531051b8b9 [ot-font] Return char-not-found if mapped to gid 0
OpenType cmap table can use gid=0 to mean "not covered" to produce
more optimized cmap subtables.  Return false from get_nominal_glyph()
for those.  hb-ft already does this.
2018-08-25 08:44:18 -07:00
Garret Rieger 2bdd903c69 [subset] limit the max codepoint value to the unicode limit.
When collecting all codepoints in the cmap avoid using large amount of memory for fonts that declare coverage over all 32 bit integers.
2018-07-31 18:40:38 -07:00
Behdad Esfahbod e57a638bde One more 2018-07-23 12:00:02 -07:00
Behdad Esfahbod 36ed163fdd Remove unnecessary OT:: namespace specifiers 2018-07-23 11:57:45 -07:00
Behdad Esfahbod 9583e0077d Port more off of Sanitizer<> 2018-07-22 22:43:25 -07:00
Behdad Esfahbod bddeb2b10c Minor renamings of internal inline functions 2018-07-10 14:13:21 +02:00
Behdad Esfahbod f7515769fd [vector] Use Crap pool in push() as well 2018-06-01 17:48:37 -07:00
Garret Rieger 251cc977e9 [subset] Switch to using hb_map_t inside of hb_subset_plan_t. 2018-05-30 17:23:59 -06:00
Behdad Esfahbod e99d75ea9c Fix warning 2018-05-09 15:31:57 -07:00
Behdad Esfahbod 63f57f4dab Mark more unsized array's as arrayZ 2018-05-08 16:56:11 -07:00
Behdad Esfahbod 0644d92ef3
Merge pull request #1018 from googlefonts/cmap4
[subset] Add cmap format 4 subsetting.
2018-05-08 15:21:09 -07:00
Behdad Esfahbod eba1c16a60 Always lock blob in sanitize. Remove blob->lock_as() in favor of blob->lock() 2018-05-08 02:47:42 -07:00
Behdad Esfahbod b4fa505014 Move Sanitizer::lock_instance<>() to blob->lock_as<>(). 2018-05-08 02:45:08 -07:00
Behdad Esfahbod abc12f7b81 Move null pool to hb-private 2018-05-08 02:23:36 -07:00
Garret Rieger 3be050f075 [subset] entrySelectorZ -> entrySelector. 2018-05-04 11:23:32 -07:00
Garret Rieger 7c22f98da7 [subset] add missing template parameter. 2018-05-04 11:20:03 -07:00
Garret Rieger 95eb0f3baf [subset] Switch to a non-log using implementation of caculating searchRangeZ, entrySelectorZ, and rangeShiftZ in cmap4. 2018-05-04 11:20:03 -07:00
Garret Rieger c817992f49 [subset] Write out a format 4, plat 0 encoding record to match fontTools. 2018-05-04 11:20:03 -07:00
Garret Rieger 9ef55a4c13 [subset] A few bug fixes for cmap format 4 subsetting. 2018-05-04 11:20:03 -07:00
Garret Rieger 81ea75f5c8 [subset] Complete implementation of cmap4 subsetting. 2018-05-04 11:20:03 -07:00
Garret Rieger 4195a52b04 [subset] WIP implementation of serialize for cmap format 4. 2018-05-04 11:20:03 -07:00
Garret Rieger cfa592d31c [subset] Add an implement for cmap format 4 create_sub_table_plan. 2018-05-04 11:20:03 -07:00
Garret Rieger 295d67ea7d [subset] WIP cmap format 4 subsetting. 2018-05-04 11:20:03 -07:00
Garret Rieger 0053d13283 [subset] Refactor cmap subsetting to make it possible to add support for more sub tables. 2018-05-04 11:20:03 -07:00
Behdad Esfahbod 5b93f69169 Rename some X-terminated members to Z-terminated
X-terminated means don't access this, it's not located correctly.
Z-terminated means this is a C array with no bound checking.
2018-05-02 14:59:14 -04:00
Behdad Esfahbod 37b95612d4 Remove hb_auto_array_t
Part of https://github.com/harfbuzz/harfbuzz/issues/1017
2018-05-01 19:09:00 -04:00
Behdad Esfahbod 5c3112aec8 s/hb_prealloced_array_t/hb_vector_t/g
Part of https://github.com/harfbuzz/harfbuzz/issues/1017
2018-05-01 19:07:04 -04:00
Garret Rieger 5e318e09ba [subset] Fix broken cmap creation.
It was ignoring the restriction that gids must be consecutive to be placed into a single group.
2018-04-19 12:51:51 -06:00
Garret Rieger 5dadbb0fa0 [subset] Add implementation of cmap format 12 codepoint listing. (#988) 2018-04-17 15:00:23 +02:00
Garret Rieger 39754fb659 [subset] Don't assume the last segment in cmap 4 can be skipped, actually check it. 2018-04-16 16:29:26 -06:00
Garret Rieger 21a181af2b [subset] sketch out support for a call that lists all codepoints present in a font. Implement support for it in format 4 cmap sub table. 2018-04-16 16:29:26 -06:00
Ebrahim Byagowi 435b1878e7
Rename UINT24 to HBUINT24 for consistency (#983) 2018-04-15 21:18:48 +04:30
Ebrahim Byagowi f24b0b9728 Update the links and revive the dead ones 2018-04-12 13:44:32 +04:30
Ebrahim Byagowi b799fc8077
minor, use LOffsetTo and LArrayOf whenever possible (#966) 2018-04-11 18:36:09 +04:30
Garret Rieger 0fb8a5ce19 [subset] Fix memory leak in cmap subsetting. 2018-02-23 15:37:43 -08:00
Behdad Esfahbod d1f16fce96 Don't use %zu
Some of our bots / compilers don't like it. Wasn't caught by bots because this
is only in debug code.

825ad378e0
2018-02-20 10:32:09 -08:00
Dominik Röttsches 25136d9b72 Use %zu format specifier for size_t to fix cross platform build
Fixes Chromium Android builds, compare
https://ci.chromium.org/buildbot/tryserver.chromium.android/linux_android_rel_ng/491787
2018-02-20 14:01:15 +02:00
Behdad Esfahbod 6fa690c75a Fix debug build
Context needs to be called 'c'. The TRACE_* rely on that.
2018-02-18 16:27:59 -08:00
Rod Sheeter 1725c35da0 [subset] cmap space bracket 2018-02-14 19:36:33 -08:00
Behdad Esfahbod b1bd0b5f50 [subset] Minor 2018-02-14 18:50:19 -08:00
Rod Sheeter 3ed70e5e64 [subset] return bool not hb_bool_t from table::subset 2018-02-14 15:24:49 -08:00
Rod Sheeter 88d56e241b [subset] Use a supplier instead of memcpy and fix a few unnecessary {}s for cmap 2018-02-14 15:20:43 -08:00
Rod Sheeter fa87770372 [subset] First pass at hmtx 2018-02-14 14:53:10 -08:00
Rod Sheeter a0fe3011ba copy all cmap groups at once 2018-02-14 10:52:41 -08:00
Garret Rieger 343dfe8965 [subset] white and add inline in hb-ot-cmap-table. 2018-02-14 10:19:50 -08:00
Rod Sheeter d1a4d5616f output format 12 as enc 10 to match how Roboto did it 2018-02-12 16:25:32 -08:00
Rod Sheeter 1330edc4fe Use functions to get new gids. Avoid 0; fonttools drops it from cmap. 2018-02-12 14:29:23 -08:00
Rod Sheeter a5713bc2cb we love all our groups 2018-02-12 11:30:57 -08:00
Rod Sheeter 0301e5be28 Build a working cmap format 12 2018-02-12 10:12:11 -08:00
Behdad Esfahbod 41906cd5ef [subset] Another fixup
I broke this in c31fcf4c58
2018-02-11 19:46:06 -06:00
Behdad Esfahbod 9aa2eb61e6 Minor 2018-02-11 19:00:49 -06:00
Behdad Esfahbod c31fcf4c58 [subset] Replace auto_array with prealloced_array
auto_array has constructor/destructor. Cannot be used in POD object, as the clang
bots all noticed...
2018-02-10 14:20:10 -06:00
Rod Sheeter 9275bd03ea First pass at building a cmap 2018-02-09 17:40:52 -08:00
Rod Sheeter 1cd98d05e0 Create the groups for a cmap format12. Does not yet build the actual table. 2018-02-08 19:39:57 -08:00
Rod Sheeter 59c658c8d5 capture codepoints sorted so we can use them for cmap later. one day we will have a map 2018-02-08 19:22:47 -08:00
Behdad Esfahbod 9682ef135f Minor fixups 2018-02-08 17:35:57 -06:00
Rod Sheeter 13193a9b97 move to the hb_face_t dest pattern 2018-02-08 17:31:11 -06:00
Rod Sheeter 0859a00669 sketch a subset<T> and call it for cmap. Add subset to cmap, albeit not working even for the msot basic case just yet 2018-02-08 17:31:11 -06:00
Behdad Esfahbod 6b19178ee3 Prefix int types with HB
Such a headache that Windows defines UINT8, ...; Just prefix it.
2018-01-10 03:07:30 +01:00
Behdad Esfahbod 470fe5b603 [aat] Implement Lookup table
Untested, but compiles.
2018-01-10 02:50:49 +01:00
Behdad Esfahbod 6f335ed1e5 Replace USHORT/SHORT/ULONG/etc with UINT16/INT16/UINT32/etc 2017-11-14 21:06:07 -08:00
Behdad Esfahbod 977ddff1f1 [ot] Move hb_ot_face_cmap_accelerator_t 2017-11-14 20:06:19 -08:00
Behdad Esfahbod dbdbfe3d7b Use nullptr instead of NULL 2017-10-15 12:11:08 +02:00
Behdad Esfahbod 5e156fa5ed Add LOffsetTo<> 2017-01-22 20:28:56 -08:00
Behdad Esfahbod 23335deaad [ot-font] Accelerate cmap format4 get_glyph 2016-02-24 20:27:13 +09:00
Behdad Esfahbod 5473ebfb84 [ot-font] Remove level of indirection in get_glyph_variant 2016-02-24 19:32:43 +09:00
Behdad Esfahbod b47159011c Define return_trace()
Not functional change (expected!).
2015-09-29 14:57:02 +01:00
Behdad Esfahbod de2118ed7a Make sanitize() a const method
This makes a lot of code safer.  We only try modifying the object in one
place, after making sure it's safe to do so.  So, do a const_cast<> in
that one place...
2015-02-25 15:43:28 -08:00
Behdad Esfahbod 7627100f42 Mark unsigned integer literals with the u suffix
Simplifies hb_in_range() calls as the type can be inferred.
The rest is obsessiveness, I admit.
2014-07-11 16:22:13 -04:00
Behdad Esfahbod af528b6674 Fix typo; ouch! 2014-06-27 18:07:00 -04:00
Behdad Esfahbod 7d4ada66c9 Mark unsed members with a "Z" suffix
There may be more.  There are members that are by definition
redundant or reserved and not needed, NOT what we *currently*
don't use.

I'm sure there's more...
2014-06-27 17:32:56 -04:00
Behdad Esfahbod a5a4736916 [cmap] Implement subtable format 14 2014-06-27 17:22:31 -04:00
Behdad Esfahbod 41ea594950 Minor: Remove LongSortedArrayOf 2014-06-27 15:23:18 -04:00
Behdad Esfahbod 9da552dcc5 Minor: Remove some GenericXXX templates 2014-06-27 15:18:36 -04:00
Behdad Esfahbod 36073ede5b Minor: Reorder template parameter order 2014-06-27 15:18:26 -04:00
Behdad Esfahbod df554af99d Rename search() to bsearch() and lsearch()
Such that the complexity of the algorithm used is clear at
call site.
2014-06-19 15:39:18 -04:00
Behdad Esfahbod f1a72fe7bf [ot-font] Fix cmap EncodingRecord cmp order 2014-06-04 19:03:16 -04:00
Behdad Esfahbod ce34f0b07e [ot-font] Use binary search for format12 cmap subtable 2014-06-04 18:57:46 -04:00
Behdad Esfahbod 257d1adfa1 [ot-font] Work around broken cmap subtable format 4 length
Roboto was hitting this.  FreeType also has pretty much the
same code for this, in ttcmap.c:tt_cmap4_validate():

    /* in certain fonts, the `length' field is invalid and goes */
    /* out of bound.  We try to correct this here...            */
    if ( table + length > valid->limit )
    {
      if ( valid->level >= FT_VALIDATE_TIGHT )
        FT_INVALID_TOO_SHORT;

      length = (FT_UInt)( valid->limit - table );
    }
2014-06-04 18:47:55 -04:00
Behdad Esfahbod 500737e8e1 [ot-font] Don't select a Null cmap subtable
Can happen either in broken fonts, or as a result of sanitize().
2014-06-04 18:17:29 -04:00
Behdad Esfahbod c95587618c [ot] Minor note re cmap subtable format 2 and 8 2014-05-14 00:42:18 -04:00
Behdad Esfahbod b7878cd58e [ot] Implement cmap subtable format 0 2014-05-13 21:47:51 -04:00
Behdad Esfahbod ca7b77431d [ot] Factor out code between cmap sutable format 12 and 13 2014-05-13 21:26:34 -04:00
Behdad Esfahbod 94759e8219 [ot] Factor out code between cmap subtable format 6 and 10 2014-05-13 21:19:49 -04:00