[Test] fix MathFontTests on mac
This commit is contained in:
19
Sources/SwiftMath/MathBundle/MathFont.swift
Executable file → Normal file
19
Sources/SwiftMath/MathBundle/MathFont.swift
Executable file → Normal file
@@ -41,11 +41,28 @@ public enum MathFont: String, CaseIterable, Identifiable {
|
|||||||
case .firaFont: "Fira Math"
|
case .firaFont: "Fira Math"
|
||||||
case .notoSansFont: "Noto Sans Math"
|
case .notoSansFont: "Noto Sans Math"
|
||||||
case .libertinusFont: "Libertinus Math"
|
case .libertinusFont: "Libertinus Math"
|
||||||
case .garamondFont: "Garamond Math"
|
case .garamondFont: "Garamond-Math" // PostScript name is "Garamond-Math", not "Garamond Math"
|
||||||
case .leteSansFont: "Lete Sans Math"
|
case .leteSansFont: "Lete Sans Math"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var postScriptName: String {
|
||||||
|
switch self {
|
||||||
|
case .latinModernFont: "LatinModernMath-Regular"
|
||||||
|
case .kpMathLightFont: "KpMath-Light"
|
||||||
|
case .kpMathSansFont: "KpMath-Sans"
|
||||||
|
case .xitsFont: "XITSMath"
|
||||||
|
case .termesFont: "TeXGyreTermesMath-Regular"
|
||||||
|
case .asanaFont: "Asana-Math"
|
||||||
|
case .eulerFont: "Euler-Math"
|
||||||
|
case .firaFont: "FiraMath-Regular"
|
||||||
|
case .notoSansFont: "NotoSansMath-Regular"
|
||||||
|
case .libertinusFont: "LibertinusMath-Regular"
|
||||||
|
case .garamondFont: "Garamond-Math"
|
||||||
|
case .leteSansFont: "LeteSansMath"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var fontName: String { self.rawValue }
|
var fontName: String { self.rawValue }
|
||||||
|
|
||||||
public func cgFont() -> CGFont {
|
public func cgFont() -> CGFont {
|
||||||
|
|||||||
4
Tests/SwiftMathTests/MathFontTests.swift
Executable file → Normal file
4
Tests/SwiftMathTests/MathFontTests.swift
Executable file → Normal file
@@ -17,7 +17,7 @@ final class MathFontTests: XCTestCase {
|
|||||||
XCTAssertNotNil($0.cgFont())
|
XCTAssertNotNil($0.cgFont())
|
||||||
XCTAssertNotNil($0.ctFont(withSize: CGFloat(size)))
|
XCTAssertNotNil($0.ctFont(withSize: CGFloat(size)))
|
||||||
XCTAssertEqual($0.ctFont(withSize: CGFloat(size)).fontSize, CGFloat(size), "ctFont fontSize != size.")
|
XCTAssertEqual($0.ctFont(withSize: CGFloat(size)).fontSize, CGFloat(size), "ctFont fontSize != size.")
|
||||||
XCTAssertEqual($0.cgFont().postScriptName as? String, $0.fontName, "postscript Name != UIFont fontName")
|
XCTAssertEqual($0.cgFont().postScriptName as? String, $0.postScriptName, "cgFont.postScriptName != postScriptName")
|
||||||
// XCTAssertEqual($0.uiFont(withSize: CGFloat(size))?.familyName, $0.fontFamilyName, "uifont familyName != familyName.")
|
// XCTAssertEqual($0.uiFont(withSize: CGFloat(size))?.familyName, $0.fontFamilyName, "uifont familyName != familyName.")
|
||||||
XCTAssertEqual(CTFontCopyFamilyName($0.ctFont(withSize: CGFloat(size))) as String, $0.fontFamilyName, "ctfont.family != familyName")
|
XCTAssertEqual(CTFontCopyFamilyName($0.ctFont(withSize: CGFloat(size))) as String, $0.fontFamilyName, "ctfont.family != familyName")
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ final class MathFontTests: XCTestCase {
|
|||||||
XCTAssertEqual(mathFont.ctFont(withSize: CGFloat(size)).fontSize, CGFloat(size), "ctFont fontSize test")
|
XCTAssertEqual(mathFont.ctFont(withSize: CGFloat(size)).fontSize, CGFloat(size), "ctFont fontSize test")
|
||||||
}
|
}
|
||||||
var fontNames: [String] {
|
var fontNames: [String] {
|
||||||
MathFont.allCases.map { $0.fontName }
|
MathFont.allCases.map { $0.postScriptName }
|
||||||
}
|
}
|
||||||
var fontFamilyNames: [String] {
|
var fontFamilyNames: [String] {
|
||||||
MathFont.allCases.map { $0.fontFamilyName }
|
MathFont.allCases.map { $0.fontFamilyName }
|
||||||
|
|||||||
Reference in New Issue
Block a user