Skip to content

Commit

Permalink
[common] Use non-deprecated font register API to make Catalyst happy
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed Apr 2, 2021
1 parent 164b04a commit 6201e1b
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Common/VT100/FontMetrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ import os.log
}
let fonts = listing.filter { item in item.pathExtension == "ttf" || item.pathExtension == "otf" }
if fonts.count > 0 {
var cfErrorsWrapper: Unmanaged<CFArray>? = nil
CTFontManagerRegisterFontsForURLs(fonts as CFArray, .process, &cfErrorsWrapper)
if let cfErrors = cfErrorsWrapper?.takeUnretainedValue(),
let errors = cfErrors as? [NSError] {
os_log("%{public}li error(s) loading fonts: %{public}@", type: .error, errors.count, errors)
if #available(iOS 13, *) {
for font in fonts {
var cfErrorWrapper: Unmanaged<CFError>? = nil
CTFontManagerRegisterFontsForURL(font as CFURL, .process, &cfErrorWrapper)
if let cfError = cfErrorWrapper?.takeUnretainedValue() {
os_log("error loading font %{public}@: %{public}@", type: .error, font.lastPathComponent, String(describing: cfError))
}
}
} else {
var cfErrorsWrapper: Unmanaged<CFArray>? = nil
CTFontManagerRegisterFontsForURLs(fonts as CFArray, .process, &cfErrorsWrapper)
if let cfErrors = cfErrorsWrapper?.takeUnretainedValue(),
let errors = cfErrors as? [NSError] {
os_log("%{public}li error(s) loading fonts: %{public}@", type: .error, errors.count, errors)
}
}
}
}
Expand Down

0 comments on commit 6201e1b

Please sign in to comment.