mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Stop using screen fonts
This commit is contained in:
parent
bf2233acd0
commit
c7206e4d23
@ -5,6 +5,11 @@ Change Log
|
||||
develop
|
||||
--------------------------
|
||||
|
||||
### Improvements
|
||||
|
||||
- Adjust glyph size calculation.
|
||||
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix an issue where document icons were blurry in non-Retina display.
|
||||
|
@ -117,7 +117,6 @@ final class EditorTextView: NSTextView, Themable {
|
||||
|
||||
// setup layoutManager and textContainer
|
||||
let layoutManager = LayoutManager()
|
||||
layoutManager.usesScreenFonts = true
|
||||
layoutManager.allowsNonContiguousLayout = true
|
||||
self.textContainer!.replaceLayoutManager(layoutManager)
|
||||
|
||||
@ -1091,9 +1090,9 @@ final class EditorTextView: NSTextView, Themable {
|
||||
paragraphStyle.lineHeightMultiple = self.lineHeight.rounded(to: 5)
|
||||
|
||||
// calculate tab interval
|
||||
if let font = self.font, let displayFont = self.layoutManager?.substituteFont(for: font) {
|
||||
if let font = self.font {
|
||||
paragraphStyle.tabStops = []
|
||||
paragraphStyle.defaultTabInterval = CGFloat(self.tabWidth) * displayFont.advancement(character: " ").width
|
||||
paragraphStyle.defaultTabInterval = CGFloat(self.tabWidth) * font.advancement(character: " ").width
|
||||
}
|
||||
|
||||
self.defaultParagraphStyle = paragraphStyle
|
||||
|
@ -63,7 +63,6 @@ final class FindPanelTextView: NSTextView {
|
||||
|
||||
// set subclassed layout manager for invisible characters
|
||||
let layoutManager = FindPanelLayoutManager()
|
||||
layoutManager.usesScreenFonts = true
|
||||
self.textContainer?.replaceLayoutManager(layoutManager)
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,7 @@ final class LayoutManager: NSLayoutManager {
|
||||
}
|
||||
|
||||
// cache width of space char for hanging indent width calculation
|
||||
let drawingFont = self.substituteFont(for: textFont)
|
||||
self.spaceWidth = drawingFont.advancement(character: " ").width
|
||||
self.spaceWidth = textFont.advancement(character: " ").width
|
||||
|
||||
self.invisibleLines = self.generateInvisibleLines()
|
||||
}
|
||||
@ -312,10 +311,15 @@ final class LayoutManager: NSLayoutManager {
|
||||
|
||||
// get dummy attributes to make calculation of indent width the same as layoutManager's calculation (2016-04)
|
||||
let defaultParagraphStyle = textView.defaultParagraphStyle ?? NSParagraphStyle.default()
|
||||
let typingParagraphStyle = (textView.typingAttributes[NSParagraphStyleAttributeName] as? NSParagraphStyle)?.mutableCopy() as? NSMutableParagraphStyle
|
||||
typingParagraphStyle?.headIndent = 1.0 // dummy indent value for size calculation (2016-04)
|
||||
var indentAttributes: [String: Any] = [NSFontAttributeName: self.substituteFont(for: self.textFont)]
|
||||
indentAttributes[NSParagraphStyleAttributeName] = typingParagraphStyle
|
||||
let indentAttributes: [String: Any] = {
|
||||
let typingParagraphStyle = (textView.typingAttributes[NSParagraphStyleAttributeName] as? NSParagraphStyle)?.mutableCopy() as? NSMutableParagraphStyle
|
||||
typingParagraphStyle?.headIndent = 1.0 // dummy indent value for size calculation (2016-04)
|
||||
|
||||
var attributes: [String: Any] = [:]
|
||||
attributes[NSFontAttributeName] = self.textFont
|
||||
attributes[NSParagraphStyleAttributeName] = typingParagraphStyle
|
||||
return attributes
|
||||
}()
|
||||
|
||||
var cache = [String: CGFloat]()
|
||||
|
||||
|
@ -90,7 +90,6 @@ final class PrintTextView: NSTextView, NSLayoutManagerDelegate, Themable {
|
||||
// replace layoutManager
|
||||
let layoutManager = LayoutManager()
|
||||
layoutManager.delegate = self
|
||||
layoutManager.usesScreenFonts = false
|
||||
self.textContainer!.replaceLayoutManager(layoutManager)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user