PCB // Fix errors in manipulating text attributes.

This commit is contained in:
ShikiSuen 2023-09-20 19:57:47 +08:00
parent 62742e9f82
commit cf51277625
1 changed files with 8 additions and 4 deletions

View File

@ -84,6 +84,7 @@ public class PopupCompositionBuffer: NSWindowController {
return newStyle return newStyle
}(), }(),
] ]
let horizontalAttributes: [NSAttributedString.Key: Any] = [.kern: 0]
if isTypingDirectionVertical { if isTypingDirectionVertical {
attrPCBHeader.setAttributes( attrPCBHeader.setAttributes(
@ -92,6 +93,13 @@ public class PopupCompositionBuffer: NSWindowController {
attrString.setAttributes( attrString.setAttributes(
verticalAttributes, range: NSRange(location: 0, length: attrString.length) verticalAttributes, range: NSRange(location: 0, length: attrString.length)
) )
} else {
attrPCBHeader.setAttributes(
horizontalAttributes, range: NSRange(location: 0, length: attrPCBHeader.length)
)
attrString.setAttributes(
horizontalAttributes, range: NSRange(location: 0, length: attrString.length)
)
} }
let markerAttributes: [NSAttributedString.Key: Any] = { let markerAttributes: [NSAttributedString.Key: Any] = {
@ -144,10 +152,6 @@ public class PopupCompositionBuffer: NSWindowController {
attrString.insert(attrPCBHeader, at: 0) attrString.insert(attrPCBHeader, at: 0)
attrString.insert(attrPCBHeader, at: attrString.length) attrString.insert(attrPCBHeader, at: attrString.length)
attrString.setAttributes(
[.kern: 0], range: NSRange(location: 0, length: attrString.length)
)
textShown = attrString textShown = attrString
messageTextField.maximumNumberOfLines = 1 messageTextField.maximumNumberOfLines = 1
if let editor = messageTextField.currentEditor() { if let editor = messageTextField.currentEditor() {