TDKCandidates // Fix font clipping when lang identifier is enabled.

This commit is contained in:
ShikiSuen 2022-10-01 12:17:34 +08:00
parent 5b0c80db1b
commit bcbb7e5cd7
2 changed files with 8 additions and 2 deletions

View File

@ -20,7 +20,7 @@ extension CandidateCellData {
VStack(spacing: 0) { VStack(spacing: 0) {
HStack(spacing: 4) { HStack(spacing: 4) {
if UserDefaults.standard.bool(forKey: UserDef.kHandleDefaultCandidateFontsByLangIdentifier.rawValue) { 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)) Text(AttributedString(attributedString))
} else { } else {
Text(key).font(.system(size: fontSizeKey).monospaced()) Text(key).font(.system(size: fontSizeKey).monospaced())

View File

@ -60,8 +60,14 @@ public class CandidateCellData: Hashable {
let paraStyle = NSMutableParagraphStyle() let paraStyle = NSMutableParagraphStyle()
paraStyle.setParagraphStyle(NSParagraphStyle.default) paraStyle.setParagraphStyle(NSParagraphStyle.default)
paraStyle.alignment = .natural 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] = [ var attrKey: [NSAttributedString.Key: AnyObject] = [
.font: NSFont.monospacedDigitSystemFont(ofSize: size * 0.7, weight: .regular), .font: theFontForCandidateKey,
.paragraphStyle: paraStyleKey, .paragraphStyle: paraStyleKey,
] ]
if isSelected { if isSelected {