threadsafe protect CTFontCreateWithGraphicsFont
This commit is contained in:
@@ -156,11 +156,15 @@ private class BundleManager {
|
|||||||
}
|
}
|
||||||
//Note: ctfont creation and caching is now threadsafe.
|
//Note: ctfont creation and caching is now threadsafe.
|
||||||
guard threadSafeQueue.sync(execute: { ctFonts[fontSizePair] }) == nil else { return ctFonts[fontSizePair]! }
|
guard threadSafeQueue.sync(execute: { ctFonts[fontSizePair] }) == nil else { return ctFonts[fontSizePair]! }
|
||||||
let newCTFont = CTFontCreateWithGraphicsFont(cgFont, size, nil, nil)
|
return threadSafeQueue.sync(flags: .barrier, execute: {
|
||||||
threadSafeQueue.sync(flags: .barrier) {
|
if let ctfont = ctFonts[fontSizePair] {
|
||||||
ctFonts[fontSizePair] = newCTFont
|
return ctfont
|
||||||
}
|
} else {
|
||||||
return newCTFont
|
let result = CTFontCreateWithGraphicsFont(cgFont, size, nil, nil)
|
||||||
|
ctFonts[fontSizePair] = result
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
fileprivate func obtainRawMathTable(font: MathFont) -> NSDictionary {
|
fileprivate func obtainRawMathTable(font: MathFont) -> NSDictionary {
|
||||||
onDemandRegistration(mathFont: font)
|
onDemandRegistration(mathFont: font)
|
||||||
|
|||||||
Reference in New Issue
Block a user