[>64k:layout] Templatize LigatureSubst
This commit is contained in:
parent
27d24212db
commit
704e696ad0
|
@ -7,16 +7,18 @@ namespace OT {
|
||||||
namespace Layout {
|
namespace Layout {
|
||||||
namespace GSUB_impl {
|
namespace GSUB_impl {
|
||||||
|
|
||||||
|
template <typename Types>
|
||||||
struct Ligature
|
struct Ligature
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
HBGlyphID16 ligGlyph; /* GlyphID of ligature to substitute */
|
typename Types::HBGlyphID
|
||||||
HeadlessArrayOf<HBGlyphID16>
|
ligGlyph; /* GlyphID of ligature to substitute */
|
||||||
|
HeadlessArrayOf<typename Types::HBGlyphID>
|
||||||
component; /* Array of component GlyphIDs--start
|
component; /* Array of component GlyphIDs--start
|
||||||
* with the second component--ordered
|
* with the second component--ordered
|
||||||
* in writing direction */
|
* in writing direction */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (4, component);
|
DEFINE_SIZE_ARRAY (Types::size + 2, component);
|
||||||
|
|
||||||
bool sanitize (hb_sanitize_context_t *c) const
|
bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,10 +8,11 @@ namespace OT {
|
||||||
namespace Layout {
|
namespace Layout {
|
||||||
namespace GSUB_impl {
|
namespace GSUB_impl {
|
||||||
|
|
||||||
|
template <typename Types>
|
||||||
struct LigatureSet
|
struct LigatureSet
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Array16OfOffset16To<Ligature>
|
Array16OfOffset16To<Ligature<Types>>
|
||||||
ligature; /* Array LigatureSet tables
|
ligature; /* Array LigatureSet tables
|
||||||
* ordered by preference */
|
* ordered by preference */
|
||||||
public:
|
public:
|
||||||
|
@ -28,7 +29,7 @@ struct LigatureSet
|
||||||
return
|
return
|
||||||
+ hb_iter (ligature)
|
+ hb_iter (ligature)
|
||||||
| hb_map (hb_add (this))
|
| hb_map (hb_add (this))
|
||||||
| hb_map ([glyphs] (const Ligature &_) { return _.intersects (glyphs); })
|
| hb_map ([glyphs] (const Ligature<Types> &_) { return _.intersects (glyphs); })
|
||||||
| hb_any
|
| hb_any
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,7 @@ struct LigatureSet
|
||||||
{
|
{
|
||||||
+ hb_iter (ligature)
|
+ hb_iter (ligature)
|
||||||
| hb_map (hb_add (this))
|
| hb_map (hb_add (this))
|
||||||
| hb_apply ([c] (const Ligature &_) { _.closure (c); })
|
| hb_apply ([c] (const Ligature<Types> &_) { _.closure (c); })
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ struct LigatureSet
|
||||||
{
|
{
|
||||||
+ hb_iter (ligature)
|
+ hb_iter (ligature)
|
||||||
| hb_map (hb_add (this))
|
| hb_map (hb_add (this))
|
||||||
| hb_apply ([c] (const Ligature &_) { _.collect_glyphs (c); })
|
| hb_apply ([c] (const Ligature<Types> &_) { _.collect_glyphs (c); })
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ struct LigatureSet
|
||||||
return
|
return
|
||||||
+ hb_iter (ligature)
|
+ hb_iter (ligature)
|
||||||
| hb_map (hb_add (this))
|
| hb_map (hb_add (this))
|
||||||
| hb_map ([c] (const Ligature &_) { return _.would_apply (c); })
|
| hb_map ([c] (const Ligature<Types> &_) { return _.would_apply (c); })
|
||||||
| hb_any
|
| hb_any
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +66,7 @@ struct LigatureSet
|
||||||
unsigned int num_ligs = ligature.len;
|
unsigned int num_ligs = ligature.len;
|
||||||
for (unsigned int i = 0; i < num_ligs; i++)
|
for (unsigned int i = 0; i < num_ligs; i++)
|
||||||
{
|
{
|
||||||
const Ligature &lig = this+ligature[i];
|
const auto &lig = this+ligature[i];
|
||||||
if (lig.apply (c)) return_trace (true);
|
if (lig.apply (c)) return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct LigatureSubst
|
||||||
protected:
|
protected:
|
||||||
union {
|
union {
|
||||||
HBUINT16 format; /* Format identifier */
|
HBUINT16 format; /* Format identifier */
|
||||||
LigatureSubstFormat1 format1;
|
LigatureSubstFormat1_2<SmallTypes> format1;
|
||||||
} u;
|
} u;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -8,18 +8,19 @@ namespace OT {
|
||||||
namespace Layout {
|
namespace Layout {
|
||||||
namespace GSUB_impl {
|
namespace GSUB_impl {
|
||||||
|
|
||||||
struct LigatureSubstFormat1
|
template <typename Types>
|
||||||
|
struct LigatureSubstFormat1_2
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
HBUINT16 format; /* Format identifier--format = 1 */
|
HBUINT16 format; /* Format identifier--format = 1 */
|
||||||
Offset16To<Coverage>
|
typename Types::template OffsetTo<Coverage>
|
||||||
coverage; /* Offset to Coverage table--from
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of Substitution table */
|
* beginning of Substitution table */
|
||||||
Array16OfOffset16To<LigatureSet>
|
Array16Of<typename Types::template OffsetTo<LigatureSet<Types>>>
|
||||||
ligatureSet; /* Array LigatureSet tables
|
ligatureSet; /* Array LigatureSet tables
|
||||||
* ordered by Coverage Index */
|
* ordered by Coverage Index */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (6, ligatureSet);
|
DEFINE_SIZE_ARRAY (4 + Types::size, ligatureSet);
|
||||||
|
|
||||||
bool sanitize (hb_sanitize_context_t *c) const
|
bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
|
@ -33,7 +34,7 @@ struct LigatureSubstFormat1
|
||||||
+ hb_zip (this+coverage, ligatureSet)
|
+ hb_zip (this+coverage, ligatureSet)
|
||||||
| hb_filter (*glyphs, hb_first)
|
| hb_filter (*glyphs, hb_first)
|
||||||
| hb_map (hb_second)
|
| hb_map (hb_second)
|
||||||
| hb_map ([this, glyphs] (const Offset16To<LigatureSet> &_)
|
| hb_map ([this, glyphs] (const typename Types::template OffsetTo<LigatureSet<Types>> &_)
|
||||||
{ return (this+_).intersects (glyphs); })
|
{ return (this+_).intersects (glyphs); })
|
||||||
| hb_any
|
| hb_any
|
||||||
;
|
;
|
||||||
|
@ -48,7 +49,7 @@ struct LigatureSubstFormat1
|
||||||
| hb_filter (c->parent_active_glyphs (), hb_first)
|
| hb_filter (c->parent_active_glyphs (), hb_first)
|
||||||
| hb_map (hb_second)
|
| hb_map (hb_second)
|
||||||
| hb_map (hb_add (this))
|
| hb_map (hb_add (this))
|
||||||
| hb_apply ([c] (const LigatureSet &_) { _.closure (c); })
|
| hb_apply ([c] (const LigatureSet<Types> &_) { _.closure (c); })
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +63,7 @@ struct LigatureSubstFormat1
|
||||||
+ hb_zip (this+coverage, ligatureSet)
|
+ hb_zip (this+coverage, ligatureSet)
|
||||||
| hb_map (hb_second)
|
| hb_map (hb_second)
|
||||||
| hb_map (hb_add (this))
|
| hb_map (hb_add (this))
|
||||||
| hb_apply ([c] (const LigatureSet &_) { _.collect_glyphs (c); })
|
| hb_apply ([c] (const LigatureSet<Types> &_) { _.collect_glyphs (c); })
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ struct LigatureSubstFormat1
|
||||||
unsigned int index = (this+coverage).get_coverage (c->glyphs[0]);
|
unsigned int index = (this+coverage).get_coverage (c->glyphs[0]);
|
||||||
if (likely (index == NOT_COVERED)) return false;
|
if (likely (index == NOT_COVERED)) return false;
|
||||||
|
|
||||||
const LigatureSet &lig_set = this+ligatureSet[index];
|
const auto &lig_set = this+ligatureSet[index];
|
||||||
return lig_set.would_apply (c);
|
return lig_set.would_apply (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ struct LigatureSubstFormat1
|
||||||
unsigned int index = (this+coverage).get_coverage (c->buffer->cur ().codepoint);
|
unsigned int index = (this+coverage).get_coverage (c->buffer->cur ().codepoint);
|
||||||
if (likely (index == NOT_COVERED)) return_trace (false);
|
if (likely (index == NOT_COVERED)) return_trace (false);
|
||||||
|
|
||||||
const LigatureSet &lig_set = this+ligatureSet[index];
|
const auto &lig_set = this+ligatureSet[index];
|
||||||
return_trace (lig_set.apply (c));
|
return_trace (lig_set.apply (c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ struct LigatureSubstFormat1
|
||||||
hb_set_t new_coverage;
|
hb_set_t new_coverage;
|
||||||
+ hb_zip (this+coverage, hb_iter (ligatureSet) | hb_map (hb_add (this)))
|
+ hb_zip (this+coverage, hb_iter (ligatureSet) | hb_map (hb_add (this)))
|
||||||
| hb_filter (glyphset, hb_first)
|
| hb_filter (glyphset, hb_first)
|
||||||
| hb_filter ([&] (const LigatureSet& _) {
|
| hb_filter ([&] (const LigatureSet<Types>& _) {
|
||||||
return _.intersects (&glyphset);
|
return _.intersects (&glyphset);
|
||||||
}, hb_second)
|
}, hb_second)
|
||||||
| hb_map (hb_first)
|
| hb_map (hb_first)
|
||||||
|
|
Loading…
Reference in New Issue