ctlIME // Failed to set languageIdentifier for composing buffer font.

This commit is contained in:
ShikiSuen 2022-06-22 13:35:03 +08:00
parent 2f68cf373c
commit 48f8a1f94a
1 changed files with 32 additions and 0 deletions

View File

@ -278,6 +278,38 @@ extension ctlInputMethod {
clearInlineDisplay() clearInlineDisplay()
return return
} }
var identifier: AnyObject {
switch IME.currentInputMode {
case InputMode.imeModeCHS:
if #available(macOS 12.0, *) {
return "zh-Hans" as AnyObject
}
case InputMode.imeModeCHT:
if #available(macOS 12.0, *) {
return (mgrPrefs.shiftJISShinjitaiOutputEnabled || mgrPrefs.chineseConversionEnabled)
? "ja" as AnyObject : "zh-Hant" as AnyObject
}
default:
break
}
return "" as AnyObject
}
// [Shiki's Note] This might needs to be bug-reported to Apple:
// The LanguageIdentifier attribute of an NSAttributeString designated to
// IMK Client().SetMarkedText won't let the actual font respect your languageIdentifier
// settings. Still, this might behaves as Apple's current expectation, I'm afraid.
if #available(macOS 12.0, *) {
state.attributedString.setAttributes(
[.languageIdentifier: identifier],
range: NSRange(
location: 0,
length: state.composingBuffer.utf16.count
)
)
}
/// selectionRange /// selectionRange
/// 0 replacementRangeNSNotFound /// 0 replacementRangeNSNotFound
/// ///