From 9f37e3cdb8cd09e9a54b790b32168363970db03a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 11:30:40 +0800 Subject: [PATCH] Voltaire // Differentiate Chinese fallback fonts per inputMode. - Thanks to Dr. Ken Lunde's suggestion. Note that this only works with macOS 12 Monterey and later macOS releases. --- Source/UI/CandidateUI/HorizontalCandidateController.swift | 8 ++++++++ Source/UI/CandidateUI/VerticalCandidateController.swift | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Source/UI/CandidateUI/HorizontalCandidateController.swift b/Source/UI/CandidateUI/HorizontalCandidateController.swift index a8faeb52..bab60327 100644 --- a/Source/UI/CandidateUI/HorizontalCandidateController.swift +++ b/Source/UI/CandidateUI/HorizontalCandidateController.swift @@ -132,6 +132,14 @@ fileprivate class HorizontalCandidateView: NSView { } else { NSColor.controlBackgroundColor.setFill() } + switch ctlInputMethod.currentKeyHandler.inputMode { + case InputMode.imeModeCHS: + if #available(macOS 12.0, *) {activeCandidateAttr[.languageIdentifier] = "zh-Hans" as AnyObject} + case InputMode.imeModeCHT: + if #available(macOS 12.0, *) {activeCandidateAttr[.languageIdentifier] = "zh-Hant" as AnyObject} + default: + break + } NSBezierPath.fill(rctCandidateArea) (keyLabels[index] as NSString).draw(in: rctLabel, withAttributes: activeCandidateIndexAttr) (displayedCandidates[index] as NSString).draw(in: rctCandidatePhrase, withAttributes: activeCandidateAttr) diff --git a/Source/UI/CandidateUI/VerticalCandidateController.swift b/Source/UI/CandidateUI/VerticalCandidateController.swift index 64b67eae..da384088 100644 --- a/Source/UI/CandidateUI/VerticalCandidateController.swift +++ b/Source/UI/CandidateUI/VerticalCandidateController.swift @@ -138,6 +138,14 @@ fileprivate class VerticalCandidateView: NSView { } else { NSColor.controlBackgroundColor.setFill() } + switch ctlInputMethod.currentKeyHandler.inputMode { + case InputMode.imeModeCHS: + if #available(macOS 12.0, *) {activeCandidateAttr[.languageIdentifier] = "zh-Hans" as AnyObject} + case InputMode.imeModeCHT: + if #available(macOS 12.0, *) {activeCandidateAttr[.languageIdentifier] = "zh-Hant" as AnyObject} + default: + break + } NSBezierPath.fill(rctCandidateArea) (keyLabels[index] as NSString).draw(in: rctLabel, withAttributes: activeCandidateIndexAttr) (displayedCandidates[index] as NSString).draw(in: rctCandidatePhrase, withAttributes: activeCandidateAttr)