Skip to content

Swift API for accessing font data from OpenType font files

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt
Notifications You must be signed in to change notification settings

satzlich/swift-open-type

Repository files navigation

SwiftOpenType

API for OpenType tables.

Status

Access to MATH table is fully supported.

harfbuzz SwiftOpenType
hb_ot_math_has_data hasData
hb_ot_math_get_constant getConstant
hb_ot_math_get_glyph_italics_correction getGlyphItalicsCorrection
hb_ot_math_get_glyph_top_accent_attachment getGlyphTopAccentAttachment
hb_ot_math_get_glyph_kerning getGlyphKerning
hb_ot_math_get_glyph_kernings getGlyphKernings,
getGlyphKerningCount
hb_ot_math_is_glyph_extended_shape isGlyphExtendedShape
hb_ot_math_get_glyph_variants getGlyphVariants,
getGlyphVariantCount
hb_ot_math_get_min_connector_overlap getMinConnectorOverlap
hb_ot_math_get_glyph_assembly getGlyphAssembly,
getGlyphAssemblyItalicsCorrection,
getGlyphAssemblyParts,
getGlyphAssemblyPartCount

Example

do {
    let helvetica = CTFontCreateWithName("Helvetica" as CFString, 12.0, nil)
    let mathTable = helvetica.createCachedMathTable()
    if !mathTable.hasData() {
        print("no MATH table")
    }
}

do {
    let lmmath = CTFontCreateWithName("Latin Modern Math" as CFString, 12.0, nil)
    let mathTable = lmmath.createCachedMathTable()
    print("axis height, in design units: \(mathTable.getConstant(.axisHeight))")
}

Tests

See MathTableTests

See also

OpenTypeSwift is the repository that this codebase evolved from, which supports math constants.

OpenType Specification is the best reference.

About

Swift API for accessing font data from OpenType font files

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages