src/hb-aat-layout-morx-table.hh | 64 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)
New commits: commit dc8ed45292ce4e522c3bda03fd83873da7b6591e Author: Behdad Esfahbod <beh...@behdad.org> Date: Wed Sep 19 16:46:41 2018 -0400 [morx] Implement forward/backward processing We reverse too many times. Can be optimized. But I doubt many fonts use reverse lookups, so doesn't matter. Other than not applying user features, this completes morx table implementation. diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 03bb4d53..0a2d62b5 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -836,6 +836,8 @@ struct Chain unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { + bool reverse; + if (!(subtable->subFeatureFlags & flags)) goto skip; @@ -844,11 +846,49 @@ struct Chain bool (subtable->coverage & ChainSubtable::Vertical)) goto skip; + /* Buffer contents is always in logical direction. Determine if + * we need to reverse before applying this subtable. We reverse + * back after if we did reverse indeed. + * + * Quoting the spac: + * """ + * Bits 28 and 30 of the coverage field control the order in which + * glyphs are processed when the subtable is run by the layout engine. + * Bit 28 is used to indicate if the glyph processing direction is + * the same as logical order or layout order. Bit 30 is used to + * indicate whether glyphs are processed forwards or backwards within + * that order. + + Bit 30 Bit 28 Interpretation for Horizontal Text + 0 0 The subtable is processed in layout order + (the same order as the glyphs, which is + always left-to-right). + 1 0 The subtable is processed in reverse layout order + (the order opposite that of the glyphs, which is + always right-to-left). + 0 1 The subtable is processed in logical order + (the same order as the characters, which may be + left-to-right or right-to-left). + 1 1 The subtable is processed in reverse logical order + (the order opposite that of the characters, which + may be right-to-left or left-to-right). + */ + reverse = subtable->coverage & ChainSubtable::Logical ? + bool (subtable->coverage & ChainSubtable::Descending) : + bool (subtable->coverage & ChainSubtable::Descending) != + HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction); + if (!c->buffer->message (c->font, "start chain subtable %d", c->lookup_index)) goto skip; + if (reverse) + c->buffer->reverse (); + subtable->dispatch (c); + if (reverse) + c->buffer->reverse (); + (void) c->buffer->message (c->font, "end chain subtable %d", c->lookup_index); skip: commit 3bccd62196b5dff70d446c3fe053b1b47bb9c19e Author: Behdad Esfahbod <beh...@behdad.org> Date: Wed Sep 19 16:24:34 2018 -0400 [morx] Implement horiz-only/vert-only subtables diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 03f31024..03bb4d53 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -743,8 +743,25 @@ struct ChainSubtable friend struct Chain; inline unsigned int get_size (void) const { return length; } - inline unsigned int get_type (void) const { return coverage & 0xFF; } + inline unsigned int get_type (void) const { return coverage & SubtableType; } + enum Coverage + { + Vertical = 0x80000000, /* If set, this subtable will only be applied + * to vertical text. If clear, this subtable + * will only be applied to horizontal text. */ + Descending = 0x40000000, /* If set, this subtable will process glyphs + * in descending order. If clear, it will + * process the glyphs in ascending order. */ + AllDirections = 0x20000000, /* If set, this subtable will be applied to + * both horizontal and vertical text (i.e. + * the state of bit 0x80000000 is ignored). */ + Logical = 0x10000000, /* If set, this subtable will process glyphs + * in logical order (or reverse logical order, + * depending on the value of bit 0x80000000). */ + Reserved = 0x0FFFFF00, /* Reserved, set to zero. */ + SubtableType = 0x000000FF, /* Subtable type; see following table. */ + }; enum Type { Rearrangement = 0, @@ -822,6 +839,11 @@ struct Chain if (!(subtable->subFeatureFlags & flags)) goto skip; + if (!(subtable->coverage & ChainSubtable::AllDirections) && + HB_DIRECTION_IS_VERTICAL (c->buffer->props.direction) != + bool (subtable->coverage & ChainSubtable::Vertical)) + goto skip; + if (!c->buffer->message (c->font, "start chain subtable %d", c->lookup_index)) goto skip; _______________________________________________ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz