Sunset MathTable, created MTFontV2, MTFontMathTableV2 and MathImage, about to sunset MTMathImage

This commit is contained in:
Peter Tang
2023-09-15 09:53:54 +08:00
parent 2762cbee85
commit cea2188310
10 changed files with 338 additions and 65 deletions

View File

@@ -0,0 +1,28 @@
//
// MTFontMathTableV2Tests.swift
//
//
// Created by Peter Tang on 15/9/2023.
//
import XCTest
@testable import SwiftMath
final class MTFontMathTableV2Tests: XCTestCase {
func testMTFontV2Script() throws {
let size = CGFloat(Int.random(in: 20 ... 40))
MathFont.allCases.forEach {
let mTable = $0.mtfont(size: size).mathTable
XCTAssertNotNil(mTable)
let values = [
mTable?.fractionNumeratorDisplayStyleShiftUp,
mTable?.fractionNumeratorShiftUp,
mTable?.fractionDenominatorDisplayStyleShiftDown,
mTable?.fractionDenominatorShiftDown,
mTable?.fractionNumeratorDisplayStyleGapMin,
mTable?.fractionNumeratorGapMin,
].compactMap{$0}
print("\($0.rawValue).plist: \(values)")
}
}
}

View File

@@ -0,0 +1,21 @@
//
// MTFontV2Tests.swift
//
//
// Created by Peter Tang on 15/9/2023.
//
import XCTest
@testable import SwiftMath
final class MTFontV2Tests: XCTestCase {
func testMTFontV2Script() throws {
let size = CGFloat(Int.random(in: 20 ... 40))
MathFont.allCases.forEach {
let mtfont = $0.mtfont(size: size)
let mTable = mtfont.mathTable?._mathTable
XCTAssertNotNil(mtfont)
XCTAssertNotNil(mTable)
}
}
}

View File

@@ -16,7 +16,7 @@ final class MathFontTests: XCTestCase {
// print("\(#function) ctfont \($0.ctFont(withSize: CGFloat(size)))")
XCTAssertNotNil($0.cgFont())
XCTAssertNotNil($0.ctFont(withSize: CGFloat(size)))
XCTAssertEqual($0.ctFont(withSize: CGFloat(size))?.fontSize, CGFloat(size), "ctFont fontSize test")
XCTAssertEqual($0.ctFont(withSize: CGFloat(size)).fontSize, CGFloat(size), "ctFont fontSize test")
}
#if os(iOS)
// for family in UIFont.familyNames.sorted() {

View File

@@ -1,36 +0,0 @@
import XCTest
@testable import SwiftMath
//
// MathTableTests.swift
//
//
// Created by Peter Tang on 12/9/2023.
//
final class MathTableTests: XCTestCase {
func testMathFontScript() throws {
let size = Int.random(in: 20 ... 40)
MathFont.allCases.forEach {
// print("\(#function) cgfont \($0.cgFont())")
// print("\(#function) ctfont \($0.ctFont(withSize: CGFloat(size)))")
// XCTAssertNotNil($0.cgFont())
// XCTAssertNotNil($0.ctFont(withSize: CGFloat(size)))
// XCTAssertEqual($0.ctFont(withSize: CGFloat(size))?.fontSize, CGFloat(size), "ctFont fontSize test")
let ctFont = $0.ctFont(withSize: CGFloat(size))
if let unitsPerEm = ctFont?.unitsPerEm {
let mathTable = MathTable(withFont: $0, fontSize: CGFloat(size), unitsPerEm: unitsPerEm)
let values = [
mathTable.fractionNumeratorDisplayStyleShiftUp,
mathTable.fractionNumeratorShiftUp,
mathTable.fractionDenominatorDisplayStyleShiftDown,
mathTable.fractionDenominatorShiftDown,
mathTable.fractionNumeratorDisplayStyleGapMin,
mathTable.fractionNumeratorGapMin,
]
print("\(ctFont) -> \(values)")
}
}
}
}