Class OpenTypeLayout
What a face's OpenType layout tables (GSUB and GPOS) offer: the scripts, language systems and features they list, and the glyphs GSUB can produce from a set of glyphs. A table whose structure is damaged is left out whole, as the shaper leaves it out.
public sealed class OpenTypeLayout
- Inheritance
-
OpenTypeLayout
- Inherited Members
Examples
// What the font's layout tables list.
OpenTypeLayout layout = face.Layout;
IReadOnlyList<FontTag> scripts = layout.Scripts; // DFLT, cyrl, grek, latn
IReadOnlyList<FontTag> languages = layout.GetLanguageSystems(new FontTag("latn"));
IReadOnlyList<FontTag> features = layout.GetFeatures(new FontTag("latn")); // liga, kern, ...
Properties
DefaultClosureFeatures
Gets the layout features hb-subset keeps by default, which GetClosure(IEnumerable<ushort>, IEnumerable<FontTag>?) follows when no features are given: the
common ones (such as ccmp, liga, locl, calt and kern), fractions, vertical forms,
East Asian spacing, and those the Arabic, Hangul, Tibetan and Indic shapers apply; not discretionary ones such as
smcp, dlig or ss01.
public static IReadOnlyList<FontTag> DefaultClosureFeatures { get; }
Property Value
Features
Gets every feature tag GSUB and GPOS list, in tag order.
public IReadOnlyList<FontTag> Features { get; }
Property Value
HasGlyphClasses
Gets whether the face has a usable GDEF table with glyph classes.
public bool HasGlyphClasses { get; }
Property Value
HasGpos
Gets whether the face has a usable GPOS table (positioning such as kerning and mark placement).
public bool HasGpos { get; }
Property Value
HasGsub
Gets whether the face has a usable GSUB table (substitutions such as ligatures and contextual forms).
public bool HasGsub { get; }
Property Value
Scripts
Gets the script tags GSUB and GPOS list, such as latn, arab or DFLT, in tag order.
public IReadOnlyList<FontTag> Scripts { get; }
Property Value
Methods
GetClosure(IEnumerable<ushort>, IEnumerable<FontTag>?)
Gets the glyphs the face's GSUB substitutions can produce from glyphs: the glyphs themselves and every
glyph a lookup of the given features (in any script and language system, with the lookups their contextual rules call
and their feature variations) can substitute for them, repeated until nothing is added. This is the layout closure
hb-subset computes, so a subset that keeps these glyphs can be shaped again as the full face would be.
public IReadOnlySet<ushort> GetClosure(IEnumerable<ushort> glyphs, IEnumerable<FontTag>? features = null)
Parameters
glyphsIEnumerable<ushort>The glyph ids to start from, such as those of the characters a page uses; ids the face does not have are ignored.
featuresIEnumerable<FontTag>The feature tags whose lookups are followed, or null for DefaultClosureFeatures; pass Features to follow every feature and an empty list to follow none.
Returns
- IReadOnlySet<ushort>
The glyph ids, ascending when enumerated.
Examples
// The glyphs a web font subset needs so that it shapes "office" as the full font does: the characters' glyphs and every
// glyph GSUB can turn them into (the "ffi" ligature, for one).
ushort[] used = [0, .. "office".Select(c => face.GetGlyph(c))];
IReadOnlySet<ushort> keep = face.Layout.GetClosure(used); // hb-subset's default features
IReadOnlySet<ushort> all = face.Layout.GetClosure(used, face.Layout.Features); // every feature, small caps too
GetFeatures(FontTag, FontTag?)
Gets the feature tags a language system lists, including its required feature, in tag order.
public IReadOnlyList<FontTag> GetFeatures(FontTag script, FontTag? language = null)
Parameters
scriptFontTagThe script tag.
languageFontTag?The language system tag, or null for the script's default system.
Returns
- IReadOnlyList<FontTag>
The tags; empty when no table lists the script.
GetLanguageSystems(FontTag)
Gets the language system tags a script lists, such as URD or SRB; the default system is not listed.
public IReadOnlyList<FontTag> GetLanguageSystems(FontTag script)
Parameters
scriptFontTagThe script tag.
Returns
- IReadOnlyList<FontTag>
The tags, in tag order; empty when no table lists the script.