mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-24 22:33:52 +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 {
|
||||
guard newValue.isFixedPitch else {
|
||||
return
|
||||
if !newValue.fontDescriptor.symbolicTraits.contains(.monoSpace) {
|
||||
self.log.info("\(newValue) is not monospaced.")
|
||||
}
|
||||
|
||||
let size = newValue.pointSize
|
||||
|
@ -60,6 +60,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
self.useSnapshot = initialAppState.useSnapshotUpdate
|
||||
|
||||
super.init()
|
||||
|
||||
NSUserNotificationCenter.default.delegate = self
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
|
@ -503,6 +503,7 @@ class MainWindow: NSObject,
|
||||
|
||||
private func showInitError() {
|
||||
let notification = NSUserNotification()
|
||||
notification.identifier = UUID().uuidString
|
||||
notification.title = "Error during initialization"
|
||||
notification.informativeText =
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@
|
||||
* See LICENSE
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import Cocoa
|
||||
import DictionaryCoding
|
||||
import os
|
||||
|
||||
@ -30,10 +30,33 @@ class PrefMiddleware: MiddlewareType {
|
||||
return { tuple in
|
||||
let result = reduce(tuple)
|
||||
|
||||
guard tuple.modified else {
|
||||
guard result.modified else {
|
||||
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 {
|
||||
let dictionary: [String: Any] = try dictEncoder.encode(result.state)
|
||||
defaults.set(dictionary, forKey: PrefMiddleware.compatibleVersion)
|
||||
@ -45,8 +68,9 @@ class PrefMiddleware: MiddlewareType {
|
||||
}
|
||||
}
|
||||
|
||||
private let log = OSLog(subsystem: Defs.loggerSubsystem,
|
||||
category: Defs.LoggerCategory.middleware)
|
||||
private let log = OSLog(subsystem: Defs.loggerSubsystem, category: Defs.LoggerCategory.middleware)
|
||||
|
||||
private var currentFont = NSFont.userFixedPitchFont(ofSize: 13)!
|
||||
|
||||
class MainWindowMiddleware: MiddlewareType {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user