mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 06:43:24 +03:00
GH-812 Allow all fonts, but warn when variable width font is selected
This commit is contained in:
parent
3b364fc215
commit
13ebda767e
@ -91,8 +91,8 @@ public class NvimView: NSView,
|
|||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
guard newValue.isFixedPitch else {
|
if !newValue.fontDescriptor.symbolicTraits.contains(.monoSpace) {
|
||||||
return
|
self.log.info("\(newValue) is not monospaced.")
|
||||||
}
|
}
|
||||||
|
|
||||||
let size = newValue.pointSize
|
let size = newValue.pointSize
|
||||||
|
@ -60,6 +60,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
|||||||
self.useSnapshot = initialAppState.useSnapshotUpdate
|
self.useSnapshot = initialAppState.useSnapshotUpdate
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
|
NSUserNotificationCenter.default.delegate = self
|
||||||
}
|
}
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
|
@ -503,6 +503,7 @@ class MainWindow: NSObject,
|
|||||||
|
|
||||||
private func showInitError() {
|
private func showInitError() {
|
||||||
let notification = NSUserNotification()
|
let notification = NSUserNotification()
|
||||||
|
notification.identifier = UUID().uuidString
|
||||||
notification.title = "Error during initialization"
|
notification.title = "Error during initialization"
|
||||||
notification.informativeText =
|
notification.informativeText =
|
||||||
"""
|
"""
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* See LICENSE
|
* See LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Cocoa
|
||||||
import DictionaryCoding
|
import DictionaryCoding
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -30,10 +30,33 @@ class PrefMiddleware: MiddlewareType {
|
|||||||
return { tuple in
|
return { tuple in
|
||||||
let result = reduce(tuple)
|
let result = reduce(tuple)
|
||||||
|
|
||||||
guard tuple.modified else {
|
guard result.modified else {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let newFont = result.state.mainWindowTemplate.appearance.font
|
||||||
|
let traits = newFont.fontDescriptor.symbolicTraits
|
||||||
|
|
||||||
|
if newFont != self.currentFont {
|
||||||
|
self.currentFont = newFont
|
||||||
|
|
||||||
|
let newFontNameText: String
|
||||||
|
if let newFontName = newFont.displayName {
|
||||||
|
newFontNameText = ", \(newFontName),"
|
||||||
|
} else {
|
||||||
|
newFontNameText = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if !traits.contains(.monoSpace) {
|
||||||
|
let notification = NSUserNotification()
|
||||||
|
notification.identifier = UUID().uuidString
|
||||||
|
notification.title = "No monospaced font"
|
||||||
|
notification.informativeText = "The font you selected\(newFontNameText) does not seem "
|
||||||
|
+ "to be a monospaced font. The rendering will most likely be broken."
|
||||||
|
NSUserNotificationCenter.default.deliver(notification)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let dictionary: [String: Any] = try dictEncoder.encode(result.state)
|
let dictionary: [String: Any] = try dictEncoder.encode(result.state)
|
||||||
defaults.set(dictionary, forKey: PrefMiddleware.compatibleVersion)
|
defaults.set(dictionary, forKey: PrefMiddleware.compatibleVersion)
|
||||||
@ -45,8 +68,9 @@ class PrefMiddleware: MiddlewareType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let log = OSLog(subsystem: Defs.loggerSubsystem,
|
private let log = OSLog(subsystem: Defs.loggerSubsystem, category: Defs.LoggerCategory.middleware)
|
||||||
category: Defs.LoggerCategory.middleware)
|
|
||||||
|
private var currentFont = NSFont.userFixedPitchFont(ofSize: 13)!
|
||||||
|
|
||||||
class MainWindowMiddleware: MiddlewareType {
|
class MainWindowMiddleware: MiddlewareType {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user