Add support for OpenType frac
feature (#1230).
This commit is contained in:
parent
844f4023c4
commit
35ecd6dddc
6 changed files with 125 additions and 16 deletions
50
font-src/otl/gsub-frac.ptl
Normal file
50
font-src/otl/gsub-frac.ptl
Normal file
|
@ -0,0 +1,50 @@
|
|||
import [add-common-feature add-feature add-lookup BeginLookupBlock EndLookupBlock ChainRuleBuilder] from "./table-util"
|
||||
import [NumeratorForm DenominatorForm] from "../support/gr"
|
||||
|
||||
define-operator "~>" 880 'right' : syntax-rules
|
||||
`(@l ~> @r) `{.left @l .right @r}
|
||||
|
||||
# Name-driven feature pairs
|
||||
export : define [buildFrac sink glyphStore] : begin
|
||||
local rec : BeginLookupBlock sink
|
||||
|
||||
define frac : add-feature sink 'frac'
|
||||
define { chain-rule reverse-rule } : ChainRuleBuilder sink
|
||||
|
||||
define subSolidus : add-lookup sink : object
|
||||
.type 'gsub_single'
|
||||
.substitutions : object ['solidus' 'fractionBar']
|
||||
|
||||
define digitSet { }
|
||||
define numSet { }
|
||||
define denSet { }
|
||||
|
||||
foreach { gid g } [glyphStore.namedEntries] : if (gid.(0) !== ".") : begin
|
||||
local numForm : NumeratorForm.get g
|
||||
local denForm : DenominatorForm.get g
|
||||
if (numForm && denForm) : begin
|
||||
digitSet.push gid
|
||||
numSet.push numForm
|
||||
denSet.push denForm
|
||||
|
||||
define subDen : add-lookup sink : object
|
||||
.type 'gsub_chaining'
|
||||
.rules : list
|
||||
chain-rule [{'fractionBar'}.concat denSet] [digitSet ~> denSet]
|
||||
|
||||
define subNum : add-lookup sink : object
|
||||
.type 'gsub_reverse'
|
||||
.rules : list
|
||||
reverse-rule [digitSet ~> numSet] [{'fractionBar'}.concat numSet]
|
||||
|
||||
frac.lookups.push subSolidus
|
||||
frac.lookups.push subDen
|
||||
frac.lookups.push subNum
|
||||
sink.lookupDep.push {subSolidus subDen}
|
||||
sink.lookupDep.push {subSolidus subNum}
|
||||
|
||||
add-common-feature sink frac
|
||||
|
||||
EndLookupBlock rec sink
|
||||
|
||||
define [objectIsNotEmpty obj] : obj && [Object.keys obj].length
|
|
@ -6,6 +6,7 @@ import [CreateEmptyTable finalizeTable MoveBackUtilityLookups] from "./table-uti
|
|||
import [buildLigations] from './gsub-ligation'
|
||||
import [buildCCMP] from './gsub-ccmp'
|
||||
import [buildGrFeature] from './gsub-gr'
|
||||
import [buildFrac] from './gsub-frac'
|
||||
import [buildCVSS] from './gsub-cv-ss'
|
||||
import [buildLOCL] from './gsub-locl'
|
||||
import [buildGsubThousands] from './gsub-thousands'
|
||||
|
@ -35,6 +36,9 @@ define [buildGSUB para glyphStore markGlyphs] : begin
|
|||
# ccmp
|
||||
buildCCMP gsub glyphStore markGlyphs
|
||||
|
||||
# frac
|
||||
buildFrac gsub glyphStore
|
||||
|
||||
# Ligation
|
||||
if para.enableLigation : do
|
||||
define plm : Object.assign {.} para.ligation.defaultBuildup
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue