From bcbb7e5cd700b341a272677f04939f00e0c92f66 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sat, 1 Oct 2022 12:17:34 +0800 Subject: [PATCH] TDKCandidates // Fix font clipping when lang identifier is enabled. --- .../CandidateWindow/CandidateCellDataExtension.swift | 2 +- .../Sources/Shared/CandidateBasicUnits.swift | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellDataExtension.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellDataExtension.swift index 4016374c..08417282 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellDataExtension.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellDataExtension.swift @@ -20,7 +20,7 @@ extension CandidateCellData { VStack(spacing: 0) { HStack(spacing: 4) { if UserDefaults.standard.bool(forKey: UserDef.kHandleDefaultCandidateFontsByLangIdentifier.rawValue) { - Text(AttributedString(attributedStringHeader)).frame(width: CandidateCellData.unifiedSize / 2) + Text(AttributedString(attributedStringHeader)).frame(width: CandidateCellData.unifiedSize * 2 / 3) Text(AttributedString(attributedString)) } else { Text(key).font(.system(size: fontSizeKey).monospaced()) diff --git a/Packages/vChewing_Shared/Sources/Shared/CandidateBasicUnits.swift b/Packages/vChewing_Shared/Sources/Shared/CandidateBasicUnits.swift index 6544a6bc..7428d86a 100644 --- a/Packages/vChewing_Shared/Sources/Shared/CandidateBasicUnits.swift +++ b/Packages/vChewing_Shared/Sources/Shared/CandidateBasicUnits.swift @@ -60,8 +60,14 @@ public class CandidateCellData: Hashable { let paraStyle = NSMutableParagraphStyle() paraStyle.setParagraphStyle(NSParagraphStyle.default) paraStyle.alignment = .natural + let theFontForCandidateKey: NSFont = { + if #available(macOS 10.15, *) { + return NSFont.monospacedSystemFont(ofSize: size * 0.7, weight: .regular) + } + return NSFont.monospacedDigitSystemFont(ofSize: size * 0.7, weight: .regular) + }() var attrKey: [NSAttributedString.Key: AnyObject] = [ - .font: NSFont.monospacedDigitSystemFont(ofSize: size * 0.7, weight: .regular), + .font: theFontForCandidateKey, .paragraphStyle: paraStyleKey, ] if isSelected {