NSAttrTextView // Enhance compatibility with macOS 10.11 El Capitan.

- Also fine-tuning the line spacing.
This commit is contained in:
ShikiSuen 2022-09-11 07:56:58 +08:00
parent e417be73bb
commit 03d38a80ed
1 changed files with 5 additions and 3 deletions

View File

@ -65,9 +65,11 @@ public class NSAttributedTextView: NSView {
let isVertical: Bool = !(direction == .horizontal) let isVertical: Bool = !(direction == .horizontal)
newAttributes[.verticalGlyphForm] = isVertical newAttributes[.verticalGlyphForm] = isVertical
let newStyle: NSMutableParagraphStyle = newAttributes[.paragraphStyle] as! NSMutableParagraphStyle let newStyle: NSMutableParagraphStyle = newAttributes[.paragraphStyle] as! NSMutableParagraphStyle
newStyle.lineSpacing = isVertical ? (fontSize / -2) : fontSize * 0.1 if #available(macOS 10.13, *) {
newStyle.maximumLineHeight = fontSize newStyle.lineSpacing = isVertical ? (fontSize / -2) : fontSize * 0.1
newStyle.minimumLineHeight = fontSize newStyle.maximumLineHeight = fontSize * 1.1
newStyle.minimumLineHeight = fontSize * 1.1
}
newAttributes[.paragraphStyle] = newStyle newAttributes[.paragraphStyle] = newStyle
var text: String = text ?? "" var text: String = text ?? ""
if !(direction == .horizontal) { if !(direction == .horizontal) {