src/hb-aat-layout-common-private.hh | 5 src/hb-aat-layout-morx-table.hh | 86 ++++++++-- src/hb-aat-layout.cc | 20 +- src/hb-open-type-private.hh | 6 src/hb-set-private.hh | 1 test/shaping/data/text-rendering-tests/Makefile.sources | 2 test/shaping/data/text-rendering-tests/fonts/TestMORXFourteen.ttf |binary test/shaping/data/text-rendering-tests/fonts/TestMORXThirteen.ttf |binary test/shaping/data/text-rendering-tests/tests/MORX-13.tests | 1 test/shaping/data/text-rendering-tests/tests/MORX-14.tests | 1 10 files changed, 97 insertions(+), 25 deletions(-)
New commits: commit 12fffce10eb6ffebdedd655d0b1f10a99adf1808 Author: Behdad Esfahbod <[email protected]> Date: Mon Jan 15 15:41:51 2018 -0500 [aat] Sanitize classTable in StateTable diff --git a/src/hb-aat-layout-common-private.hh b/src/hb-aat-layout-common-private.hh index a67ee528..f912ed02 100644 --- a/src/hb-aat-layout-common-private.hh +++ b/src/hb-aat-layout-common-private.hh @@ -550,7 +550,8 @@ struct StateTable unsigned int *num_entries_out = nullptr) const { TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) return_trace (false); + if (unlikely (!(c->check_struct (this) && + classTable.sanitize (c, this)))) return_trace (false); const HBUINT16 *states = (this+stateArrayTable).arrayZ; const Entry<Extra> *entries = (this+entryTable).arrayZ; commit e6263c7142ca22efd9a3c93353a513f475c1c48d Author: Behdad Esfahbod <[email protected]> Date: Mon Jan 15 15:37:55 2018 -0500 [aat] Wire up table length to apply() diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index d2a66509..766292b3 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -448,13 +448,13 @@ struct ChainSubtable Insertion = 5 }; - inline void apply (hb_apply_context_t *c) const + inline void apply (hb_apply_context_t *c, const char *end) const { - dispatch (c); + dispatch (c, end); } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + inline typename context_t::return_t dispatch (context_t *c, const char *end) const { unsigned int subtable_type = get_type (); TRACE_DISPATCH (this, subtable_type); @@ -476,7 +476,7 @@ struct ChainSubtable !c->check_range (this, length)) return_trace (false); - return_trace (dispatch (c)); + return_trace (dispatch (c, c->end)); } protected: @@ -496,13 +496,13 @@ struct ChainSubtable struct Chain { - inline void apply (hb_apply_context_t *c) const + inline void apply (hb_apply_context_t *c, const char *end) const { const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount); unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { - subtable->apply (c); + subtable->apply (c, end); subtable = &StructAfter<ChainSubtable> (*subtable); } } @@ -555,13 +555,14 @@ struct morx { static const hb_tag_t tableTag = HB_AAT_TAG_MORX; - inline void apply (hb_apply_context_t *c) const + inline void apply (hb_apply_context_t *c, unsigned int length) const { + const char *end = (const char *) this + length; const Chain *chain = chains; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { - chain->apply (c); + chain->apply (c, end); chain = &StructAfter<Chain> (*chain); } } diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 79f0ae65..7455787f 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -37,11 +37,20 @@ */ static inline const AAT::morx& -_get_morx (hb_face_t *face) +_get_morx (hb_face_t *face, unsigned int *length = nullptr) { - if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(AAT::morx); + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) + { + if (length) + *length = 0; + return OT::Null(AAT::morx); + } hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->morx.get ()); /* XXX this doesn't call set_num_glyphs on sanitizer. */ + /* XXX this doesn't call set_num_glyphs on sanitizer. */ + const AAT::morx& morx = *(layout->morx.get ()); + if (length) + *length = hb_blob_get_length (layout->morx.blob); + return morx; } static inline void @@ -61,6 +70,7 @@ _hb_aat_layout_create (hb_face_t *face) void hb_aat_layout_substitute (OT::hb_apply_context_t *c) { - const AAT::morx& morx = _get_morx (c->face); - morx.apply (c); + unsigned int length; + const AAT::morx& morx = _get_morx (c->face, &length); + morx.apply (c, length); } diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 736497d9..04e4a4e1 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -1145,8 +1145,8 @@ struct hb_lazy_table_loader_t inline void init (hb_face_t *face_) { face = face_; - instance = nullptr; blob = nullptr; + instance = nullptr; } inline void fini (void) @@ -1177,10 +1177,10 @@ struct hb_lazy_table_loader_t return get(); } - private: hb_face_t *face; - T *instance; mutable hb_blob_t *blob; + private: + mutable T *instance; }; commit 679ae744d07db7746a983ece54c22635a9dc3cff Author: Behdad Esfahbod <[email protected]> Date: Sun Jan 14 15:03:31 2018 -0500 [aat] Towards implementing LigatureSubtable diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 64c946ec..d2a66509 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -288,19 +288,74 @@ struct ContextualSubtable struct LigatureSubtable { + struct EntryData + { + HBUINT16 ligActionIndex; /* Index to the first ligActionTable entry + * for processing this group, if indicated + * by the flags. */ + public: + DEFINE_SIZE_STATIC (2); + }; + + struct driver_context_t + { + static const bool in_place = false; + enum Flags { + SetComponent = 0x8000, /* Push this glyph onto the component stack for + * eventual processing. */ + DontAdvance = 0x4000, /* Leave the glyph pointer at this glyph for the + next iteration. */ + PerformAction = 0x2000, /* Use the ligActionIndex to process a ligature + * group. */ + Reserved = 0x1FFF, /* These bits are reserved and should be set to 0. */ + }; + + inline driver_context_t (const LigatureSubtable *table) : + ret (false) {} + + inline void transition (StateTableDriver<EntryData> *driver, + const Entry<EntryData> *entry) + { + hb_buffer_t *buffer = driver->buffer; + + /* TODO */ + } + + public: + bool ret; + private: + }; + inline bool apply (hb_apply_context_t *c) const { TRACE_APPLY (this); - /* TODO */ - return_trace (false); + + driver_context_t dc (this); + + StateTableDriver<EntryData> driver (machine, c->buffer, c->face); + driver.drive (&dc); + + return_trace (dc.ret); } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - /* TODO */ + /* The main sanitization is done at run-time. */ + return machine.sanitize (c); return_trace (true); } + + protected: + StateTable<EntryData> machine; + OffsetTo<UnsizedArrayOf<HBUINT32>, HBUINT32> + ligAction; /* Offset to the ligature action table. */ + OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT32> + component; /* Offset to the component table. */ + OffsetTo<UnsizedArrayOf<GlyphID>, HBUINT32> + ligature; /* Offset to the actual ligature lists. */ + public: + DEFINE_SIZE_STATIC (28); }; struct NoncontextualSubtable commit c9e12a2b9b34d73d37def2261a5c1a7ef20b8349 Author: Behdad Esfahbod <[email protected]> Date: Sat Jan 13 17:05:12 2018 +0000 Fix set initializer diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index 9c6f3ee3..576c169e 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -185,6 +185,7 @@ struct hb_set_t inline void init (void) { + in_error = false; page_map.init (); pages.init (); } commit 54a1e250a839f030b43dbeba66cadc50ab5f90f6 Author: Behdad Esfahbod <[email protected]> Date: Sat Jan 13 14:44:39 2018 +0000 [test/text-rendering-tests] Update from upstream diff --git a/test/shaping/data/text-rendering-tests/Makefile.sources b/test/shaping/data/text-rendering-tests/Makefile.sources index 3e834243..81b37896 100644 --- a/test/shaping/data/text-rendering-tests/Makefile.sources +++ b/test/shaping/data/text-rendering-tests/Makefile.sources @@ -28,6 +28,8 @@ TESTS = \ tests/HVAR-2.tests \ tests/KERN-1.tests \ tests/KERN-2.tests \ + tests/MORX-13.tests \ + tests/MORX-14.tests \ tests/SHBALI-3.tests \ tests/SHKNDA-1.tests \ $(NULL) diff --git a/test/shaping/data/text-rendering-tests/fonts/TestMORXFourteen.ttf b/test/shaping/data/text-rendering-tests/fonts/TestMORXFourteen.ttf new file mode 100644 index 00000000..31c30c04 Binary files /dev/null and b/test/shaping/data/text-rendering-tests/fonts/TestMORXFourteen.ttf differ diff --git a/test/shaping/data/text-rendering-tests/fonts/TestMORXThirteen.ttf b/test/shaping/data/text-rendering-tests/fonts/TestMORXThirteen.ttf new file mode 100644 index 00000000..f3c6f0f7 Binary files /dev/null and b/test/shaping/data/text-rendering-tests/fonts/TestMORXThirteen.ttf differ diff --git a/test/shaping/data/text-rendering-tests/tests/MORX-13.tests b/test/shaping/data/text-rendering-tests/tests/MORX-13.tests new file mode 100644 index 00000000..42d81073 --- /dev/null +++ b/test/shaping/data/text-rendering-tests/tests/MORX-13.tests @@ -0,0 +1 @@ +../fonts/TestMORXThirteen.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0041,U+0042,U+0043,U+0044,U+0045:[B|C@626,0|D@1222,0|E@1896,0|A@2452,0] diff --git a/test/shaping/data/text-rendering-tests/tests/MORX-14.tests b/test/shaping/data/text-rendering-tests/tests/MORX-14.tests new file mode 100644 index 00000000..bff742f3 --- /dev/null +++ b/test/shaping/data/text-rendering-tests/tests/MORX-14.tests @@ -0,0 +1 @@ +../fonts/TestMORXFourteen.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0041,U+0042,U+0043,U+0044,U+0045:[B|C@626,0|D@1222,0|E@1896,0|A@2452,0] commit 9009b341c46caaa81deae8ea55e6f7dd98565f59 Author: Behdad Esfahbod <[email protected]> Date: Fri Jan 12 12:04:53 2018 +0100 [aat] Fix some struct sizes I hate it that with my compiler at least, it doesn't catch totally uncompilable statements in templates if they are not used... diff --git a/src/hb-aat-layout-common-private.hh b/src/hb-aat-layout-common-private.hh index 990be2e7..a67ee528 100644 --- a/src/hb-aat-layout-common-private.hh +++ b/src/hb-aat-layout-common-private.hh @@ -602,7 +602,7 @@ struct StateTable entryTable; /* Offset to the entry array. */ public: - DEFINE_SIZE_UNION (2, format); + DEFINE_SIZE_STATIC (16); }; template <typename EntryData> diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index f0715894..64c946ec 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -169,7 +169,7 @@ struct RearrangementSubtable protected: StateTable<void> machine; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_STATIC (16); }; struct ContextualSubtable @@ -283,7 +283,7 @@ struct ContextualSubtable OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32>, HBUINT32> substitutionTables; public: - DEFINE_SIZE_MIN (2); + DEFINE_SIZE_STATIC (20); }; struct LigatureSubtable @@ -436,7 +436,7 @@ struct ChainSubtable InsertionSubtable insertion; } u; public: - DEFINE_SIZE_MIN (2 * sizeof (HBUINT32) + 4); + DEFINE_SIZE_MIN (12); }; struct Chain @@ -488,7 +488,7 @@ struct Chain // subtableGlyphCoverageArray if major == 3 public: - DEFINE_SIZE_MIN (8 + 2 * sizeof (HBUINT32)); + DEFINE_SIZE_MIN (16); }; _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
