Added mathFonts bundle and initial code translation to test MTTypesetter.

This commit is contained in:
Michael Griebling
2023-01-12 08:32:02 -05:00
parent 82f8b08c61
commit 2ee1cc0b19
15 changed files with 1635 additions and 25 deletions

View File

@@ -33,12 +33,12 @@ public class MTFont {
// In particular it does not have the math italic characters which breaks our variable rendering.
// So we first load a CGFont from the file and then convert it to a CTFont.
self.init()
print("Loading font %@", name);
print("Loading font \(name)")
let bundle = MTFont.fontBundle
let fontPath = bundle.path(forResource: name, ofType: "otf")
let fontDataProvider = CGDataProvider(filename: fontPath!)
self.defaultCGFont = CGFont(fontDataProvider!)!
print("Num glyphs: %zd", self.defaultCGFont.numberOfGlyphs)
print("Num glyphs: \(self.defaultCGFont.numberOfGlyphs)")
self.ctFont = CTFontCreateWithGraphicsFont(self.defaultCGFont, size, nil, nil);
@@ -50,7 +50,8 @@ public class MTFont {
static var fontBundle:Bundle {
// Uses bundle for class so that this can be access by the unit tests.
return Bundle(url: Bundle(for: self).url(forResource: "iosMathFonts", withExtension: "bundle")!)!
let url = Bundle.module.url(forResource: "mathFonts", withExtension: "bundle")!
return Bundle(url: url)!
}
func copy(withSize size: CGFloat) -> MTFont {