LayoutQueries Class

Answers questions about the layout tables of a font without shaping a text: whether it has a feature, what a feature does to a glyph or to a pair of glyphs. The lookups are those of the default language system of a script.

public static class LayoutQueries

Remarks

Each call reads the tables: a caller that asks often keeps the answers.

Methods

NameDescription
GetPairAdjustment(FontFace, uint, int, int, uint)Gets the adjustments the lookups of a feature of the GPOS table make to two consecutive glyphs, in font units, from positions that are all 0: the advances and the offsets of the two glyphs, the y axis up. For the kern feature, a font without the feature in its GPOS table has the pairs of its legacy kerning table, added to the advance of the first glyph.
GetSingleSubstitution(FontFace, uint, int, uint)Gets the glyph the lookups of a feature of the GSUB table substitute for a glyph (e.g. rtlm, the right-to-left mirrored forms), or the glyph itself when the feature does not substitute it by one glyph.
HasFeature(FontFace, bool, UnicodeScript, uint)Determines whether the default language system of a script has a feature in a layout table of a font.
HasFeature(FontFace, bool, uint)Determines whether a layout table of a font has a feature, whatever the scripts and the language systems that list it.
HasVerticalAlternate(FontFace, int)Determines whether the vert feature of a font, of any script, substitutes a glyph by one glyph: a character whose vertical orientation is "transformed rotated" (Tr) is upright in a vertical line when the font has a vertical alternate for it (Unicode Standard Annex #50).
WouldSubstitute(FontFace, UnicodeScript, uint, int)Determines whether a feature of the default language system of a script substitutes a glyph on its own: whether one of its lookups has a rule whose input is the glyph alone, whatever its context.

GetPairAdjustment(FontFace, uint, int, int, uint)

LayoutQueries.cs

Gets the adjustments the lookups of a feature of the GPOS table make to two consecutive glyphs, in font units, from positions that are all 0: the advances and the offsets of the two glyphs, the y axis up. For the kern feature, a font without the feature in its GPOS table has the pairs of its legacy kerning table, added to the advance of the first glyph.

public static (GlyphPosition First, GlyphPosition Second) GetPairAdjustment(FontFace face, uint feature, int first, int second, uint scriptTag)

Parameters

face FontFace
The font.
feature uint
The tag of the feature.
first int
The first glyph.
second int
The second glyph.
scriptTag uint
The OpenType tag of the script, whose default language system is used; else the one of DFLT, dflt or latn.

Returns

(GlyphPosition First, GlyphPosition Second)

Exceptions

InvalidFontException
The GPOS table is malformed.

GetSingleSubstitution(FontFace, uint, int, uint)

LayoutQueries.cs

Gets the glyph the lookups of a feature of the GSUB table substitute for a glyph (e.g. rtlm, the right-to-left mirrored forms), or the glyph itself when the feature does not substitute it by one glyph.

public static int GetSingleSubstitution(FontFace face, uint feature, int glyph, uint scriptTag)

Parameters

face FontFace
The font.
feature uint
The tag of the feature.
glyph int
The glyph.
scriptTag uint
The OpenType tag of the script, whose default language system is used; else the one of DFLT, dflt or latn.

Returns

int

Exceptions

InvalidFontException
The GSUB table is malformed.

HasFeature overloads

HasFeature(FontFace, bool, UnicodeScript, uint)

LayoutQueries.cs

Determines whether the default language system of a script has a feature in a layout table of a font.

public static bool HasFeature(FontFace face, bool isPositioning, UnicodeScript script, uint feature)
Parameters
face FontFace
isPositioning bool
script UnicodeScript
feature uint
Returns

bool

Exceptions
InvalidFontException
The table is malformed.

HasFeature(FontFace, bool, uint)

LayoutQueries.cs

Determines whether a layout table of a font has a feature, whatever the scripts and the language systems that list it.

public static bool HasFeature(FontFace face, bool isPositioning, uint feature)
Parameters
face FontFace
The font.
isPositioning bool
true for the GPOS table, false for the GSUB table.
feature uint
The tag of the feature.
Returns

bool

HasVerticalAlternate(FontFace, int)

LayoutQueries.cs

Determines whether the vert feature of a font, of any script, substitutes a glyph by one glyph: a character whose vertical orientation is "transformed rotated" (Tr) is upright in a vertical line when the font has a vertical alternate for it (Unicode Standard Annex #50).

public static bool HasVerticalAlternate(FontFace face, int glyph)

Parameters

face FontFace
glyph int

Returns

bool

Exceptions

InvalidFontException
The GSUB table is malformed.

WouldSubstitute(FontFace, UnicodeScript, uint, int)

LayoutQueries.cs

Determines whether a feature of the default language system of a script substitutes a glyph on its own: whether one of its lookups has a rule whose input is the glyph alone, whatever its context.

public static bool WouldSubstitute(FontFace face, UnicodeScript script, uint feature, int glyph)

Parameters

face FontFace
script UnicodeScript
feature uint
glyph int

Returns

bool

Exceptions

InvalidFontException
The GSUB table is malformed.

Fields

NameDescription
DefaultScriptThe tag of the default script, and the scripts a feature of a script is looked for in after it.

DefaultScript

The tag of the default script, and the scripts a feature of a script is looked for in after it.

public static readonly uint DefaultScript