From 963413fc5454d92621ae83a8d9c9324e404b8166 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 26 Aug 2018 00:47:55 -0700 Subject: [PATCH] WIP --- src/hb-ot-cmap-table.hh | 1 - src/hb-ot-face.hh | 22 ---------------------- src/hb-ot-layout-gpos-table.hh | 2 ++ src/hb-ot-layout-gsub-table.hh | 2 ++ src/hb-ot-layout-gsubgpos.hh | 31 ++++++++++++++++++++++++++++++- src/hb-ot-layout.hh | 18 +++++++++++++++++- 6 files changed, 51 insertions(+), 25 deletions(-) diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index cdf67f1..c357714 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -1018,7 +1018,6 @@ struct cmap { inline void init (hb_face_t *face) { - /* TODO Switch to using table from face->ot.table. */ this->blob = hb_sanitize_context_t().reference_table (face); const cmap *table = this->blob->as (); const CmapSubtableFormat14 *subtable_uvs = nullptr; diff --git a/src/hb-ot-face.hh b/src/hb-ot-face.hh index bbbc6e2..1466f11 100644 --- a/src/hb-ot-face.hh +++ b/src/hb-ot-face.hh @@ -32,7 +32,6 @@ #include "hb.hh" #include "hb-machinery.hh" -#include "hb-set-digest.hh" #include "hb-ot-cmap-table.hh" #include "hb-ot-glyf-table.hh" @@ -46,27 +45,6 @@ * hb_ot_face_data_t */ -struct hb_ot_layout_lookup_accelerator_t -{ - template - inline void init (const TLookup &lookup) - { - digest.init (); - lookup.add_coverage (&digest); - } - - inline void fini (void) - { - } - - inline bool may_have (hb_codepoint_t g) const { - return digest.may_have (g); - } - - private: - hb_set_digest_t digest; -}; - /* Most of these tables are NOT needed for shaping. But we need to hook them *somewhere*. * This is as good as any place. */ #define HB_OT_LAYOUT_TABLES \ diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 66767df..e1a4050 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1522,6 +1522,8 @@ struct GPOS : GSUBGPOS const OffsetTo &list = CastR > (lookupList); return_trace (list.sanitize (c, this)); } + + typedef GSUBGPOS::accelerator_t accelerator_t; }; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index d2c1fb9..59e8a43 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1317,6 +1317,8 @@ struct GSUB : GSUBGPOS const OffsetTo &list = CastR > (lookupList); return_trace (list.sanitize (c, this)); } + + typedef GSUBGPOS::accelerator_t accelerator_t; }; diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index d21c3de..44b595a 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -988,7 +988,6 @@ struct LookupRecord DEFINE_SIZE_STATIC (4); }; - template static inline void recurse_lookups (context_t *c, unsigned int lookupCount, @@ -2382,6 +2381,36 @@ struct GSUBGPOS (version.to_int () < 0x00010001u || featureVars.sanitize (c, this))); } + template + struct accelerator_t + { + inline void init (hb_face_t *face) + { + this->blob = hb_sanitize_context_t().reference_table (face); + const T &table = *this->blob->as (); + + this->lookup_count = table.get_lookup_count (); + + this->accels = (hb_ot_layout_lookup_accelerator_t *) calloc (this->lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); + if (unlikely (!this->accels)) + this->lookup_count = 0; + + for (unsigned int i = 0; i < this->lookup_count; i++) + this->accels[i].init (table.get_lookup (i)); + } + + inline void fini (void) + { + hb_blob_destroy (this->blob); + free (accels); + } + + private: + hb_blob_t *blob; + unsigned int lookup_count; + hb_ot_layout_lookup_accelerator_t *accels; + }; + protected: FixedVersion<>version; /* Version of the GSUB/GPOS table--initially set * to 0x00010000u */ diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh index fcc0998..02c8c7b 100644 --- a/src/hb-ot-layout.hh +++ b/src/hb-ot-layout.hh @@ -34,6 +34,7 @@ #include "hb-font.hh" #include "hb-buffer.hh" #include "hb-open-type.hh" +#include "hb-set-digest.hh" /* Private API corresponding to hb-ot-layout.h: */ @@ -86,7 +87,22 @@ hb_ot_layout_substitute_start (hb_font_t *font, hb_buffer_t *buffer); -struct hb_ot_layout_lookup_accelerator_t; +struct hb_ot_layout_lookup_accelerator_t +{ + template + inline void init (const TLookup &lookup) + { + digest.init (); + lookup.add_coverage (&digest); + } + inline void fini (void) {} + + inline bool may_have (hb_codepoint_t g) const + { return digest.may_have (g); } + + private: + hb_set_digest_t digest; +}; namespace OT { struct hb_ot_apply_context_t; -- 2.7.4