Simple API for OpenType tables, extending CTFont
. Core Text provides access to the raw data,
this library just makes it nice to use from Swift, with named accessors for all supported values.
Check if the MATH table is present:
let helvetica12 = CTFontCreateWithName("Helvetica" as CFString, 12.0, nil)
if let metrics = helvetica12.mathMetrics {
print("That's surprising!")
}
Access a constant, scaled to the font size:
let lm12 = CTFontCreateWithName("Latin Modern Math" as CFString, 12.0, nil)
let metrics = lm12.mathMetrics!
print("axis height above baseline, in pts: \(metrics.axisHeight)") // 3.0
The Latin Modern Math font is required to run the tests. It can be downloaded from CTAN.
OpenType is a very large spec, with many archaic corners. This library isn't intended to be complete by any stretch.
In fact, it currently provides only the MathConstants values from the MATH
table. If you'd like to see something
else, please submit an issue or PR.
CoreTextSwift uses a similar approach to expose the existing Core Text APIs in a nice way, and was an inspiration.
Microsoft's OpenType spec is the best reference.