More fvar.swift stuff. This is gonna hurt...

This commit is contained in:
Pietro Gagliardi 2017-11-02 03:17:33 -04:00
parent 03b089c972
commit 830753d888
1 changed files with 12 additions and 2 deletions

View File

@ -56,6 +56,16 @@ matches.forEach { d in
} }
print("") print("")
weightVals.forEach { k, v in weightVals.forEach { k, v in
let scaled = (v - weightMin) / (weightMax - weightMin) let basicScaled = (v - weightMin) / (weightMax - weightMin)
print("\(k) scaled = \(scaled) (OS2 \(UInt16(scaled * 1000)))") print("\(k) basic scaled = \(basicScaled) (OS2 \(UInt16(basicScaled * 1000)))")
// https://www.microsoft.com/typography/otspec/otvaroverview.htm#CSN
var opentypeScaled: Double = 0
if v < weightDef {
opentypeScaled = -((weightDef - v) / (weightDef - weightMin))
} else if v > weightDef {
opentypeScaled = (v - weightDef) / (weightMax - weightDef)
}
print("\(k) opentype scaled = \(opentypeScaled)")
} }
print("")
print("\(CTFontDescriptorCreateMatchingFontDescriptors(CTFontDescriptorCreateCopyWithVariation(matches[0], FourCharCode(2003265652) as CFNumber, CGFloat(weightMax)), Set([kCTFontVariationAttribute as String]) as CFSet))")