improves plak
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import CoreText
|
||||
import Foundation
|
||||
|
||||
/// Registers the bundled OpenDyslexic faces for this process.
|
||||
/// Registers the bundled OpenDyslexic and OpenDyslexic Mono faces for this process.
|
||||
public enum FontRegistry {
|
||||
public static let resourceBundleName = "Plak_PlakUI.bundle"
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import AppKit
|
||||
|
||||
/// OpenDyslexic for all text; the system font when the bundled face is missing.
|
||||
/// OpenDyslexic for text, OpenDyslexic Mono for code and tables; a system font when a bundled face is missing.
|
||||
public enum PlakFonts {
|
||||
public static let regular = "OpenDyslexic-Regular"
|
||||
public static let monoRegular = "OpenDyslexicMono-Regular"
|
||||
|
||||
public static func body(_ size: CGFloat) -> NSFont {
|
||||
FontRegistry.registerBundledFonts()
|
||||
return NSFont(name: regular, size: size) ?? .systemFont(ofSize: size)
|
||||
}
|
||||
|
||||
public static func mono(_ size: CGFloat) -> NSFont {
|
||||
FontRegistry.registerBundledFonts()
|
||||
return NSFont(name: monoRegular, size: size) ?? .monospacedSystemFont(ofSize: size, weight: .regular)
|
||||
}
|
||||
|
||||
/// The height of one line of this font with no paragraph style.
|
||||
static func naturalLineHeight(_ font: NSFont) -> CGFloat {
|
||||
ceil(font.ascender - font.descender + font.leading)
|
||||
|
||||
@@ -10,8 +10,24 @@ public enum Theme {
|
||||
public static let inkMuted = NSColor(hex: 0x6E655A)
|
||||
/// The caret.
|
||||
public static let accent = NSColor(hex: 0x8A4B2A)
|
||||
/// Selected text, and the save error message.
|
||||
/// Selected text, the save error message, and the lines of a table.
|
||||
public static let selection = NSColor(hex: 0xB9AE98)
|
||||
/// The tint behind a code block.
|
||||
public static let codePaper = NSColor(hex: 0xCBC2B0)
|
||||
/// Code keywords, and true, false and null.
|
||||
public static let codeKeyword = NSColor(hex: 0x7A2E14)
|
||||
/// Code strings and heredocs, XML attribute values and CDATA.
|
||||
public static let codeString = NSColor(hex: 0x385218)
|
||||
/// Code comments: muted, yet readable on the code paper.
|
||||
public static let codeComment = NSColor(hex: 0x564E44)
|
||||
/// Code numbers.
|
||||
public static let codeNumber = NSColor(hex: 0x2E4A7A)
|
||||
/// PHP `$variables`.
|
||||
public static let codeVariable = NSColor(hex: 0x0E5064)
|
||||
/// XML tags and the PHP open and close tags.
|
||||
public static let codeTag = NSColor(hex: 0x7A3B12)
|
||||
/// XML attribute names and JSON keys.
|
||||
public static let codeAttribute = NSColor(hex: 0x5E4A12)
|
||||
}
|
||||
|
||||
public extension NSColor {
|
||||
@@ -54,6 +70,14 @@ public enum PageMetrics {
|
||||
public static let dateMarginMinimum: CGFloat = 120
|
||||
/// Room between a margin date and the column.
|
||||
public static let dateSpacing: CGFloat = 16
|
||||
/// The size of code and tables against the body size.
|
||||
public static let codeScale: CGFloat = 0.875
|
||||
/// Room around the code inside a code block.
|
||||
public static let codePadding: CGFloat = 8
|
||||
public static let codeCornerRadius: CGFloat = 4
|
||||
/// The widest a table column shows; a longer value is cut off with an ellipsis.
|
||||
public static let tableColumnMaximum: CGFloat = 240
|
||||
public static let tableCellPadding = NSSize(width: 6, height: 3)
|
||||
|
||||
/// The width of about 68 characters of body text.
|
||||
public static func columnWidth(bodySize: CGFloat) -> CGFloat {
|
||||
|
||||
Reference in New Issue
Block a user