src/hb-aat-layout.cc | 4 src/hb-face-private.hh | 7 src/hb-machinery-private.hh | 19 +- src/hb-ot-font.cc | 51 +++--- src/hb-ot-layout-gpos-table.hh | 4 src/hb-ot-layout-gsub-table.hh | 6 src/hb-ot-layout-gsubgpos-private.hh | 2 src/hb-ot-layout-private.hh | 92 +++++++---- src/hb-ot-layout.cc | 289 +++++++++++++++++------------------ src/hb-ot-math.cc | 2 src/hb-ot-var.cc | 4 11 files changed, 258 insertions(+), 222 deletions(-)
New commits: commit 30ff8ac865a266c8dca11eeac155c2cd3d1aa159 Author: Behdad Esfahbod <[email protected]> Date: Fri Aug 3 17:32:00 2018 -0700 Rename diff --git a/src/hb-machinery-private.hh b/src/hb-machinery-private.hh index ce90fabd..0d2dbc3c 100644 --- a/src/hb-machinery-private.hh +++ b/src/hb-machinery-private.hh @@ -594,7 +594,7 @@ template <unsigned int WheresFace, typename Subclass, typename Returned, typename Stored = Returned> -struct hb_base_lazy_loader_t +struct hb_lazy_loader_t { static_assert (WheresFace > 0, ""); @@ -657,7 +657,7 @@ struct hb_base_lazy_loader_t /* Specializations. */ template <unsigned int WheresFace, typename T> -struct hb_lazy_loader_t : hb_base_lazy_loader_t<WheresFace, hb_lazy_loader_t<WheresFace, T>, T> +struct hb_object_lazy_loader_t : hb_lazy_loader_t<WheresFace, hb_object_lazy_loader_t<WheresFace, T>, T> { static inline T *create (hb_face_t *face) { @@ -681,7 +681,7 @@ struct hb_lazy_loader_t : hb_base_lazy_loader_t<WheresFace, hb_lazy_loader_t<Whe }; template <unsigned int WheresFace, typename T> -struct hb_table_lazy_loader_t : hb_base_lazy_loader_t<WheresFace, hb_table_lazy_loader_t<WheresFace, T>, T, hb_blob_t> +struct hb_table_lazy_loader_t : hb_lazy_loader_t<WheresFace, hb_table_lazy_loader_t<WheresFace, T>, T, hb_blob_t> { static inline hb_blob_t *create (hb_face_t *face) { diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 48934b1b..025f9437 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -70,10 +70,10 @@ struct hb_ot_font_t OT::vmtx::accelerator_t v_metrics; hb_face_t *face; /* MUST be JUST before the lazy loaders. */ - hb_lazy_loader_t<1, OT::glyf::accelerator_t> glyf; - hb_lazy_loader_t<2, OT::CBDT::accelerator_t> cbdt; - hb_lazy_loader_t<3, OT::post::accelerator_t> post; - hb_lazy_loader_t<4, OT::kern::accelerator_t> kern; + hb_object_lazy_loader_t<1, OT::glyf::accelerator_t> glyf; + hb_object_lazy_loader_t<2, OT::CBDT::accelerator_t> cbdt; + hb_object_lazy_loader_t<3, OT::post::accelerator_t> post; + hb_object_lazy_loader_t<4, OT::kern::accelerator_t> kern; }; commit 85ba4a190f30da5147d3b2ddac4d58dda31181f1 Author: Behdad Esfahbod <[email protected]> Date: Fri Aug 3 17:06:42 2018 -0700 [ot] Comment diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 4b90b098..b03b8252 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -142,6 +142,8 @@ struct hb_ot_layout_lookup_accelerator_t 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 \ /* OpenType shaping. */ \ HB_OT_LAYOUT_TABLE(OT, GDEF) \ commit 07afc1a213bde91fdfc44dd613f2e82ac1617c9f Author: Behdad Esfahbod <[email protected]> Date: Fri Aug 3 17:03:32 2018 -0700 [ot] Add misc tables to tables_t Most unused. diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index a579b037..4b90b098 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -142,26 +142,34 @@ struct hb_ot_layout_lookup_accelerator_t hb_set_digest_t digest; }; -namespace OT { - struct BASE; - struct COLR; - struct CPAL; -} - -namespace AAT { - struct ankr; - struct kerx; - struct trak; -} - #define HB_OT_LAYOUT_TABLES \ + /* OpenType shaping. */ \ HB_OT_LAYOUT_TABLE(OT, GDEF) \ HB_OT_LAYOUT_TABLE(OT, GSUB) \ HB_OT_LAYOUT_TABLE(OT, GPOS) \ - HB_OT_LAYOUT_TABLE(OT, MATH) \ + HB_OT_LAYOUT_TABLE(OT, JSTF) \ + HB_OT_LAYOUT_TABLE(OT, BASE) \ + /* AAT shaping. */ \ + HB_OT_LAYOUT_TABLE(AAT, morx) \ + HB_OT_LAYOUT_TABLE(AAT, kerx) \ + HB_OT_LAYOUT_TABLE(AAT, ankr) \ + HB_OT_LAYOUT_TABLE(AAT, trak) \ + /* OpenType variations. */ \ HB_OT_LAYOUT_TABLE(OT, fvar) \ HB_OT_LAYOUT_TABLE(OT, avar) \ - HB_OT_LAYOUT_TABLE(AAT, morx) \ + HB_OT_LAYOUT_TABLE(OT, MVAR) \ + /* OpenType color. */ \ + HB_OT_LAYOUT_TABLE(OT, COLR) \ + HB_OT_LAYOUT_TABLE(OT, CPAL) \ + HB_OT_LAYOUT_TABLE(OT, CBDT) \ + HB_OT_LAYOUT_TABLE(OT, CBLC) \ + HB_OT_LAYOUT_TABLE(OT, sbix) \ + HB_OT_LAYOUT_TABLE(OT, svg) \ + /* OpenType math. */ \ + HB_OT_LAYOUT_TABLE(OT, MATH) \ + /* OpenType fundamentals. */ \ + HB_OT_LAYOUT_TABLE(OT, post) \ + /* */ /* Declare tables. */ #define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; } commit 74b4df2cdef68b74536d9c29426b242199a63a6f Author: Behdad Esfahbod <[email protected]> Date: Fri Aug 3 16:57:40 2018 -0700 [ot] Move GDEF into tables_t diff --git a/src/hb-machinery-private.hh b/src/hb-machinery-private.hh index cd608cfb..ce90fabd 100644 --- a/src/hb-machinery-private.hh +++ b/src/hb-machinery-private.hh @@ -633,6 +633,12 @@ struct hb_base_lazy_loader_t return p; } + inline void set_stored (Stored *instance_) + { + assert (instance == nullptr); + instance = instance_; + } + inline const Returned * get (void) const { return thiz ()->convert (get_stored ()); diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index b967bf6f..1d5a02a0 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1335,7 +1335,7 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) { _hb_buffer_assert_gsubgpos_vars (buffer); - const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef; + const GDEF &gdef = *hb_ot_layout_from_face (font->face)->table.GDEF; unsigned int count = buffer->len; for (unsigned int i = 0; i < count; i++) { diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 747811e6..f3566ab1 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -480,7 +480,7 @@ struct hb_ot_apply_context_t : iter_input (), iter_context (), font (font_), face (font->face), buffer (buffer_), recurse_func (nullptr), - gdef (*hb_ot_layout_from_face (face)->gdef), + gdef (*hb_ot_layout_from_face (face)->table.GDEF), var_store (gdef.get_var_store ()), direction (buffer_->props.direction), lookup_mask (1), diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 3c957f1e..a579b037 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -146,9 +146,6 @@ namespace OT { struct BASE; struct COLR; struct CPAL; - struct GDEF; - struct GSUB; - struct GPOS; } namespace AAT { @@ -158,6 +155,7 @@ namespace AAT { } #define HB_OT_LAYOUT_TABLES \ + HB_OT_LAYOUT_TABLE(OT, GDEF) \ HB_OT_LAYOUT_TABLE(OT, GSUB) \ HB_OT_LAYOUT_TABLE(OT, GPOS) \ HB_OT_LAYOUT_TABLE(OT, MATH) \ @@ -172,9 +170,6 @@ HB_OT_LAYOUT_TABLES struct hb_ot_layout_t { - hb_blob_t *gdef_blob; - const struct OT::GDEF *gdef; - unsigned int gsub_lookup_count; unsigned int gpos_lookup_count; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 557800a6..bfde063d 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -170,18 +170,15 @@ _hb_ot_layout_create (hb_face_t *face) if (unlikely (!layout)) return nullptr; - layout->gdef_blob = hb_sanitize_context_t ().reference_table<OT::GDEF> (face); - layout->gdef = layout->gdef_blob->as<OT::GDEF> (); - layout->table.init0 (face); const OT::GSUB &gsub = *layout->table.GSUB; const OT::GPOS &gpos = *layout->table.GPOS; - if (_hb_ot_blacklist_gdef (layout->gdef_blob->length, - layout->table.GSUB.get_blob()->length, - layout->table.GPOS.get_blob()->length)) - layout->gdef = &Null(OT::GDEF); + if (unlikely (_hb_ot_blacklist_gdef (layout->table.GDEF.get_blob ()->length, + layout->table.GSUB.get_blob ()->length, + layout->table.GPOS.get_blob ()->length))) + layout->table.GDEF.set_stored (hb_blob_get_empty ()); unsigned int gsub_lookup_count = layout->gsub_lookup_count = gsub.get_lookup_count (); unsigned int gpos_lookup_count = layout->gpos_lookup_count = gpos.get_lookup_count (); @@ -217,8 +214,6 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) free (layout->gsub_accels); free (layout->gpos_accels); - hb_blob_destroy (layout->gdef_blob); - layout->table.fini (); free (layout); @@ -236,7 +231,7 @@ static inline const OT::GDEF& _get_gdef (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF); - return *hb_ot_layout_from_face (face)->gdef; + return *hb_ot_layout_from_face (face)->table.GDEF; } static inline const OT::GSUB& _get_gsub (hb_face_t *face) commit 0271c7ab3b76dbf8a4e3e92eaf67d9d61b7a63dc Author: Behdad Esfahbod <[email protected]> Date: Fri Aug 3 16:45:57 2018 -0700 [ot] Move GSUB/GPOS into tables_t diff --git a/src/hb-machinery-private.hh b/src/hb-machinery-private.hh index ec7a0da1..cd608cfb 100644 --- a/src/hb-machinery-private.hh +++ b/src/hb-machinery-private.hh @@ -613,10 +613,8 @@ struct hb_base_lazy_loader_t thiz ()->destroy (instance); } - inline const Returned * operator-> (void) const - { - return thiz ()->get (); - } + inline const Returned * operator -> (void) const { return thiz ()->get (); } + inline const Returned & operator * (void) const { return *thiz ()->get (); } inline Stored * get_stored (void) const { diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index b52c0144..fe34a328 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1628,14 +1628,14 @@ GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) template <typename context_t> /*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { - const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS); const PosLookup &l = gpos.get_lookup (lookup_index); return l.dispatch (c); } /*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index) { - const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS); const PosLookup &l = gpos.get_lookup (lookup_index); unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_index = c->lookup_index; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index eef8dc54..b967bf6f 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1359,14 +1359,14 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) template <typename context_t> /*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB); const SubstLookup &l = gsub.get_lookup (lookup_index); return l.dispatch (c); } /*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB); const SubstLookup &l = gsub.get_lookup (lookup_index); unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_index = c->lookup_index; diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index c09464bb..3c957f1e 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -158,6 +158,8 @@ namespace AAT { } #define HB_OT_LAYOUT_TABLES \ + HB_OT_LAYOUT_TABLE(OT, GSUB) \ + HB_OT_LAYOUT_TABLE(OT, GPOS) \ HB_OT_LAYOUT_TABLE(OT, MATH) \ HB_OT_LAYOUT_TABLE(OT, fvar) \ HB_OT_LAYOUT_TABLE(OT, avar) \ @@ -171,12 +173,7 @@ HB_OT_LAYOUT_TABLES struct hb_ot_layout_t { hb_blob_t *gdef_blob; - hb_blob_t *gsub_blob; - hb_blob_t *gpos_blob; - const struct OT::GDEF *gdef; - const struct OT::GSUB *gsub; - const struct OT::GPOS *gpos; unsigned int gsub_lookup_count; unsigned int gpos_lookup_count; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index d0adaeb3..557800a6 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -173,36 +173,33 @@ _hb_ot_layout_create (hb_face_t *face) layout->gdef_blob = hb_sanitize_context_t ().reference_table<OT::GDEF> (face); layout->gdef = layout->gdef_blob->as<OT::GDEF> (); - layout->gsub_blob = hb_sanitize_context_t ().reference_table<OT::GSUB> (face); - layout->gsub = layout->gsub_blob->as<OT::GSUB> (); - - layout->gpos_blob = hb_sanitize_context_t ().reference_table<OT::GPOS> (face); - layout->gpos = layout->gpos_blob->as<OT::GPOS> (); - layout->table.init0 (face); + const OT::GSUB &gsub = *layout->table.GSUB; + const OT::GPOS &gpos = *layout->table.GPOS; + if (_hb_ot_blacklist_gdef (layout->gdef_blob->length, - layout->gsub_blob->length, - layout->gpos_blob->length)) + layout->table.GSUB.get_blob()->length, + layout->table.GPOS.get_blob()->length)) layout->gdef = &Null(OT::GDEF); - layout->gsub_lookup_count = layout->gsub->get_lookup_count (); - layout->gpos_lookup_count = layout->gpos->get_lookup_count (); + unsigned int gsub_lookup_count = layout->gsub_lookup_count = gsub.get_lookup_count (); + unsigned int gpos_lookup_count = layout->gpos_lookup_count = gpos.get_lookup_count (); - layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); - layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); + layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gsub_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); + layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gpos_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); - if (unlikely ((layout->gsub_lookup_count && !layout->gsub_accels) || - (layout->gpos_lookup_count && !layout->gpos_accels))) + if (unlikely ((gsub_lookup_count && !layout->gsub_accels) || + (gpos_lookup_count && !layout->gpos_accels))) { _hb_ot_layout_destroy (layout); return nullptr; } - for (unsigned int i = 0; i < layout->gsub_lookup_count; i++) - layout->gsub_accels[i].init (layout->gsub->get_lookup (i)); - for (unsigned int i = 0; i < layout->gpos_lookup_count; i++) - layout->gpos_accels[i].init (layout->gpos->get_lookup (i)); + for (unsigned int i = 0; i < gsub_lookup_count; i++) + layout->gsub_accels[i].init (gsub.get_lookup (i)); + for (unsigned int i = 0; i < gpos_lookup_count; i++) + layout->gpos_accels[i].init (gpos.get_lookup (i)); return layout; } @@ -221,8 +218,6 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) free (layout->gpos_accels); hb_blob_destroy (layout->gdef_blob); - hb_blob_destroy (layout->gsub_blob); - hb_blob_destroy (layout->gpos_blob); layout->table.fini (); @@ -247,13 +242,13 @@ static inline const OT::GSUB& _get_gsub (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB); - return *hb_ot_layout_from_face (face)->gsub; + return *hb_ot_layout_from_face (face)->table.GSUB; } static inline const OT::GPOS& _get_gpos (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS); - return *hb_ot_layout_from_face (face)->gpos; + return *hb_ot_layout_from_face (face)->table.GPOS; } /* @@ -861,13 +856,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, { case HB_OT_TAG_GSUB: { - const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index); + const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index); l.collect_glyphs (&c); return; } case HB_OT_TAG_GPOS: { - const OT::PosLookup& l = hb_ot_layout_from_face (face)->gpos->get_lookup (lookup_index); + const OT::PosLookup& l = hb_ot_layout_from_face (face)->table.GPOS->get_lookup (lookup_index); l.collect_glyphs (&c); return; } @@ -943,7 +938,7 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face, if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false; OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context); - const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index); + const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index); return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index]); } @@ -1101,7 +1096,7 @@ struct GSUBProxy typedef OT::SubstLookup Lookup; GSUBProxy (hb_face_t *face) : - table (*hb_ot_layout_from_face (face)->gsub), + table (*hb_ot_layout_from_face (face)->table.GSUB), accels (hb_ot_layout_from_face (face)->gsub_accels) {} const OT::GSUB &table; @@ -1115,7 +1110,7 @@ struct GPOSProxy typedef OT::PosLookup Lookup; GPOSProxy (hb_face_t *face) : - table (*hb_ot_layout_from_face (face)->gpos), + table (*hb_ot_layout_from_face (face)->table.GPOS), accels (hb_ot_layout_from_face (face)->gpos_accels) {} const OT::GPOS &table; commit f73d2775cf649d148ace7c2593da9666d60fc1be Author: Behdad Esfahbod <[email protected]> Date: Fri Aug 3 16:34:25 2018 -0700 [ot] More shuffling Misc. table loading now properly automated. diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 8222a3fc..c09464bb 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -121,25 +121,6 @@ hb_ot_layout_position_finish_offsets (hb_font_t *font, * hb_ot_layout_t */ -namespace OT { - struct BASE; - struct COLR; - struct CPAL; - struct GDEF; - struct GSUB; - struct GPOS; - struct MATH; - struct fvar; - struct avar; -} - -namespace AAT { - struct ankr; - struct kerx; - struct morx; - struct trak; -} - struct hb_ot_layout_lookup_accelerator_t { template <typename TLookup> @@ -161,6 +142,32 @@ struct hb_ot_layout_lookup_accelerator_t hb_set_digest_t digest; }; +namespace OT { + struct BASE; + struct COLR; + struct CPAL; + struct GDEF; + struct GSUB; + struct GPOS; +} + +namespace AAT { + struct ankr; + struct kerx; + struct trak; +} + +#define HB_OT_LAYOUT_TABLES \ + HB_OT_LAYOUT_TABLE(OT, MATH) \ + HB_OT_LAYOUT_TABLE(OT, fvar) \ + HB_OT_LAYOUT_TABLE(OT, avar) \ + HB_OT_LAYOUT_TABLE(AAT, morx) \ + +/* Declare tables. */ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; } +HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + struct hb_ot_layout_t { hb_blob_t *gdef_blob; @@ -180,11 +187,25 @@ struct hb_ot_layout_t /* Various non-shaping tables. */ struct tables_t { + HB_INTERNAL void init0 (hb_face_t *face); + HB_INTERNAL void fini (void); + +#define HB_OT_LAYOUT_TABLE_ORDER(Namespace, Type) \ + HB_PASTE (TABLE_ORDER_, HB_PASTE (Namespace, HB_PASTE (_, Type))) + enum order_t + { + TABLE_ORDER_ZERO, +#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ + HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type), + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + }; + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ - hb_table_lazy_loader_t<1, struct OT::MATH> math; - hb_table_lazy_loader_t<2, struct OT::fvar> fvar; - hb_table_lazy_loader_t<3, struct OT::avar> avar; - hb_table_lazy_loader_t<4, struct AAT::morx> morx; +#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ + hb_table_lazy_loader_t<HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type), struct Namespace::Type> Type; + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE } table; }; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 6af64952..d0adaeb3 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -149,6 +149,20 @@ _hb_ot_blacklist_gdef (unsigned int gdef_len, return false; } +void hb_ot_layout_t::tables_t::init0 (hb_face_t *face) +{ + this->face = face; +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.init0 (); + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE +} +void hb_ot_layout_t::tables_t::fini (void) +{ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.fini (); + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE +} + hb_ot_layout_t * _hb_ot_layout_create (hb_face_t *face) { @@ -165,11 +179,7 @@ _hb_ot_layout_create (hb_face_t *face) layout->gpos_blob = hb_sanitize_context_t ().reference_table<OT::GPOS> (face); layout->gpos = layout->gpos_blob->as<OT::GPOS> (); - layout->table.face = face; - layout->table.math.init0 (); - layout->table.fvar.init0 (); - layout->table.avar.init0 (); - layout->table.morx.init0 (); + layout->table.init0 (face); if (_hb_ot_blacklist_gdef (layout->gdef_blob->length, layout->gsub_blob->length, @@ -214,10 +224,7 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) hb_blob_destroy (layout->gsub_blob); hb_blob_destroy (layout->gpos_blob); - layout->table.math.fini (); - layout->table.fvar.fini (); - layout->table.avar.fini (); - layout->table.morx.fini (); + layout->table.fini (); free (layout); } diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc index 3e4ab756..e7cb4652 100644 --- a/src/hb-ot-math.cc +++ b/src/hb-ot-math.cc @@ -34,7 +34,7 @@ _get_math (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->table.math.get ()); + return *(layout->table.MATH.get ()); } /* commit 52fbd23d868a989d51b7df5be40be582890d13e5 Author: Behdad Esfahbod <[email protected]> Date: Fri Aug 3 16:22:16 2018 -0700 [ot] Minor diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 3417033f..36d4037a 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -52,9 +52,9 @@ _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr) return Null(AAT::morx); } hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - const AAT::morx& morx = *(layout->morx.get ()); + const AAT::morx& morx = *(layout->table.morx.get ()); if (blob) - *blob = layout->morx.get_blob (); + *blob = layout->table.morx.get_blob (); return morx; } diff --git a/src/hb-face-private.hh b/src/hb-face-private.hh index fe3b8b24..73a68461 100644 --- a/src/hb-face-private.hh +++ b/src/hb-face-private.hh @@ -55,16 +55,13 @@ struct hb_face_t { struct hb_shaper_data_t shaper_data; /* Various shaper data. */ - /* Various non-shaping data. */ - /* ... */ - /* Cache */ - struct plan_node_t { + struct plan_node_t + { hb_shape_plan_t *shape_plan; plan_node_t *next; } *shape_plans; - inline hb_blob_t *reference_table (hb_tag_t tag) const { hb_blob_t *blob; diff --git a/src/hb-machinery-private.hh b/src/hb-machinery-private.hh index 40e42071..ec7a0da1 100644 --- a/src/hb-machinery-private.hh +++ b/src/hb-machinery-private.hh @@ -602,6 +602,7 @@ struct hb_base_lazy_loader_t inline const Subclass* thiz (void) const { return static_cast<const Subclass *> (this); } inline Subclass* thiz (void) { return static_cast<Subclass *> (this); } + inline void init0 (void) {} /* Init, when memory is already set to 0. No-op for us. */ inline void init (void) { instance = nullptr; diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 64c6e22f..8222a3fc 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -177,12 +177,15 @@ struct hb_ot_layout_t hb_ot_layout_lookup_accelerator_t *gsub_accels; hb_ot_layout_lookup_accelerator_t *gpos_accels; - /* TODO Move the following out of this struct. */ - hb_face_t *face; /* MUST be JUST before the lazy loaders. */ - hb_table_lazy_loader_t<1, struct OT::MATH> math; - hb_table_lazy_loader_t<2, struct OT::fvar> fvar; - hb_table_lazy_loader_t<3, struct OT::avar> avar; - hb_table_lazy_loader_t<4, struct AAT::morx> morx; + /* Various non-shaping tables. */ + struct tables_t + { + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ + hb_table_lazy_loader_t<1, struct OT::MATH> math; + hb_table_lazy_loader_t<2, struct OT::fvar> fvar; + hb_table_lazy_loader_t<3, struct OT::avar> avar; + hb_table_lazy_loader_t<4, struct AAT::morx> morx; + } table; }; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index c60b2750..6af64952 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -31,6 +31,7 @@ #include "hb-open-type-private.hh" #include "hb-ot-layout-private.hh" #include "hb-ot-map-private.hh" +#include "hb-map-private.hh" #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gsub-table.hh" @@ -44,7 +45,6 @@ #include "hb-ot-color-sbix-table.hh" #include "hb-ot-color-svg-table.hh" #include "hb-ot-name-table.hh" -#include "hb-map-private.hh" static bool @@ -165,11 +165,11 @@ _hb_ot_layout_create (hb_face_t *face) layout->gpos_blob = hb_sanitize_context_t ().reference_table<OT::GPOS> (face); layout->gpos = layout->gpos_blob->as<OT::GPOS> (); - layout->face = face; - layout->math.init (); - layout->fvar.init (); - layout->avar.init (); - layout->morx.init (); + layout->table.face = face; + layout->table.math.init0 (); + layout->table.fvar.init0 (); + layout->table.avar.init0 (); + layout->table.morx.init0 (); if (_hb_ot_blacklist_gdef (layout->gdef_blob->length, layout->gsub_blob->length, @@ -214,10 +214,10 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) hb_blob_destroy (layout->gsub_blob); hb_blob_destroy (layout->gpos_blob); - layout->math.fini (); - layout->fvar.fini (); - layout->avar.fini (); - layout->morx.fini (); + layout->table.math.fini (); + layout->table.fvar.fini (); + layout->table.avar.fini (); + layout->table.morx.fini (); free (layout); } diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc index 1667a7da..3e4ab756 100644 --- a/src/hb-ot-math.cc +++ b/src/hb-ot-math.cc @@ -34,7 +34,7 @@ _get_math (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->math.get ()); + return *(layout->table.math.get ()); } /* diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc index f0612a61..366860d5 100644 --- a/src/hb-ot-var.cc +++ b/src/hb-ot-var.cc @@ -41,14 +41,14 @@ _get_fvar (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::fvar); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->fvar.get ()); + return *(layout->table.fvar.get ()); } static inline const OT::avar& _get_avar (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::avar); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->avar.get ()); + return *(layout->table.avar.get ()); } /** commit 6a0a298aabe777e2c1ed443f100fe6142c83e3b3 Author: Behdad Esfahbod <[email protected]> Date: Thu Aug 2 23:13:19 2018 -0700 [ot] Move code around diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index db83481c..c60b2750 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -47,6 +47,108 @@ #include "hb-map-private.hh" +static bool +_hb_ot_blacklist_gdef (unsigned int gdef_len, + unsigned int gsub_len, + unsigned int gpos_len) +{ + /* The ugly business of blacklisting individual fonts' tables happen here! + * See this thread for why we finally had to bend in and do this: + * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html + * + * In certain versions of Times New Roman Italic and Bold Italic, + * ASCII double quotation mark U+0022 has wrong glyph class 3 (mark) + * in GDEF. Many versions of Tahoma have bad GDEF tables that + * incorrectly classify some spacing marks such as certain IPA + * symbols as glyph class 3. So do older versions of Microsoft + * Himalaya, and the version of Cantarell shipped by Ubuntu 16.04. + * + * Nuke the GDEF tables of to avoid unwanted width-zeroing. + * + * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 + * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 + * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 + */ +#define ENCODE(x,y,z) ((int64_t) (x) << 32 | (int64_t) (y) << 16 | (z)) + switch ENCODE(gdef_len, gsub_len, gpos_len) + { + /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */ + case ENCODE (442, 2874, 42038): + /* sha1sum:37fc8c16a0894ab7b749e35579856c73c840867b Windows 7? timesbi.ttf */ + case ENCODE (430, 2874, 40662): + /* sha1sum:19fc45110ea6cd3cdd0a5faca256a3797a069a80 Windows 7 timesi.ttf */ + case ENCODE (442, 2874, 39116): + /* sha1sum:6d2d3c9ed5b7de87bc84eae0df95ee5232ecde26 Windows 7 timesbi.ttf */ + case ENCODE (430, 2874, 39374): + /* sha1sum:8583225a8b49667c077b3525333f84af08c6bcd8 OS X 10.11.3 Times New Roman Italic.ttf */ + case ENCODE (490, 3046, 41638): + /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ + case ENCODE (478, 3046, 41902): + /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ + case ENCODE (898, 12554, 46470): + /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ + case ENCODE (910, 12566, 47732): + /* sha1sum:4f95b7e4878f60fa3a39ca269618dfde9721a79e tahoma.ttf from Windows 8.1 */ + case ENCODE (928, 23298, 59332): + /* sha1sum:6d400781948517c3c0441ba42acb309584b73033 tahomabd.ttf from Windows 8.1 */ + case ENCODE (940, 23310, 60732): + /* tahoma.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (964, 23836, 60072): + /* tahomabd.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (976, 23832, 61456): + /* sha1sum:e55fa2dfe957a9f7ec26be516a0e30b0c925f846 tahoma.ttf from Windows 10 */ + case ENCODE (994, 24474, 60336): + /* sha1sum:7199385abb4c2cc81c83a151a7599b6368e92343 tahomabd.ttf from Windows 10 */ + case ENCODE (1006, 24470, 61740): + /* tahoma.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (1006, 24576, 61346): + /* tahomabd.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (1018, 24572, 62828): + /* sha1sum:b9c84d820c49850d3d27ec498be93955b82772b5 tahoma.ttf from Windows 10 AU */ + case ENCODE (1006, 24576, 61352): + /* sha1sum:2bdfaab28174bdadd2f3d4200a30a7ae31db79d2 tahomabd.ttf from Windows 10 AU */ + case ENCODE (1018, 24572, 62834): + /* sha1sum:b0d36cf5a2fbe746a3dd277bffc6756a820807a7 Tahoma.ttf from Mac OS X 10.9 */ + case ENCODE (832, 7324, 47162): + /* sha1sum:12fc4538e84d461771b30c18b5eb6bd434e30fba Tahoma Bold.ttf from Mac OS X 10.9 */ + case ENCODE (844, 7302, 45474): + /* sha1sum:eb8afadd28e9cf963e886b23a30b44ab4fd83acc himalaya.ttf from Windows 7 */ + case ENCODE (180, 13054, 7254): + /* sha1sum:73da7f025b238a3f737aa1fde22577a6370f77b0 himalaya.ttf from Windows 8 */ + case ENCODE (192, 12638, 7254): + /* sha1sum:6e80fd1c0b059bbee49272401583160dc1e6a427 himalaya.ttf from Windows 8.1 */ + case ENCODE (192, 12690, 7254): + /* 8d9267aea9cd2c852ecfb9f12a6e834bfaeafe44 cantarell-fonts-0.0.21/otf/Cantarell-Regular.otf */ + /* 983988ff7b47439ab79aeaf9a45bd4a2c5b9d371 cantarell-fonts-0.0.21/otf/Cantarell-Oblique.otf */ + case ENCODE (188, 248, 3852): + /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ + /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ + case ENCODE (188, 264, 3426): + /* d125afa82a77a6475ac0e74e7c207914af84b37a padauk-2.80/Padauk.ttf RHEL 7.2 */ + case ENCODE (1058, 47032, 11818): + /* 0f7b80437227b90a577cc078c0216160ae61b031 padauk-2.80/Padauk-Bold.ttf RHEL 7.2*/ + case ENCODE (1046, 47030, 12600): + /* d3dde9aa0a6b7f8f6a89ef1002e9aaa11b882290 padauk-2.80/Padauk.ttf Ubuntu 16.04 */ + case ENCODE (1058, 71796, 16770): + /* 5f3c98ccccae8a953be2d122c1b3a77fd805093f padauk-2.80/Padauk-Bold.ttf Ubuntu 16.04 */ + case ENCODE (1046, 71790, 17862): + /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ + case ENCODE (1046, 71788, 17112): + /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ + case ENCODE (1058, 71794, 17514): + /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ + case ENCODE (1330, 109904, 57938): + /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ + case ENCODE (1330, 109904, 58972): + /* sha1sum: c26e41d567ed821bed997e937bc0c41435689e85 Padauk.ttf + * "Padauk Regular" "Version 2.5", see https://crbug.com/681813 */ + case ENCODE (1004, 59092, 14836): + return true; +#undef ENCODE + } + return false; +} + hb_ot_layout_t * _hb_ot_layout_create (hb_face_t *face) { @@ -69,111 +171,10 @@ _hb_ot_layout_create (hb_face_t *face) layout->avar.init (); layout->morx.init (); - { - /* The ugly business of blacklisting individual fonts' tables happen here! - * See this thread for why we finally had to bend in and do this: - * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html - * - * In certain versions of Times New Roman Italic and Bold Italic, - * ASCII double quotation mark U+0022 has wrong glyph class 3 (mark) - * in GDEF. Many versions of Tahoma have bad GDEF tables that - * incorrectly classify some spacing marks such as certain IPA - * symbols as glyph class 3. So do older versions of Microsoft - * Himalaya, and the version of Cantarell shipped by Ubuntu 16.04. - * - * Nuke the GDEF tables of to avoid unwanted width-zeroing. - * - * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 - * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 - * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 - */ - unsigned int gdef_len = layout->gdef_blob->length; - unsigned int gsub_len = layout->gsub_blob->length; - unsigned int gpos_len = layout->gpos_blob->length; -#define ENCODE(x,y,z) ((int64_t) (x) << 32 | (int64_t) (y) << 16 | (z)) - switch ENCODE(gdef_len, gsub_len, gpos_len) - { - /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */ - case ENCODE (442, 2874, 42038): - /* sha1sum:37fc8c16a0894ab7b749e35579856c73c840867b Windows 7? timesbi.ttf */ - case ENCODE (430, 2874, 40662): - /* sha1sum:19fc45110ea6cd3cdd0a5faca256a3797a069a80 Windows 7 timesi.ttf */ - case ENCODE (442, 2874, 39116): - /* sha1sum:6d2d3c9ed5b7de87bc84eae0df95ee5232ecde26 Windows 7 timesbi.ttf */ - case ENCODE (430, 2874, 39374): - /* sha1sum:8583225a8b49667c077b3525333f84af08c6bcd8 OS X 10.11.3 Times New Roman Italic.ttf */ - case ENCODE (490, 3046, 41638): - /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ - case ENCODE (478, 3046, 41902): - /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ - case ENCODE (898, 12554, 46470): - /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ - case ENCODE (910, 12566, 47732): - /* sha1sum:4f95b7e4878f60fa3a39ca269618dfde9721a79e tahoma.ttf from Windows 8.1 */ - case ENCODE (928, 23298, 59332): - /* sha1sum:6d400781948517c3c0441ba42acb309584b73033 tahomabd.ttf from Windows 8.1 */ - case ENCODE (940, 23310, 60732): - /* tahoma.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - case ENCODE (964, 23836, 60072): - /* tahomabd.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - case ENCODE (976, 23832, 61456): - /* sha1sum:e55fa2dfe957a9f7ec26be516a0e30b0c925f846 tahoma.ttf from Windows 10 */ - case ENCODE (994, 24474, 60336): - /* sha1sum:7199385abb4c2cc81c83a151a7599b6368e92343 tahomabd.ttf from Windows 10 */ - case ENCODE (1006, 24470, 61740): - /* tahoma.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - case ENCODE (1006, 24576, 61346): - /* tahomabd.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - case ENCODE (1018, 24572, 62828): - /* sha1sum:b9c84d820c49850d3d27ec498be93955b82772b5 tahoma.ttf from Windows 10 AU */ - case ENCODE (1006, 24576, 61352): - /* sha1sum:2bdfaab28174bdadd2f3d4200a30a7ae31db79d2 tahomabd.ttf from Windows 10 AU */ - case ENCODE (1018, 24572, 62834): - /* sha1sum:b0d36cf5a2fbe746a3dd277bffc6756a820807a7 Tahoma.ttf from Mac OS X 10.9 */ - case ENCODE (832, 7324, 47162): - /* sha1sum:12fc4538e84d461771b30c18b5eb6bd434e30fba Tahoma Bold.ttf from Mac OS X 10.9 */ - case ENCODE (844, 7302, 45474): - /* sha1sum:eb8afadd28e9cf963e886b23a30b44ab4fd83acc himalaya.ttf from Windows 7 */ - case ENCODE (180, 13054, 7254): - /* sha1sum:73da7f025b238a3f737aa1fde22577a6370f77b0 himalaya.ttf from Windows 8 */ - case ENCODE (192, 12638, 7254): - /* sha1sum:6e80fd1c0b059bbee49272401583160dc1e6a427 himalaya.ttf from Windows 8.1 */ - case ENCODE (192, 12690, 7254): - /* 8d9267aea9cd2c852ecfb9f12a6e834bfaeafe44 cantarell-fonts-0.0.21/otf/Cantarell-Regular.otf */ - /* 983988ff7b47439ab79aeaf9a45bd4a2c5b9d371 cantarell-fonts-0.0.21/otf/Cantarell-Oblique.otf */ - case ENCODE (188, 248, 3852): - /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ - /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ - case ENCODE (188, 264, 3426): - /* d125afa82a77a6475ac0e74e7c207914af84b37a padauk-2.80/Padauk.ttf RHEL 7.2 */ - case ENCODE (1058, 47032, 11818): - /* 0f7b80437227b90a577cc078c0216160ae61b031 padauk-2.80/Padauk-Bold.ttf RHEL 7.2*/ - case ENCODE (1046, 47030, 12600): - /* d3dde9aa0a6b7f8f6a89ef1002e9aaa11b882290 padauk-2.80/Padauk.ttf Ubuntu 16.04 */ - case ENCODE (1058, 71796, 16770): - /* 5f3c98ccccae8a953be2d122c1b3a77fd805093f padauk-2.80/Padauk-Bold.ttf Ubuntu 16.04 */ - case ENCODE (1046, 71790, 17862): - /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ - case ENCODE (1046, 71788, 17112): - /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ - case ENCODE (1058, 71794, 17514): - /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ - case ENCODE (1330, 109904, 57938): - /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ - case ENCODE (1330, 109904, 58972): - /* sha1sum: c26e41d567ed821bed997e937bc0c41435689e85 Padauk.ttf - * "Padauk Regular" "Version 2.5", see https://crbug.com/681813 */ - case ENCODE (1004, 59092, 14836): - { - layout->gdef = &Null(OT::GDEF); - break; - } -#undef ENCODE - - default: - break; - } - } + if (_hb_ot_blacklist_gdef (layout->gdef_blob->length, + layout->gsub_blob->length, + layout->gpos_blob->length)) + layout->gdef = &Null(OT::GDEF); layout->gsub_lookup_count = layout->gsub->get_lookup_count (); layout->gpos_lookup_count = layout->gpos->get_lookup_count (); commit 5e718a751efdda89511c9f30238b500125193499 Author: Behdad Esfahbod <[email protected]> Date: Thu Aug 2 23:04:42 2018 -0700 [ot] Use switch for checking for blacklisted GDEF tables Faster / more compact code. diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index a9436619..db83481c 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -70,97 +70,108 @@ _hb_ot_layout_create (hb_face_t *face) layout->morx.init (); { - /* - * The ugly business of blacklisting individual fonts' tables happen here! + /* The ugly business of blacklisting individual fonts' tables happen here! * See this thread for why we finally had to bend in and do this: * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html + * + * In certain versions of Times New Roman Italic and Bold Italic, + * ASCII double quotation mark U+0022 has wrong glyph class 3 (mark) + * in GDEF. Many versions of Tahoma have bad GDEF tables that + * incorrectly classify some spacing marks such as certain IPA + * symbols as glyph class 3. So do older versions of Microsoft + * Himalaya, and the version of Cantarell shipped by Ubuntu 16.04. + * + * Nuke the GDEF tables of to avoid unwanted width-zeroing. + * + * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 + * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 + * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 */ unsigned int gdef_len = layout->gdef_blob->length; unsigned int gsub_len = layout->gsub_blob->length; unsigned int gpos_len = layout->gpos_blob->length; - if (0 +#define ENCODE(x,y,z) ((int64_t) (x) << 32 | (int64_t) (y) << 16 | (z)) + switch ENCODE(gdef_len, gsub_len, gpos_len) + { /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */ - || (442 == gdef_len && 42038 == gpos_len && 2874 == gsub_len) + case ENCODE (442, 2874, 42038): /* sha1sum:37fc8c16a0894ab7b749e35579856c73c840867b Windows 7? timesbi.ttf */ - || (430 == gdef_len && 40662 == gpos_len && 2874 == gsub_len) + case ENCODE (430, 2874, 40662): /* sha1sum:19fc45110ea6cd3cdd0a5faca256a3797a069a80 Windows 7 timesi.ttf */ - || (442 == gdef_len && 39116 == gpos_len && 2874 == gsub_len) + case ENCODE (442, 2874, 39116): /* sha1sum:6d2d3c9ed5b7de87bc84eae0df95ee5232ecde26 Windows 7 timesbi.ttf */ - || (430 == gdef_len && 39374 == gpos_len && 2874 == gsub_len) + case ENCODE (430, 2874, 39374): /* sha1sum:8583225a8b49667c077b3525333f84af08c6bcd8 OS X 10.11.3 Times New Roman Italic.ttf */ - || (490 == gdef_len && 41638 == gpos_len && 3046 == gsub_len) + case ENCODE (490, 3046, 41638): /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ - || (478 == gdef_len && 41902 == gpos_len && 3046 == gsub_len) + case ENCODE (478, 3046, 41902): /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ - || (898 == gdef_len && 46470 == gpos_len && 12554 == gsub_len) + case ENCODE (898, 12554, 46470): /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ - || (910 == gdef_len && 47732 == gpos_len && 12566 == gsub_len) + case ENCODE (910, 12566, 47732): /* sha1sum:4f95b7e4878f60fa3a39ca269618dfde9721a79e tahoma.ttf from Windows 8.1 */ - || (928 == gdef_len && 59332 == gpos_len && 23298 == gsub_len) + case ENCODE (928, 23298, 59332): /* sha1sum:6d400781948517c3c0441ba42acb309584b73033 tahomabd.ttf from Windows 8.1 */ - || (940 == gdef_len && 60732 == gpos_len && 23310 == gsub_len) + case ENCODE (940, 23310, 60732): /* tahoma.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (964 == gdef_len && 60072 == gpos_len && 23836 == gsub_len) + case ENCODE (964, 23836, 60072): /* tahomabd.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (976 == gdef_len && 61456 == gpos_len && 23832 == gsub_len) + case ENCODE (976, 23832, 61456): /* sha1sum:e55fa2dfe957a9f7ec26be516a0e30b0c925f846 tahoma.ttf from Windows 10 */ - || (994 == gdef_len && 60336 == gpos_len && 24474 == gsub_len) + case ENCODE (994, 24474, 60336): /* sha1sum:7199385abb4c2cc81c83a151a7599b6368e92343 tahomabd.ttf from Windows 10 */ - || (1006 == gdef_len && 61740 == gpos_len && 24470 == gsub_len) + case ENCODE (1006, 24470, 61740): /* tahoma.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (1006 == gdef_len && 61346 == gpos_len && 24576 == gsub_len) + case ENCODE (1006, 24576, 61346): /* tahomabd.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (1018 == gdef_len && 62828 == gpos_len && 24572 == gsub_len) + case ENCODE (1018, 24572, 62828): /* sha1sum:b9c84d820c49850d3d27ec498be93955b82772b5 tahoma.ttf from Windows 10 AU */ - || (1006 == gdef_len && 61352 == gpos_len && 24576 == gsub_len) + case ENCODE (1006, 24576, 61352): /* sha1sum:2bdfaab28174bdadd2f3d4200a30a7ae31db79d2 tahomabd.ttf from Windows 10 AU */ - || (1018 == gdef_len && 62834 == gpos_len && 24572 == gsub_len) + case ENCODE (1018, 24572, 62834): /* sha1sum:b0d36cf5a2fbe746a3dd277bffc6756a820807a7 Tahoma.ttf from Mac OS X 10.9 */ - || (832 == gdef_len && 47162 == gpos_len && 7324 == gsub_len) + case ENCODE (832, 7324, 47162): /* sha1sum:12fc4538e84d461771b30c18b5eb6bd434e30fba Tahoma Bold.ttf from Mac OS X 10.9 */ - || (844 == gdef_len && 45474 == gpos_len && 7302 == gsub_len) + case ENCODE (844, 7302, 45474): /* sha1sum:eb8afadd28e9cf963e886b23a30b44ab4fd83acc himalaya.ttf from Windows 7 */ - || (180 == gdef_len && 7254 == gpos_len && 13054 == gsub_len) + case ENCODE (180, 13054, 7254): /* sha1sum:73da7f025b238a3f737aa1fde22577a6370f77b0 himalaya.ttf from Windows 8 */ - || (192 == gdef_len && 7254 == gpos_len && 12638 == gsub_len) + case ENCODE (192, 12638, 7254): /* sha1sum:6e80fd1c0b059bbee49272401583160dc1e6a427 himalaya.ttf from Windows 8.1 */ - || (192 == gdef_len && 7254 == gpos_len && 12690 == gsub_len) + case ENCODE (192, 12690, 7254): /* 8d9267aea9cd2c852ecfb9f12a6e834bfaeafe44 cantarell-fonts-0.0.21/otf/Cantarell-Regular.otf */ /* 983988ff7b47439ab79aeaf9a45bd4a2c5b9d371 cantarell-fonts-0.0.21/otf/Cantarell-Oblique.otf */ - || (188 == gdef_len && 3852 == gpos_len && 248 == gsub_len) + case ENCODE (188, 248, 3852): /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ - || (188 == gdef_len && 3426 == gpos_len && 264 == gsub_len) + case ENCODE (188, 264, 3426): /* d125afa82a77a6475ac0e74e7c207914af84b37a padauk-2.80/Padauk.ttf RHEL 7.2 */ - || (1058 == gdef_len && 11818 == gpos_len && 47032 == gsub_len) + case ENCODE (1058, 47032, 11818): /* 0f7b80437227b90a577cc078c0216160ae61b031 padauk-2.80/Padauk-Bold.ttf RHEL 7.2*/ - || (1046 == gdef_len && 12600 == gpos_len && 47030 == gsub_len) + case ENCODE (1046, 47030, 12600): /* d3dde9aa0a6b7f8f6a89ef1002e9aaa11b882290 padauk-2.80/Padauk.ttf Ubuntu 16.04 */ - || (1058 == gdef_len && 16770 == gpos_len && 71796 == gsub_len) + case ENCODE (1058, 71796, 16770): /* 5f3c98ccccae8a953be2d122c1b3a77fd805093f padauk-2.80/Padauk-Bold.ttf Ubuntu 16.04 */ - || (1046 == gdef_len && 17862 == gpos_len && 71790 == gsub_len) + case ENCODE (1046, 71790, 17862): /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ - || (1046 == gdef_len && 17112 == gpos_len && 71788 == gsub_len) + case ENCODE (1046, 71788, 17112): /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ - || (1058 == gdef_len && 17514 == gpos_len && 71794 == gsub_len) + case ENCODE (1058, 71794, 17514): /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ - || (1330 == gdef_len && 57938 == gpos_len && 109904 == gsub_len) + case ENCODE (1330, 109904, 57938): /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ - || (1330 == gdef_len && 58972 == gpos_len && 109904 == gsub_len) + case ENCODE (1330, 109904, 58972): /* sha1sum: c26e41d567ed821bed997e937bc0c41435689e85 Padauk.ttf * "Padauk Regular" "Version 2.5", see https://crbug.com/681813 */ - || (1004 == gdef_len && 14836 == gpos_len && 59092 == gsub_len) - ) - { - /* Many versions of Tahoma have bad GDEF tables that incorrectly classify some spacing marks - * such as certain IPA symbols as glyph class 3. So do older versions of Microsoft Himalaya, - * and the version of Cantarell shipped by Ubuntu 16.04. - * Nuke the GDEF tables of these fonts to avoid unwanted width-zeroing. - * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 - * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 - * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 - */ - layout->gdef = &Null(OT::GDEF); + case ENCODE (1004, 59092, 14836): + { + layout->gdef = &Null(OT::GDEF); + break; + } +#undef ENCODE + + default: + break; } } commit b5cdf5280d5b00df5356cc5c3236844ca0576bd0 Author: Behdad Esfahbod <[email protected]> Date: Thu Aug 2 22:56:42 2018 -0700 [ot] In GDEF blacklisting logic, remove the glyph index check for Times Just blacklist based on table sizes like we do for other fonts. diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 8a9eae45..a9436619 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -91,18 +91,6 @@ _hb_ot_layout_create (hb_face_t *face) || (490 == gdef_len && 41638 == gpos_len && 3046 == gsub_len) /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ || (478 == gdef_len && 41902 == gpos_len && 3046 == gsub_len) - ) - { - /* In certain versions of Times New Roman Italic and Bold Italic, - * ASCII double quotation mark U+0022, mapped to glyph 5, has wrong - * glyph class 3 (mark) in GDEF. Nuke the GDEF to avoid zero-width - * double-quote. See: - * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html - */ - if (3 == layout->gdef->get_glyph_class (5)) - layout->gdef = &Null(OT::GDEF); - } - else if (0 /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ || (898 == gdef_len && 46470 == gpos_len && 12554 == gsub_len) /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ commit c988b119994ef78d400bc7d3139785312da0be75 Author: Behdad Esfahbod <[email protected]> Date: Thu Aug 2 20:04:37 2018 -0700 Move code around diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 8b41d4e7..48934b1b 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -41,6 +41,30 @@ struct hb_ot_font_t { + inline void init (hb_face_t *face) + { + cmap.init (face); + h_metrics.init (face); + v_metrics.init (face, h_metrics.ascender - h_metrics.descender); /* TODO Can we do this lazily? */ + + this->face = face; + glyf.init (); + cbdt.init (); + post.init (); + kern.init (); + } + inline void fini (void) + { + cmap.fini (); + h_metrics.fini (); + v_metrics.fini (); + + glyf.fini (); + cbdt.fini (); + post.fini (); + kern.fini (); + } + OT::cmap::accelerator_t cmap; OT::hmtx::accelerator_t h_metrics; OT::vmtx::accelerator_t v_metrics; @@ -61,14 +85,7 @@ _hb_ot_font_create (hb_face_t *face) if (unlikely (!ot_font)) return nullptr; - ot_font->cmap.init (face); - ot_font->h_metrics.init (face); - ot_font->v_metrics.init (face, ot_font->h_metrics.ascender - ot_font->h_metrics.descender); /* TODO Can we do this lazily? */ - ot_font->face = face; - ot_font->glyf.init (); - ot_font->cbdt.init (); - ot_font->post.init (); - ot_font->kern.init (); + ot_font->init (face); return ot_font; } @@ -78,13 +95,7 @@ _hb_ot_font_destroy (void *data) { hb_ot_font_t *ot_font = (hb_ot_font_t *) data; - ot_font->cmap.fini (); - ot_font->h_metrics.fini (); - ot_font->v_metrics.fini (); - ot_font->glyf.fini (); - ot_font->cbdt.fini (); - ot_font->post.fini (); - ot_font->kern.fini (); + ot_font->fini (); free (ot_font); } commit 574b37e933f98e35c2bdae04458a95522bbfbb82 Author: Behdad Esfahbod <[email protected]> Date: Thu Aug 2 02:22:38 2018 -0700 Minor diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index d80d8c4c..8b41d4e7 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -45,7 +45,7 @@ struct hb_ot_font_t OT::hmtx::accelerator_t h_metrics; OT::vmtx::accelerator_t v_metrics; - hb_face_t *face; /* MUST be before the lazy loaders. */ + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ hb_lazy_loader_t<1, OT::glyf::accelerator_t> glyf; hb_lazy_loader_t<2, OT::CBDT::accelerator_t> cbdt; hb_lazy_loader_t<3, OT::post::accelerator_t> post; diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index c8855723..64c6e22f 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -178,7 +178,7 @@ struct hb_ot_layout_t hb_ot_layout_lookup_accelerator_t *gpos_accels; /* TODO Move the following out of this struct. */ - hb_face_t *face; /* MUST be before the lazy loaders. */ + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ hb_table_lazy_loader_t<1, struct OT::MATH> math; hb_table_lazy_loader_t<2, struct OT::fvar> fvar; hb_table_lazy_loader_t<3, struct OT::avar> avar; _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
