diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 7784fae3331e89f2a3557b8d06d52a09358d4814..df6c38c4d8c50f34a316cc15b85d6991af1756ed 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -41,43 +41,9 @@ #include "hb-aat-ltag-table.hh" // Just so we compile it; unused otherwise. /* - * morx/kerx/trak + * morx/kerx/trak/ankr */ -#if 0 -static inline const AAT::ankr& -_get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr) -{ - if (unlikely (!hb_ot_shaper_face_data_ensure (face))) - { - if (blob) - *blob = hb_blob_get_empty (); - return Null(AAT::ankr); - } - hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - const AAT::ankr& ankr = *(layout->ankr.get ()); - if (blob) - *blob = layout->ankr.blob; - return ankr; -} - -static inline const AAT::kerx& -_get_kerx (hb_face_t *face, hb_blob_t **blob = nullptr) -{ - if (unlikely (!hb_ot_shaper_face_data_ensure (face))) - { - if (blob) - *blob = hb_blob_get_empty (); - return Null(AAT::kerx); - } - hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - /* XXX this doesn't call set_num_glyphs on sanitizer. */ - const AAT::kerx& kerx = *(layout->kerx.get ()); - if (blob) - *blob = layout->kerx.blob; - return kerx; -} - static inline const AAT::morx& _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr) { @@ -88,30 +54,12 @@ _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); - /* XXX this doesn't call set_num_glyphs on sanitizer. */ const AAT::morx& morx = *(layout->morx.get ()); if (blob) - *blob = layout->morx.blob; + *blob = layout->morx.get_blob (); return morx; } -static inline const AAT::trak& -_get_trak (hb_face_t *face, hb_blob_t **blob = nullptr) -{ - if (unlikely (!hb_ot_shaper_face_data_ensure (face))) - { - if (blob) - *blob = hb_blob_get_empty (); - return Null(AAT::trak); - } - hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - const AAT::trak& trak = *(layout->trak.get ()); - if (blob) - *blob = layout->trak.blob; - return trak; -} -#endif - // static inline void // _hb_aat_layout_create (hb_face_t *face) // { @@ -129,13 +77,11 @@ _get_trak (hb_face_t *face, hb_blob_t **blob = nullptr) void hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer) { -#if 0 hb_blob_t *blob; const AAT::morx& morx = _get_morx (font->face, &blob); AAT::hb_aat_apply_context_t c (font, buffer, blob); morx.apply (&c); -#endif } void diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index f6113c33aaf922cec030fff264e2e977e4667f48..f681c573f59267ca9e3411dcf7128e7bedb43ec6 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -290,9 +290,10 @@ struct hb_sanitize_context_t : template struct Sanitizer { - inline Sanitizer (void) {} + inline Sanitizer (unsigned int num_glyphs = 0) { c->num_glyphs = num_glyphs; } - inline hb_blob_t *sanitize (hb_blob_t *blob) { + inline hb_blob_t *sanitize (hb_blob_t *blob) + { bool sane; /* TODO is_sane() stuff */ @@ -1265,21 +1266,27 @@ struct hb_table_lazy_loader_t hb_blob_destroy (blob); } - inline const T* get (void) const + inline hb_blob_t* get_blob (void) const { retry: - hb_blob_t *blob_ = (hb_blob_t *) hb_atomic_ptr_get (&blob); - if (unlikely (!blob_)) + hb_blob_t *b = (hb_blob_t *) hb_atomic_ptr_get (&blob); + if (unlikely (!b)) { - blob_ = OT::Sanitizer().sanitize (face->reference_table (T::tableTag)); - if (!hb_atomic_ptr_cmpexch (&blob, nullptr, blob_)) + b = OT::Sanitizer(face->get_num_glyphs ()).sanitize (face->reference_table (T::tableTag)); + if (!hb_atomic_ptr_cmpexch (&blob, nullptr, b)) { - hb_blob_destroy (blob_); + hb_blob_destroy (b); goto retry; } - blob = blob_; + blob = b; } - return blob_->as (); + return b; + } + + inline const T* get (void) const + { + hb_blob_t *b = get_blob (); + return b->as (); } inline const T* operator-> (void) const diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index b2f974b82e89a54e7bec91dd3fa5f0ab0dd881b2..6fe673e911860d0825ac84dcc9ccc81310a55fa0 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -176,6 +176,7 @@ struct hb_ot_layout_t OT::hb_table_lazy_loader_t math; OT::hb_table_lazy_loader_t fvar; OT::hb_table_lazy_loader_t avar; + OT::hb_table_lazy_loader_t morx; 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 655c36c1c28318c588d881b1d0a8cd7d15b1ef66..3a08230732960bb40162d9a0bb7506dc3978ae7c 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -66,6 +66,7 @@ _hb_ot_layout_create (hb_face_t *face) layout->math.init (face); layout->fvar.init (face); layout->avar.init (face); + layout->morx.init (face); { /* @@ -215,6 +216,7 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) layout->math.fini (); layout->fvar.fini (); layout->avar.fini (); + layout->morx.fini (); free (layout); } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 1189b2075b21cb0df9fec644e62a4f6f22cd9a7a..6696ad885b2de805276127aed0d0b09b89342e54 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -41,7 +41,7 @@ #include "hb-set-private.hh" #include "hb-ot-layout-gsubgpos-private.hh" -//#include "hb-aat-layout-private.hh" +#include "hb-aat-layout-private.hh" static hb_tag_t common_features[] = { HB_TAG('c','c','m','p'), @@ -623,8 +623,8 @@ hb_ot_substitute_complex (hb_ot_shape_context_t *c) c->plan->substitute (c->font, buffer); - /* XXX Call morx instead. */ - //hb_aat_layout_substitute (c->font, c->buffer); + if (0) /* XXX Call morx instead. */ + hb_aat_layout_substitute (c->font, c->buffer); } static inline void