Skip to content

Commit

Permalink
Support visionOS
Browse files Browse the repository at this point in the history
  • Loading branch information
onmyway133 committed Jan 21, 2024
1 parent 80b03a4 commit c3d666d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
13 changes: 7 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// swift-tools-version:5.3
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "FontAwesomeSwiftUI",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6)
],
.macOS(.v12),
.iOS(.v15),
.tvOS(.v13),
.watchOS(.v6),
.visionOS(.v1)
],
products: [
.library(
name: "FontAwesomeSwiftUI",
Expand Down
1 change: 0 additions & 1 deletion Sources/FontAwesomeSwiftUI/FontAwesome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public struct FontAwesome {
}
}

@available(iOS 13.0, OSX 10.15, *)
public extension SwiftUI.Font {
static func awesome(style: FontStyle, size: CGFloat) -> SwiftUI.Font {
return SwiftUI.Font.custom(style.rawValue, size: size)
Expand Down
40 changes: 19 additions & 21 deletions Sources/FontAwesomeSwiftUI/FontRegister.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,34 @@
// Created by khoa on 18/10/2020.
//

#if os(iOS) || os(tvOS)
import UIKit
#if os(OSX)
import AppKit
#else
import AppKit
import UIKit
#endif

final class FontRegister {
#if os(iOS) || os(tvOS)
func register(fontName: String) {
guard let url = self.url(fontName: fontName) else {
assertionFailure("Can not locate font \(fontName)")
return
}

var error: Unmanaged<CFError>?
if !CTFontManagerRegisterFontsForURL(url as CFURL, .process, &error) {
if let error = error {
let description: CFString = CFErrorCopyDescription(error.takeUnretainedValue())
assertionFailure("Can not locate font \(fontName). Reason \(description)")
} else {
assertionFailure("Can not register font \(fontName)")
#if os(iOS) || os(tvOS) || os(visionOS)
func register(fontName: String) {
guard let url = self.url(fontName: fontName) else {
assertionFailure("Can not locate font \(fontName)")
return
}

var error: Unmanaged<CFError>?
if !CTFontManagerRegisterFontsForURL(url as CFURL, .process, &error) {
if let error = error {
let description: CFString = CFErrorCopyDescription(error .takeUnretainedValue())
assertionFailure("Can not locate font \(fontName). Reason \(description)")
} else {
assertionFailure("Can not register font \(fontName)")
}
}
}
}

#else

func register(fontName: String) {

}
func register(fontName: String) {}

#endif

Expand Down

0 comments on commit c3d666d

Please sign in to comment.