fix warnings
This commit is contained in:
@@ -3,23 +3,13 @@ import Synchronization
|
||||
import SwiftUI
|
||||
|
||||
enum Fonts {
|
||||
nonisolated(unsafe) private static let descriptors: [String: CTFontDescriptor] = {
|
||||
let dir = Bundle.main.resourceURL!.appendingPathComponent("fonts")
|
||||
var out: [String: CTFontDescriptor] = [:]
|
||||
for name in try! FileManager.default.contentsOfDirectory(atPath: dir.path) where name.hasSuffix(".woff2") {
|
||||
let url = dir.appendingPathComponent(name)
|
||||
let found = CTFontManagerCreateFontDescriptorsFromURL(url as CFURL) as! [CTFontDescriptor]
|
||||
out[name] = found[0]
|
||||
}
|
||||
return out
|
||||
}()
|
||||
|
||||
private static func file(_ subset: String, _ italic: Bool, _ weight: CGFloat) -> CTFontDescriptor {
|
||||
let d = unsafe descriptors["atkinson-hyperlegible-mono-\(subset)-wght-\(italic ? "italic" : "normal").woff2"]!
|
||||
let url = Bundle.main.resourceURL!.appending(path: "fonts/atkinson-hyperlegible-mono-\(subset)-wght-\(italic ? "italic" : "normal").woff2")
|
||||
let d = (CTFontManagerCreateFontDescriptorsFromURL(url as CFURL) as! [CTFontDescriptor])[0]
|
||||
return CTFontDescriptorCreateCopyWithVariation(d, 0x7767_6874 as CFNumber, weight)
|
||||
}
|
||||
|
||||
static func ct(_ size: CGFloat, weight: CGFloat = 400, italic: Bool = false) -> CTFont {
|
||||
private static func ct(_ size: CGFloat, weight: CGFloat = 400, italic: Bool = false) -> CTFont {
|
||||
let ext = file("latin-ext", italic, weight)
|
||||
let d = CTFontDescriptorCreateCopyWithAttributes(file("latin", italic, weight), [kCTFontCascadeListAttribute: [ext]] as CFDictionary)
|
||||
return CTFontCreateWithFontDescriptor(d, size, nil)
|
||||
|
||||
Reference in New Issue
Block a user