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

@@ -120,6 +120,11 @@ public class MTMathAtomFactory {
return _accentValueToName!
}
static var supportedLatexSymbolNames:[String] {
let commands = MTMathAtomFactory.supportedLatexSymbols
return commands.keys.map { String($0) }
}
static var supportedLatexSymbols: [String: MTMathAtom] = [
"square" : MTMathAtomFactory.placeholder(),
@@ -663,13 +668,21 @@ public class MTMathAtomFactory {
/** Returns a fraction with the given numerator and denominator. */
public static func fraction(withNumerator num: MTMathList, denominator denom: MTMathList) -> MTFraction {
let frac = MTFraction()
frac.numerator = num
frac.denominator = denom
return frac
}
public static func mathListForCharacters(_ chars:String) -> MTMathList? {
let list = MTMathList()
for ch in chars {
if let atom = self.atom(forCharacter: ch) {
list.add(atom)
}
}
return list
}
/** Simplification of above function when numerator and denominator are simple strings.
This function uses `mathListForCharacters` to convert the strings to `MTMathList`s. */
public static func fraction(withNumeratorString numStr: String, denominatorString denomStr: String) -> MTFraction {