Use Atkinson Hyperlegible Next, keeping Mono for code
This commit is contained in:
@@ -50,6 +50,6 @@ When the owner tells the lead "deploy byre", or anything that means the same, th
|
||||
|
||||
## UI look
|
||||
|
||||
- One font everywhere: Atkinson Hyperlegible Mono, bundled from `mac/fonts/`.
|
||||
- Two fonts, bundled from `mac/fonts/`: Atkinson Hyperlegible Next for everything, and Atkinson Hyperlegible Mono only for text whose columns matter: code (blocks and inline), diffs, file contents, the terminal, raw tool input and output, and shell commands. Both follow the one font size setting.
|
||||
- High contrast means readable text, not harshness. Body text is at least 7:1 against its background and secondary text at least 4.5:1, on soft backgrounds (off-white, dark slate; never pure black or white). Keep the frame quiet: 1px borders in a subtle tone, no dashed or heavy borders, no inverted blocks for selection, colour used sparingly for state and accent. The palette lives in `mac/Sources/Byre/Palette.swift`; change it there.
|
||||
- Never show agent cost, turn duration, or turn counts anywhere in the UI. They stay in the event log for the API, not on screen.
|
||||
|
||||
+1
-1
@@ -59,4 +59,4 @@ Places where SwiftUI alone may fall short, each checked side by side against its
|
||||
| Font from `mac/fonts/` | Core Text | Convert the files to TTF in the build script | No fallback: Core Text reads the woff2 files and their `wght` axis (200–800) |
|
||||
| SVG images from the worktree image endpoint | `NSImage(data:)` | Show the "image not available" text | No fallback: `NSImage(data:)` decodes SVG and draws it sharp at any size |
|
||||
|
||||
The font files need one thing beyond loading. The latin and latin-ext files are subsets of one variable font with the same PostScript names, so registering both and looking the font up by name finds only the latin file, and characters such as `ő` and `Ł` fall back to a system font. The app instead makes a descriptor from each file's URL, sets the weight with `CTFontDescriptorCreateCopyWithVariation`, and puts the latin-ext descriptor in the latin one's `kCTFontCascadeListAttribute`; characters in neither file then fall back to the system cascade (`→` to Menlo).
|
||||
The font files need one thing beyond loading. Each family's latin and latin-ext files are subsets of one variable font with the same PostScript names, so registering both and looking the font up by name finds only the latin file, and characters such as `ő` and `Ł` fall back to a system font. The app instead makes a descriptor from each file's URL, sets the weight with `CTFontDescriptorCreateCopyWithVariation`, and puts the latin-ext descriptor in the latin one's `kCTFontCascadeListAttribute`; characters in neither file then fall back to the system cascade (`→` to Menlo).
|
||||
|
||||
@@ -418,7 +418,7 @@ private struct HiddenComments: View {
|
||||
.font(Fonts.font(11))
|
||||
.foregroundStyle(Palette.muted)
|
||||
Text(verbatim: c.anchor.quote)
|
||||
.font(Fonts.font(11))
|
||||
.font(Fonts.font(11, mono: true))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
LineCommentBox(drafts: drafts, taskId: taskId, anchor: c.anchor)
|
||||
@@ -608,7 +608,7 @@ struct DiffLines: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.font(Fonts.font(11))
|
||||
.font(Fonts.font(11, mono: true))
|
||||
.padding(.vertical, 4)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ private struct FileText: View {
|
||||
.textSelection(.enabled)
|
||||
.padding(.trailing, 10)
|
||||
}
|
||||
.font(Fonts.font(11))
|
||||
.font(Fonts.font(11, mono: true))
|
||||
.fixedSize()
|
||||
.padding(.vertical, 6)
|
||||
if content.truncated {
|
||||
|
||||
@@ -37,15 +37,16 @@ final class FontSize {
|
||||
}
|
||||
|
||||
enum Fonts {
|
||||
private static func file(_ subset: String, _ italic: Bool, _ weight: CGFloat) -> CTFontDescriptor {
|
||||
let url = Bundle.main.resourceURL!.appending(path: "fonts/atkinson-hyperlegible-mono-\(subset)-wght-\(italic ? "italic" : "normal").woff2")
|
||||
private static func file(_ family: String, _ subset: String, _ italic: Bool, _ weight: CGFloat) -> CTFontDescriptor {
|
||||
let url = Bundle.main.resourceURL!.appending(path: "fonts/atkinson-hyperlegible-\(family)-\(subset)-wght-\(italic ? "italic" : "normal").woff2")
|
||||
let d = (CTFontManagerCreateFontDescriptorsFromURL(url as CFURL) as! [CTFontDescriptor])[0]
|
||||
return CTFontDescriptorCreateCopyWithVariation(d, 0x7767_6874 as CFNumber, weight)
|
||||
}
|
||||
|
||||
private static func ct(_ size: CGFloat, weight: CGFloat = 400, italic: Bool = false) -> CTFont {
|
||||
let ext = file("latin-ext", italic, weight)
|
||||
let d = CTFontDescriptorCreateCopyWithAttributes(file("latin", italic, weight), [kCTFontCascadeListAttribute: [ext]] as CFDictionary)
|
||||
private static func ct(_ size: CGFloat, weight: CGFloat, italic: Bool, mono: Bool) -> CTFont {
|
||||
let family = mono ? "mono" : "next"
|
||||
let ext = file(family, "latin-ext", italic, weight)
|
||||
let d = CTFontDescriptorCreateCopyWithAttributes(file(family, "latin", italic, weight), [kCTFontCascadeListAttribute: [ext]] as CFDictionary)
|
||||
return CTFontCreateWithFontDescriptor(d, size, nil)
|
||||
}
|
||||
|
||||
@@ -53,26 +54,26 @@ enum Fonts {
|
||||
|
||||
// Call sites give sizes relative to a 13pt body; the user's font size shifts them all.
|
||||
@MainActor
|
||||
private static func cached(_ size: CGFloat, _ weight: CGFloat, _ italic: Bool) -> CTFont {
|
||||
private static func cached(_ size: CGFloat, _ weight: CGFloat, _ italic: Bool, _ mono: Bool) -> CTFont {
|
||||
let size = size + CGFloat(FontSize.shared.body - 13)
|
||||
let key = "\(size) \(weight) \(italic)"
|
||||
let key = "\(size) \(weight) \(italic) \(mono)"
|
||||
return fonts.withLock { fonts in
|
||||
if let f = fonts[key] {
|
||||
return f
|
||||
}
|
||||
let f = ct(size, weight: weight, italic: italic)
|
||||
let f = ct(size, weight: weight, italic: italic, mono: mono)
|
||||
fonts[key] = f
|
||||
return f
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static func font(_ size: CGFloat, weight: CGFloat = 400, italic: Bool = false) -> Font {
|
||||
Font(cached(size, weight, italic))
|
||||
static func font(_ size: CGFloat, weight: CGFloat = 400, italic: Bool = false, mono: Bool = false) -> Font {
|
||||
Font(cached(size, weight, italic, mono))
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static func ns(_ size: CGFloat, weight: CGFloat = 400, italic: Bool = false) -> NSFont {
|
||||
cached(size, weight, italic) as NSFont
|
||||
static func ns(_ size: CGFloat, weight: CGFloat = 400, italic: Bool = false, mono: Bool = false) -> NSFont {
|
||||
cached(size, weight, italic, mono) as NSFont
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ struct PreBox: View {
|
||||
Copyable(text: text) {
|
||||
ScrollView {
|
||||
Text(verbatim: text)
|
||||
.font(Fonts.font(size))
|
||||
.font(Fonts.font(size, mono: true))
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 8)
|
||||
|
||||
@@ -172,6 +172,7 @@ struct InlineRenderer {
|
||||
var color: Color?
|
||||
var small = false
|
||||
var tip: String?
|
||||
var mono = false
|
||||
}
|
||||
|
||||
func segments(_ items: [MDInline]) -> [MDSegment] {
|
||||
@@ -192,8 +193,8 @@ struct InlineRenderer {
|
||||
|
||||
private func run(_ s: String, _ style: Style) -> AttributedString {
|
||||
var a = AttributedString(s)
|
||||
a.font = Fonts.font(style.small ? 11 : size, weight: style.bold ? 700 : weight, italic: style.italic)
|
||||
a.mergeAttributes(try! AttributeContainer([.font: Fonts.ns(style.small ? 11 : size, weight: style.bold ? 700 : weight, italic: style.italic)], including: \.appKit))
|
||||
a.font = Fonts.font(style.small ? 11 : size, weight: style.bold ? 700 : weight, italic: style.italic, mono: style.mono)
|
||||
a.mergeAttributes(try! AttributeContainer([.font: Fonts.ns(style.small ? 11 : size, weight: style.bold ? 700 : weight, italic: style.italic, mono: style.mono)], including: \.appKit))
|
||||
if let link = style.link {
|
||||
a.link = link
|
||||
}
|
||||
@@ -224,6 +225,7 @@ struct InlineRenderer {
|
||||
append(run("\n", style), &out)
|
||||
case .code(let c):
|
||||
var s = style
|
||||
s.mono = true
|
||||
if s.link == nil, let path = codeFile(c) {
|
||||
s.link = path
|
||||
s.color = Palette.accent
|
||||
@@ -795,7 +797,7 @@ private struct BlockView: View {
|
||||
Copyable(text: code) {
|
||||
ScrollView(.horizontal) {
|
||||
Text(verbatim: code)
|
||||
.font(Fonts.font(ctx.size))
|
||||
.font(Fonts.font(ctx.size, mono: true))
|
||||
.foregroundStyle(Palette.text)
|
||||
.textSelection(.enabled)
|
||||
.fixedSize()
|
||||
@@ -881,7 +883,7 @@ private struct DiffBlock: View {
|
||||
StretchColumn(minWidth: width) {
|
||||
ForEach(Array(lines.enumerated()), id: \.offset) { _, line in
|
||||
Text(verbatim: line.isEmpty ? " " : line)
|
||||
.font(Fonts.font(size))
|
||||
.font(Fonts.font(size, mono: true))
|
||||
.foregroundStyle(line.hasPrefix("@@") || line.hasPrefix("+++") || line.hasPrefix("---") ? Palette.muted : Palette.text)
|
||||
.textSelection(.enabled)
|
||||
.fixedSize()
|
||||
|
||||
@@ -103,7 +103,7 @@ private struct CommandBox: View {
|
||||
private var box: some View {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 8) {
|
||||
Text(verbatim: command)
|
||||
.font(Fonts.font(12))
|
||||
.font(Fonts.font(12, mono: true))
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Button(copied ? "Copied" : "Copy", action: copy)
|
||||
|
||||
@@ -77,7 +77,7 @@ struct TerminalHost: NSViewRepresentable {
|
||||
|
||||
func makeNSView(context: Context) -> TerminalView {
|
||||
let t = TerminalView(frame: NSRect(x: 0, y: 0, width: 800, height: 400))
|
||||
t.font = Fonts.ns(13)
|
||||
t.font = Fonts.ns(13, mono: true)
|
||||
t.changeScrollback(5000)
|
||||
t.setCursorStyle(.steadyBlock)
|
||||
t.terminalDelegate = context.coordinator
|
||||
@@ -90,7 +90,7 @@ struct TerminalHost: NSViewRepresentable {
|
||||
}
|
||||
|
||||
func updateNSView(_ nsView: TerminalView, context: Context) {
|
||||
let font = Fonts.ns(13)
|
||||
let font = Fonts.ns(13, mono: true)
|
||||
if nsView.font !== font {
|
||||
nsView.font = font
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
Copyright 2020-2024 The Atkinson Hyperlegible Mono Project Authors (https://github.com/googlefonts/atkinson-hyperlegible-next-mono) AtkinsonHyperlegibleMono-Italic[wght].ttf: Copyright 2020-2024 The Atkinson Hyperlegible Mono Project Authors (https://github.com/googlefonts/atkinson-hyperlegible-next-mono)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user