Stop using screen fonts

This commit is contained in:
1024jp 2016-10-17 20:24:20 +09:00
parent bf2233acd0
commit c7206e4d23
5 changed files with 17 additions and 11 deletions

View File

@ -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.

View File

@ -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

View File

@ -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)
}

View File

@ -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]()

View File

@ -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)
}