package harfbuzz
import (
"fmt"
"github.com/go-text/typesetting/font"
ot "github.com/go-text/typesetting/font/opentype"
"github.com/go-text/typesetting/font/opentype/tables"
)
type aatLayoutFeatureType = uint16
const (
aatLayoutFeatureTypeLigatures = 1
aatLayoutFeatureTypeLetterCase = 3
aatLayoutFeatureTypeVerticalSubstitution = 4
aatLayoutFeatureTypeNumberSpacing = 6
aatLayoutFeatureTypeVerticalPosition = 10
aatLayoutFeatureTypeFractions = 11
aatLayoutFeatureTypeTypographicExtras = 14
aatLayoutFeatureTypeMathematicalExtras = 15
aatLayoutFeatureTypeCharacterAlternatives = 17
aatLayoutFeatureTypeStyleOptions = 19
aatLayoutFeatureTypeCharacterShape = 20
aatLayoutFeatureTypeNumberCase = 21
aatLayoutFeatureTypeTextSpacing = 22
aatLayoutFeatureTypeTransliteration = 23
aatLayoutFeatureTypeRubyKana = 28
aatLayoutFeatureTypeItalicCjkRoman = 32
aatLayoutFeatureTypeCaseSensitiveLayout = 33
aatLayoutFeatureTypeAlternateKana = 34
aatLayoutFeatureTypeStylisticAlternatives = 35
aatLayoutFeatureTypeContextualAlternatives = 36
aatLayoutFeatureTypeLowerCase = 37
aatLayoutFeatureTypeUpperCase = 38
aatLayoutFeatureTypeLanguageTagType = 39
)
type aatLayoutFeatureSelector = uint16
const (
aatLayoutFeatureSelectorRequiredLigaturesOn = 0
aatLayoutFeatureSelectorRequiredLigaturesOff = 1
aatLayoutFeatureSelectorCommonLigaturesOn = 2
aatLayoutFeatureSelectorCommonLigaturesOff = 3
aatLayoutFeatureSelectorRareLigaturesOn = 4
aatLayoutFeatureSelectorRareLigaturesOff = 5
aatLayoutFeatureSelectorContextualLigaturesOn = 18
aatLayoutFeatureSelectorContextualLigaturesOff = 19
aatLayoutFeatureSelectorHistoricalLigaturesOn = 20
aatLayoutFeatureSelectorHistoricalLigaturesOff = 21
aatLayoutFeatureSelectorSmallCaps = 3
aatLayoutFeatureSelectorSubstituteVerticalFormsOn = 0
aatLayoutFeatureSelectorSubstituteVerticalFormsOff = 1
aatLayoutFeatureSelectorMonospacedNumbers = 0
aatLayoutFeatureSelectorProportionalNumbers = 1
aatLayoutFeatureSelectorNormalPosition = 0
aatLayoutFeatureSelectorSuperiors = 1
aatLayoutFeatureSelectorInferiors = 2
aatLayoutFeatureSelectorOrdinals = 3
aatLayoutFeatureSelectorScientificInferiors = 4
aatLayoutFeatureSelectorNoFractions = 0
aatLayoutFeatureSelectorVerticalFractions = 1
aatLayoutFeatureSelectorDiagonalFractions = 2
aatLayoutFeatureSelectorSlashedZeroOn = 4
aatLayoutFeatureSelectorSlashedZeroOff = 5
aatLayoutFeatureSelectorMathematicalGreekOn = 10
aatLayoutFeatureSelectorMathematicalGreekOff = 11
aatLayoutFeatureSelectorNoStyleOptions = 0
aatLayoutFeatureSelectorTitlingCaps = 4
aatLayoutFeatureSelectorTraditionalCharacters = 0
aatLayoutFeatureSelectorSimplifiedCharacters = 1
aatLayoutFeatureSelectorJis1978Characters = 2
aatLayoutFeatureSelectorJis1983Characters = 3
aatLayoutFeatureSelectorJis1990Characters = 4
aatLayoutFeatureSelectorExpertCharacters = 10
aatLayoutFeatureSelectorJis2004Characters = 11
aatLayoutFeatureSelectorHojoCharacters = 12
aatLayoutFeatureSelectorNlccharacters = 13
aatLayoutFeatureSelectorTraditionalNamesCharacters = 14
aatLayoutFeatureSelectorLowerCaseNumbers = 0
aatLayoutFeatureSelectorUpperCaseNumbers = 1
aatLayoutFeatureSelectorProportionalText = 0
aatLayoutFeatureSelectorMonospacedText = 1
aatLayoutFeatureSelectorHalfWidthText = 2
aatLayoutFeatureSelectorThirdWidthText = 3
aatLayoutFeatureSelectorQuarterWidthText = 4
aatLayoutFeatureSelectorAltProportionalText = 5
aatLayoutFeatureSelectorAltHalfWidthText = 6
aatLayoutFeatureSelectorNoTransliteration = 0
aatLayoutFeatureSelectorHanjaToHangul = 1
aatLayoutFeatureSelectorRubyKanaOn = 2
aatLayoutFeatureSelectorRubyKanaOff = 3
aatLayoutFeatureSelectorCjkItalicRomanOn = 2
aatLayoutFeatureSelectorCjkItalicRomanOff = 3
aatLayoutFeatureSelectorCaseSensitiveLayoutOn = 0
aatLayoutFeatureSelectorCaseSensitiveLayoutOff = 1
aatLayoutFeatureSelectorCaseSensitiveSpacingOn = 2
aatLayoutFeatureSelectorCaseSensitiveSpacingOff = 3
aatLayoutFeatureSelectorAlternateHorizKanaOn = 0
aatLayoutFeatureSelectorAlternateHorizKanaOff = 1
aatLayoutFeatureSelectorAlternateVertKanaOn = 2
aatLayoutFeatureSelectorAlternateVertKanaOff = 3
aatLayoutFeatureSelectorStylisticAltOneOn = 2
aatLayoutFeatureSelectorStylisticAltOneOff = 3
aatLayoutFeatureSelectorStylisticAltTwoOn = 4
aatLayoutFeatureSelectorStylisticAltTwoOff = 5
aatLayoutFeatureSelectorStylisticAltThreeOn = 6
aatLayoutFeatureSelectorStylisticAltThreeOff = 7
aatLayoutFeatureSelectorStylisticAltFourOn = 8
aatLayoutFeatureSelectorStylisticAltFourOff = 9
aatLayoutFeatureSelectorStylisticAltFiveOn = 10
aatLayoutFeatureSelectorStylisticAltFiveOff = 11
aatLayoutFeatureSelectorStylisticAltSixOn = 12
aatLayoutFeatureSelectorStylisticAltSixOff = 13
aatLayoutFeatureSelectorStylisticAltSevenOn = 14
aatLayoutFeatureSelectorStylisticAltSevenOff = 15
aatLayoutFeatureSelectorStylisticAltEightOn = 16
aatLayoutFeatureSelectorStylisticAltEightOff = 17
aatLayoutFeatureSelectorStylisticAltNineOn = 18
aatLayoutFeatureSelectorStylisticAltNineOff = 19
aatLayoutFeatureSelectorStylisticAltTenOn = 20
aatLayoutFeatureSelectorStylisticAltTenOff = 21
aatLayoutFeatureSelectorStylisticAltElevenOn = 22
aatLayoutFeatureSelectorStylisticAltElevenOff = 23
aatLayoutFeatureSelectorStylisticAltTwelveOn = 24
aatLayoutFeatureSelectorStylisticAltTwelveOff = 25
aatLayoutFeatureSelectorStylisticAltThirteenOn = 26
aatLayoutFeatureSelectorStylisticAltThirteenOff = 27
aatLayoutFeatureSelectorStylisticAltFourteenOn = 28
aatLayoutFeatureSelectorStylisticAltFourteenOff = 29
aatLayoutFeatureSelectorStylisticAltFifteenOn = 30
aatLayoutFeatureSelectorStylisticAltFifteenOff = 31
aatLayoutFeatureSelectorStylisticAltSixteenOn = 32
aatLayoutFeatureSelectorStylisticAltSixteenOff = 33
aatLayoutFeatureSelectorStylisticAltSeventeenOn = 34
aatLayoutFeatureSelectorStylisticAltSeventeenOff = 35
aatLayoutFeatureSelectorStylisticAltEighteenOn = 36
aatLayoutFeatureSelectorStylisticAltEighteenOff = 37
aatLayoutFeatureSelectorStylisticAltNineteenOn = 38
aatLayoutFeatureSelectorStylisticAltNineteenOff = 39
aatLayoutFeatureSelectorStylisticAltTwentyOn = 40
aatLayoutFeatureSelectorStylisticAltTwentyOff = 41
aatLayoutFeatureSelectorContextualAlternatesOn = 0
aatLayoutFeatureSelectorContextualAlternatesOff = 1
aatLayoutFeatureSelectorSwashAlternatesOn = 2
aatLayoutFeatureSelectorSwashAlternatesOff = 3
aatLayoutFeatureSelectorContextualSwashAlternatesOn = 4
aatLayoutFeatureSelectorContextualSwashAlternatesOff = 5
aatLayoutFeatureSelectorDefaultLowerCase = 0
aatLayoutFeatureSelectorLowerCaseSmallCaps = 1
aatLayoutFeatureSelectorLowerCasePetiteCaps = 2
aatLayoutFeatureSelectorDefaultUpperCase = 0
aatLayoutFeatureSelectorUpperCaseSmallCaps = 1
aatLayoutFeatureSelectorUpperCasePetiteCaps = 2
)
var featureMappings = [...]aatFeatureMapping {
{ot .NewTag ('a' , 'f' , 'r' , 'c' ), aatLayoutFeatureTypeFractions , aatLayoutFeatureSelectorVerticalFractions , aatLayoutFeatureSelectorNoFractions },
{ot .NewTag ('c' , '2' , 'p' , 'c' ), aatLayoutFeatureTypeUpperCase , aatLayoutFeatureSelectorUpperCasePetiteCaps , aatLayoutFeatureSelectorDefaultUpperCase },
{ot .NewTag ('c' , '2' , 's' , 'c' ), aatLayoutFeatureTypeUpperCase , aatLayoutFeatureSelectorUpperCaseSmallCaps , aatLayoutFeatureSelectorDefaultUpperCase },
{ot .NewTag ('c' , 'a' , 'l' , 't' ), aatLayoutFeatureTypeContextualAlternatives , aatLayoutFeatureSelectorContextualAlternatesOn , aatLayoutFeatureSelectorContextualAlternatesOff },
{ot .NewTag ('c' , 'a' , 's' , 'e' ), aatLayoutFeatureTypeCaseSensitiveLayout , aatLayoutFeatureSelectorCaseSensitiveLayoutOn , aatLayoutFeatureSelectorCaseSensitiveLayoutOff },
{ot .NewTag ('c' , 'l' , 'i' , 'g' ), aatLayoutFeatureTypeLigatures , aatLayoutFeatureSelectorContextualLigaturesOn , aatLayoutFeatureSelectorContextualLigaturesOff },
{ot .NewTag ('c' , 'p' , 's' , 'p' ), aatLayoutFeatureTypeCaseSensitiveLayout , aatLayoutFeatureSelectorCaseSensitiveSpacingOn , aatLayoutFeatureSelectorCaseSensitiveSpacingOff },
{ot .NewTag ('c' , 's' , 'w' , 'h' ), aatLayoutFeatureTypeContextualAlternatives , aatLayoutFeatureSelectorContextualSwashAlternatesOn , aatLayoutFeatureSelectorContextualSwashAlternatesOff },
{ot .NewTag ('d' , 'l' , 'i' , 'g' ), aatLayoutFeatureTypeLigatures , aatLayoutFeatureSelectorRareLigaturesOn , aatLayoutFeatureSelectorRareLigaturesOff },
{ot .NewTag ('e' , 'x' , 'p' , 't' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorExpertCharacters , 16 },
{ot .NewTag ('f' , 'r' , 'a' , 'c' ), aatLayoutFeatureTypeFractions , aatLayoutFeatureSelectorDiagonalFractions , aatLayoutFeatureSelectorNoFractions },
{ot .NewTag ('f' , 'w' , 'i' , 'd' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorMonospacedText , 7 },
{ot .NewTag ('h' , 'a' , 'l' , 't' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorAltHalfWidthText , 7 },
{ot .NewTag ('h' , 'i' , 's' , 't' ), 40 , 0 , 1 },
{ot .NewTag ('h' , 'k' , 'n' , 'a' ), aatLayoutFeatureTypeAlternateKana , aatLayoutFeatureSelectorAlternateHorizKanaOn , aatLayoutFeatureSelectorAlternateHorizKanaOff },
{ot .NewTag ('h' , 'l' , 'i' , 'g' ), aatLayoutFeatureTypeLigatures , aatLayoutFeatureSelectorHistoricalLigaturesOn , aatLayoutFeatureSelectorHistoricalLigaturesOff },
{ot .NewTag ('h' , 'n' , 'g' , 'l' ), aatLayoutFeatureTypeTransliteration , aatLayoutFeatureSelectorHanjaToHangul , aatLayoutFeatureSelectorNoTransliteration },
{ot .NewTag ('h' , 'o' , 'j' , 'o' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorHojoCharacters , 16 },
{ot .NewTag ('h' , 'w' , 'i' , 'd' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorHalfWidthText , 7 },
{ot .NewTag ('i' , 't' , 'a' , 'l' ), aatLayoutFeatureTypeItalicCjkRoman , aatLayoutFeatureSelectorCjkItalicRomanOn , aatLayoutFeatureSelectorCjkItalicRomanOff },
{ot .NewTag ('j' , 'p' , '0' , '4' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorJis2004Characters , 16 },
{ot .NewTag ('j' , 'p' , '7' , '8' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorJis1978Characters , 16 },
{ot .NewTag ('j' , 'p' , '8' , '3' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorJis1983Characters , 16 },
{ot .NewTag ('j' , 'p' , '9' , '0' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorJis1990Characters , 16 },
{ot .NewTag ('l' , 'i' , 'g' , 'a' ), aatLayoutFeatureTypeLigatures , aatLayoutFeatureSelectorCommonLigaturesOn , aatLayoutFeatureSelectorCommonLigaturesOff },
{ot .NewTag ('l' , 'n' , 'u' , 'm' ), aatLayoutFeatureTypeNumberCase , aatLayoutFeatureSelectorUpperCaseNumbers , 2 },
{ot .NewTag ('m' , 'g' , 'r' , 'k' ), aatLayoutFeatureTypeMathematicalExtras , aatLayoutFeatureSelectorMathematicalGreekOn , aatLayoutFeatureSelectorMathematicalGreekOff },
{ot .NewTag ('n' , 'l' , 'c' , 'k' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorNlccharacters , 16 },
{ot .NewTag ('o' , 'n' , 'u' , 'm' ), aatLayoutFeatureTypeNumberCase , aatLayoutFeatureSelectorLowerCaseNumbers , 2 },
{ot .NewTag ('o' , 'r' , 'd' , 'n' ), aatLayoutFeatureTypeVerticalPosition , aatLayoutFeatureSelectorOrdinals , aatLayoutFeatureSelectorNormalPosition },
{ot .NewTag ('p' , 'a' , 'l' , 't' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorAltProportionalText , 7 },
{ot .NewTag ('p' , 'c' , 'a' , 'p' ), aatLayoutFeatureTypeLowerCase , aatLayoutFeatureSelectorLowerCasePetiteCaps , aatLayoutFeatureSelectorDefaultLowerCase },
{ot .NewTag ('p' , 'k' , 'n' , 'a' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorProportionalText , 7 },
{ot .NewTag ('p' , 'n' , 'u' , 'm' ), aatLayoutFeatureTypeNumberSpacing , aatLayoutFeatureSelectorProportionalNumbers , 4 },
{ot .NewTag ('p' , 'w' , 'i' , 'd' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorProportionalText , 7 },
{ot .NewTag ('q' , 'w' , 'i' , 'd' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorQuarterWidthText , 7 },
{ot .NewTag ('r' , 'l' , 'i' , 'g' ), aatLayoutFeatureTypeLigatures , aatLayoutFeatureSelectorRequiredLigaturesOn , aatLayoutFeatureSelectorRequiredLigaturesOff },
{ot .NewTag ('r' , 'u' , 'b' , 'y' ), aatLayoutFeatureTypeRubyKana , aatLayoutFeatureSelectorRubyKanaOn , aatLayoutFeatureSelectorRubyKanaOff },
{ot .NewTag ('s' , 'i' , 'n' , 'f' ), aatLayoutFeatureTypeVerticalPosition , aatLayoutFeatureSelectorScientificInferiors , aatLayoutFeatureSelectorNormalPosition },
{ot .NewTag ('s' , 'm' , 'c' , 'p' ), aatLayoutFeatureTypeLowerCase , aatLayoutFeatureSelectorLowerCaseSmallCaps , aatLayoutFeatureSelectorDefaultLowerCase },
{ot .NewTag ('s' , 'm' , 'p' , 'l' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorSimplifiedCharacters , 16 },
{ot .NewTag ('s' , 's' , '0' , '1' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltOneOn , aatLayoutFeatureSelectorStylisticAltOneOff },
{ot .NewTag ('s' , 's' , '0' , '2' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltTwoOn , aatLayoutFeatureSelectorStylisticAltTwoOff },
{ot .NewTag ('s' , 's' , '0' , '3' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltThreeOn , aatLayoutFeatureSelectorStylisticAltThreeOff },
{ot .NewTag ('s' , 's' , '0' , '4' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltFourOn , aatLayoutFeatureSelectorStylisticAltFourOff },
{ot .NewTag ('s' , 's' , '0' , '5' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltFiveOn , aatLayoutFeatureSelectorStylisticAltFiveOff },
{ot .NewTag ('s' , 's' , '0' , '6' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltSixOn , aatLayoutFeatureSelectorStylisticAltSixOff },
{ot .NewTag ('s' , 's' , '0' , '7' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltSevenOn , aatLayoutFeatureSelectorStylisticAltSevenOff },
{ot .NewTag ('s' , 's' , '0' , '8' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltEightOn , aatLayoutFeatureSelectorStylisticAltEightOff },
{ot .NewTag ('s' , 's' , '0' , '9' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltNineOn , aatLayoutFeatureSelectorStylisticAltNineOff },
{ot .NewTag ('s' , 's' , '1' , '0' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltTenOn , aatLayoutFeatureSelectorStylisticAltTenOff },
{ot .NewTag ('s' , 's' , '1' , '1' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltElevenOn , aatLayoutFeatureSelectorStylisticAltElevenOff },
{ot .NewTag ('s' , 's' , '1' , '2' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltTwelveOn , aatLayoutFeatureSelectorStylisticAltTwelveOff },
{ot .NewTag ('s' , 's' , '1' , '3' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltThirteenOn , aatLayoutFeatureSelectorStylisticAltThirteenOff },
{ot .NewTag ('s' , 's' , '1' , '4' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltFourteenOn , aatLayoutFeatureSelectorStylisticAltFourteenOff },
{ot .NewTag ('s' , 's' , '1' , '5' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltFifteenOn , aatLayoutFeatureSelectorStylisticAltFifteenOff },
{ot .NewTag ('s' , 's' , '1' , '6' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltSixteenOn , aatLayoutFeatureSelectorStylisticAltSixteenOff },
{ot .NewTag ('s' , 's' , '1' , '7' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltSeventeenOn , aatLayoutFeatureSelectorStylisticAltSeventeenOff },
{ot .NewTag ('s' , 's' , '1' , '8' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltEighteenOn , aatLayoutFeatureSelectorStylisticAltEighteenOff },
{ot .NewTag ('s' , 's' , '1' , '9' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltNineteenOn , aatLayoutFeatureSelectorStylisticAltNineteenOff },
{ot .NewTag ('s' , 's' , '2' , '0' ), aatLayoutFeatureTypeStylisticAlternatives , aatLayoutFeatureSelectorStylisticAltTwentyOn , aatLayoutFeatureSelectorStylisticAltTwentyOff },
{ot .NewTag ('s' , 'u' , 'b' , 's' ), aatLayoutFeatureTypeVerticalPosition , aatLayoutFeatureSelectorInferiors , aatLayoutFeatureSelectorNormalPosition },
{ot .NewTag ('s' , 'u' , 'p' , 's' ), aatLayoutFeatureTypeVerticalPosition , aatLayoutFeatureSelectorSuperiors , aatLayoutFeatureSelectorNormalPosition },
{ot .NewTag ('s' , 'w' , 's' , 'h' ), aatLayoutFeatureTypeContextualAlternatives , aatLayoutFeatureSelectorSwashAlternatesOn , aatLayoutFeatureSelectorSwashAlternatesOff },
{ot .NewTag ('t' , 'i' , 't' , 'l' ), aatLayoutFeatureTypeStyleOptions , aatLayoutFeatureSelectorTitlingCaps , aatLayoutFeatureSelectorNoStyleOptions },
{ot .NewTag ('t' , 'n' , 'a' , 'm' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorTraditionalNamesCharacters , 16 },
{ot .NewTag ('t' , 'n' , 'u' , 'm' ), aatLayoutFeatureTypeNumberSpacing , aatLayoutFeatureSelectorMonospacedNumbers , 4 },
{ot .NewTag ('t' , 'r' , 'a' , 'd' ), aatLayoutFeatureTypeCharacterShape , aatLayoutFeatureSelectorTraditionalCharacters , 16 },
{ot .NewTag ('t' , 'w' , 'i' , 'd' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorThirdWidthText , 7 },
{ot .NewTag ('u' , 'n' , 'i' , 'c' ), aatLayoutFeatureTypeLetterCase , 14 , 15 },
{ot .NewTag ('v' , 'a' , 'l' , 't' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorAltProportionalText , 7 },
{ot .NewTag ('v' , 'e' , 'r' , 't' ), aatLayoutFeatureTypeVerticalSubstitution , aatLayoutFeatureSelectorSubstituteVerticalFormsOn , aatLayoutFeatureSelectorSubstituteVerticalFormsOff },
{ot .NewTag ('v' , 'h' , 'a' , 'l' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorAltHalfWidthText , 7 },
{ot .NewTag ('v' , 'k' , 'n' , 'a' ), aatLayoutFeatureTypeAlternateKana , aatLayoutFeatureSelectorAlternateVertKanaOn , aatLayoutFeatureSelectorAlternateVertKanaOff },
{ot .NewTag ('v' , 'p' , 'a' , 'l' ), aatLayoutFeatureTypeTextSpacing , aatLayoutFeatureSelectorAltProportionalText , 7 },
{ot .NewTag ('v' , 'r' , 't' , '2' ), aatLayoutFeatureTypeVerticalSubstitution , aatLayoutFeatureSelectorSubstituteVerticalFormsOn , aatLayoutFeatureSelectorSubstituteVerticalFormsOff },
{ot .NewTag ('v' , 'r' , 't' , 'r' ), aatLayoutFeatureTypeVerticalSubstitution , 2 , 3 },
{ot .NewTag ('z' , 'e' , 'r' , 'o' ), aatLayoutFeatureTypeTypographicExtras , aatLayoutFeatureSelectorSlashedZeroOn , aatLayoutFeatureSelectorSlashedZeroOff },
}
const deletedGlyph = 0xFFFF
type aatClassCache = otLayoutMappingCache
type aatApplyContext struct {
plan *otShapePlan
font *Font
face Face
buffer *Buffer
gdef tables .GDEF
ankrTable tables .Ankr
rangeFlags []rangeFlags
subtableFlags GlyphMask
bufferIsReversed bool
usingBufferGlyphSet bool
bufferGlyphSet intSet
firstSet intSet
secondSet intSet
machineClassCache aatClassCache
}
func newAatApplyContext(plan *otShapePlan , font *Font , buffer *Buffer ) *aatApplyContext {
var out aatApplyContext
out .plan = plan
out .font = font
out .face = font .face
out .buffer = buffer
return &out
}
func (c *aatApplyContext ) reverseBuffer () {
c .buffer .Reverse ()
c .bufferIsReversed = !c .bufferIsReversed
}
func (c *aatApplyContext ) setupBufferGlyphSet () {
c .usingBufferGlyphSet = len (c .buffer .Info ) >= 4
if !c .usingBufferGlyphSet {
return
}
c .buffer .collectGlyphs (&c .bufferGlyphSet )
}
func (c *aatApplyContext ) bufferIntersectsMachine () bool {
if c .usingBufferGlyphSet {
return c .bufferGlyphSet .Intersects (c .firstSet )
}
for _ , info := range c .buffer .Info {
if c .firstSet .hasGlyph (info .Glyph ) {
return true
}
}
return false
}
func (c *aatApplyContext ) outputGlyphs (glyphs []GID ) bool {
if c .usingBufferGlyphSet {
c .bufferGlyphSet .addGlyphs (glyphs )
}
for _ , glyph := range glyphs {
if glyph == deletedGlyph {
c .buffer .scratchFlags |= bsfAatHasDeleted
c .buffer .cur (0 ).setAatDeleted ()
} else {
if c .gdef .GlyphClassDef != nil {
c .buffer .cur (0 ).glyphProps = c .gdef .GlyphProps (gID (glyph ))
}
}
c .buffer .outputGlyphIndex (glyph )
}
return true
}
func (c *aatApplyContext ) replaceGlyph (glyph GID ) {
if glyph == deletedGlyph {
c .buffer .scratchFlags |= bsfAatHasDeleted
c .buffer .cur (0 ).setAatDeleted ()
}
if c .usingBufferGlyphSet {
c .bufferGlyphSet .addGlyph (glyph )
}
if c .gdef .GlyphClassDef != nil {
c .buffer .cur (0 ).glyphProps = c .gdef .GlyphProps (gID (glyph ))
}
c .buffer .replaceGlyphIndex (glyph )
}
func (c *aatApplyContext ) deleteGlyph () {
c .buffer .scratchFlags |= bsfAatHasDeleted
c .buffer .cur (0 ).setAatDeleted ()
c .buffer .replaceGlyphIndex (deletedGlyph )
}
func (c *aatApplyContext ) replace_glyph_inplace (i int , glyph gID ) {
c .buffer .Info [i ].Glyph = GID (glyph )
if c .usingBufferGlyphSet {
c .bufferGlyphSet .addGlyph (GID (glyph ))
}
if c .gdef .GlyphClassDef != nil {
c .buffer .Info [i ].glyphProps = c .gdef .GlyphProps (glyph )
}
}
func (c *aatApplyContext ) hasAnyFlags (flag GlyphMask ) bool {
for _ , fl := range c .rangeFlags {
if fl .flags &flag != 0 {
return true
}
}
return false
}
type stateTableDriver struct {
machine font .AATStateTable
}
func newStateTableDriver(machine font .AATStateTable , _ Face ) stateTableDriver {
return stateTableDriver {machine : machine }
}
func (s *stateTableDriver ) getClass (glyph GID , cache *aatClassCache ) uint16 {
key := uint16 (glyph )
if v , ok := cache .get (key ); ok {
return v
}
v := s .machine .GetClass (glyph )
cache .set (key , v )
return v
}
type driverContext interface {
inPlace() bool
isActionable(entry tables .AATStateEntry ) bool
transition(buffer *Buffer , s stateTableDriver , entry tables .AATStateEntry )
}
func (s stateTableDriver ) drive (c driverContext , ac *aatApplyContext ) {
const (
stateStartOfText = uint16 (0 )
classEndOfText = uint16 (0 )
DontAdvance = 0x4000
)
buffer := ac .buffer
if !c .inPlace () {
buffer .clearOutput ()
}
state := stateStartOfText
var lastRange int = -1
if len (ac .rangeFlags ) > 1 {
lastRange = 0
}
startStateSafeToBreakEot := !c .isActionable (s .machine .GetEntry (stateStartOfText , classEndOfText ))
for buffer .idx = 0 ; ; {
class := classEndOfText
if buffer .idx < len (buffer .Info ) {
class = s .getClass (buffer .Info [buffer .idx ].Glyph , &ac .machineClassCache )
}
resume :
if debugMode {
fmt .Printf ("\t\tState machine - class %d at index %d\n" , class , buffer .idx )
}
entry := s .machine .GetEntry (state , class )
nextState := entry .NewState
isNotEpsilonTransition := entry .Flags &DontAdvance == 0
isNotActionable := !c .isActionable (entry )
if lastRange != -1 {
range_ := lastRange
if buffer .idx < len (buffer .Info ) {
cluster := buffer .cur (0 ).Cluster
for cluster < ac .rangeFlags [range_ ].clusterFirst {
range_ --
}
for cluster > ac .rangeFlags [range_ ].clusterLast {
range_ ++
}
lastRange = range_
}
if !(ac .rangeFlags [range_ ].flags &ac .subtableFlags != 0 ) {
if buffer .idx == len (buffer .Info ) {
break
}
state = stateStartOfText
buffer .nextGlyph ()
continue
}
} else {
isNullTransition := state == stateStartOfText &&
nextState == stateStartOfText &&
startStateSafeToBreakEot &&
isNotActionable &&
isNotEpsilonTransition &&
lastRange == -1
if isNullTransition {
oldKlass := class
for class == oldKlass {
c .transition (buffer , s , entry )
if buffer .idx == len (buffer .Info ) {
break
}
buffer .nextGlyph ()
class = classEndOfText
if buffer .idx < len (buffer .Info ) {
class = s .getClass (buffer .Info [buffer .idx ].Glyph , &ac .machineClassCache )
}
}
if buffer .idx == len (buffer .Info ) {
break
}
goto resume
}
}
wouldbeEntry := s .machine .GetEntry (stateStartOfText , class )
isSafeToBreak := !c .isActionable (entry ) &&
(
state == stateStartOfText ||
((entry .Flags &DontAdvance != 0 ) && nextState == stateStartOfText ) ||
(
!c .isActionable (wouldbeEntry ) &&
(nextState == wouldbeEntry .NewState ) &&
(entry .Flags &DontAdvance ) == (wouldbeEntry .Flags &DontAdvance ))) &&
!c .isActionable (s .machine .GetEntry (state , classEndOfText ))
if !isSafeToBreak && buffer .backtrackLen () != 0 && buffer .idx < len (buffer .Info ) {
buffer .unsafeToBreakFromOutbuffer (buffer .backtrackLen ()-1 , buffer .idx +1 )
}
c .transition (buffer , s , entry )
state = nextState
if debugMode {
fmt .Printf ("\t\tState machine - new state %d\n" , state )
}
if buffer .idx == len (buffer .Info ) {
break
}
if isNotEpsilonTransition {
buffer .nextGlyph ()
} else {
if buffer .maxOps <= 0 {
buffer .maxOps --
buffer .nextGlyph ()
} else {
buffer .maxOps --
}
}
}
if !c .inPlace () {
buffer .swapBuffers ()
}
}
type aatFeatureMapping struct {
otFeatureTag font .Tag
aatFeatureType aatLayoutFeatureType
selectorToEnable aatLayoutFeatureSelector
selectorToDisable aatLayoutFeatureSelector
}
func aatLayoutFindFeatureMapping(tag font .Tag ) *aatFeatureMapping {
low , high := 0 , len (featureMappings )
for low < high {
mid := low + (high -low )/2
p := featureMappings [mid ].otFeatureTag
if tag < p {
high = mid
} else if tag > p {
low = mid + 1
} else {
return &featureMappings [mid ]
}
}
return nil
}
func (sp *otShapePlan ) aatLayoutSubstitute (font *Font , buffer *Buffer , features []Feature ) {
var map_ aatMap
if len (features ) != 0 {
builder := newAatMapBuilder (font .face .Font , sp .props )
for _ , feature := range features {
builder .addFeature (feature )
}
builder .compile (&map_ )
} else {
map_ = sp .aatMap
}
morx := font .face .Morx
c := newAatApplyContext (sp , font , buffer )
c .buffer .unsafeToConcat (0 , maxInt )
c .setupBufferGlyphSet ()
for i , chain := range morx {
accel := font .morxAccels [i ]
c .rangeFlags = map_ .chainFlags [i ]
c .applyMorx (chain , accel )
}
}
const bsfAatHasDeleted = bsfShaper0
func aatLayoutRemoveDeletedGlyphs(buffer *Buffer ) {
if buffer .scratchFlags &bsfAatHasDeleted != 0 {
buffer .deleteGlyphsInplace (func (info *GlyphInfo ) bool { return info .isAatDeleted () })
}
}
func (sp *otShapePlan ) aatLayoutPosition (font *Font , buffer *Buffer ) {
kerx := font .face .Kerx
c := newAatApplyContext (sp , font , buffer )
c .ankrTable = font .face .Ankr
c .setupBufferGlyphSet ()
c .applyKernx (kerx , font .kerxAccels )
}
func collectLookupGlyphs(dst *intSet , src tables .AatLookupMixed ) {
for _ , r := range src .Coverage () {
dst .addRange (uint32 (r [0 ]), uint32 (r [1 ]))
}
}
func (sp *otShapePlan ) aatLayoutTrack (font *Font , buffer *Buffer ) {
c := newAatApplyContext (sp , font , buffer )
c .applyTrak (0 )
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .