Added support for visionOS by adding to #if os(iOS) || os(visionOS)
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
// Created by Peter Tang on 10/9/2023.
|
// Created by Peter Tang on 10/9/2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#elseif os(macOS)
|
#elseif os(macOS)
|
||||||
import AppKit
|
import AppKit
|
||||||
@@ -59,7 +59,7 @@ public enum MathFont: String, CaseIterable, Identifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Note: Below code are no longer supported, unable to tell if UIFont/NSFont is threadsafe, not used in SwiftMath.
|
//Note: Below code are no longer supported, unable to tell if UIFont/NSFont is threadsafe, not used in SwiftMath.
|
||||||
// #if os(iOS)
|
// #if os(iOS) || os(visionOS)
|
||||||
// public func uiFont(withSize size: CGFloat) -> UIFont? {
|
// public func uiFont(withSize size: CGFloat) -> UIFont? {
|
||||||
// UIFont(name: fontName, size: size)
|
// UIFont(name: fontName, size: size)
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#elseif os(macOS)
|
#elseif os(macOS)
|
||||||
import AppKit
|
import AppKit
|
||||||
@@ -78,7 +78,7 @@ extension MathImage {
|
|||||||
let size = intrinsicContentSize.regularized
|
let size = intrinsicContentSize.regularized
|
||||||
layoutImage(size: size, displayList: displayList)
|
layoutImage(size: size, displayList: displayList)
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
let renderer = UIGraphicsImageRenderer(size: size)
|
let renderer = UIGraphicsImageRenderer(size: size)
|
||||||
let image = renderer.image { rendererContext in
|
let image = renderer.image { rendererContext in
|
||||||
rendererContext.cgContext.saveGState()
|
rendererContext.cgContext.saveGState()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Foundation
|
|||||||
// MIT license. See the LICENSE file for details.
|
// MIT license. See the LICENSE file for details.
|
||||||
//
|
//
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ extension MTMathImage {
|
|||||||
let size = intrinsicContentSize
|
let size = intrinsicContentSize
|
||||||
layoutImage(size: size, displayList: displayList)
|
layoutImage(size: size, displayList: displayList)
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
let renderer = UIGraphicsImageRenderer(size: size)
|
let renderer = UIGraphicsImageRenderer(size: size)
|
||||||
let image = renderer.image { rendererContext in
|
let image = renderer.image { rendererContext in
|
||||||
rendererContext.cgContext.saveGState()
|
rendererContext.cgContext.saveGState()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import SwiftUI
|
|||||||
|
|
||||||
func isIos6Supported() -> Bool {
|
func isIos6Supported() -> Bool {
|
||||||
if !MTDisplay.initialized {
|
if !MTDisplay.initialized {
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
let reqSysVer = "6.0"
|
let reqSysVer = "6.0"
|
||||||
let currSysVer = UIDevice.current.systemVersion
|
let currSysVer = UIDevice.current.systemVersion
|
||||||
if currSysVer.compare(reqSysVer, options: .numeric) != .orderedAscending {
|
if currSysVer.compare(reqSysVer, options: .numeric) != .orderedAscending {
|
||||||
@@ -58,7 +58,7 @@ public class MTDisplay:NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// For debugging. Shows the object in quick look in Xcode.
|
/// For debugging. Shows the object in quick look in Xcode.
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
func debugQuickLookObject() -> Any {
|
func debugQuickLookObject() -> Any {
|
||||||
let size = CGSizeMake(self.width, self.ascent + self.descent);
|
let size = CGSizeMake(self.width, self.ascent + self.descent);
|
||||||
UIGraphicsBeginImageContext(size);
|
UIGraphicsBeginImageContext(size);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ final class MathFontTests: XCTestCase {
|
|||||||
// 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")
|
||||||
}
|
}
|
||||||
#if os(iOS)
|
#if os(iOS) || os(visionOS)
|
||||||
// for family in UIFont.familyNames.sorted() {
|
// for family in UIFont.familyNames.sorted() {
|
||||||
// let names = UIFont.fontNames(forFamilyName: family)
|
// let names = UIFont.fontNames(forFamilyName: family)
|
||||||
// print("Family: \(family) Font names: \(names)")
|
// print("Family: \(family) Font names: \(names)")
|
||||||
|
|||||||
Reference in New Issue
Block a user