mirror of
https://github.com/stablyai/orca.git
synced 2026-10-25 16:03:53 +00:00
* fix(terminal): make the bold font weight its own setting
Deriving bold as max(700, regular + 200) silently destroyed bold. A family
exposes only a few real faces: the monospace the default chain resolves to on
macOS has exactly two, splitting at 600. Measured by rasterizing each weight to
a canvas — 100-500 are byte-identical (ink 3023) and 600-900 are byte-identical
(ink 3855), at every weight the same advance. So any base weight at or above 600
put both values in the same face and bold stopped existing, on 4 of the 9
positions the slider offers, with no error and nothing the user could do.
Arithmetic cannot fix it — on a two-face family there is no heavier face to
escape to. So bold is now user-owned: a new terminalFontWeightBold setting with
its own control, defaulting to 700. The default pair (500/700) straddles the
boundary, so existing profiles render exactly as before; a collision is now a
choice the user can see and undo.
The old test asserted 800 -> {800, 900} as 'keeps bold heavier', which is where
this hid: numerically heavier, identically rendered.
* fix(terminal): surface bold face collisions accurately
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
DEFAULT_TERMINAL_FONT_WEIGHT,
|
|
DEFAULT_TERMINAL_FONT_WEIGHT_BOLD,
|
|
resolveTerminalFontWeights,
|
|
normalizeTerminalFontWeight,
|
|
normalizeTerminalFontWeightBold
|
|
} from './terminal-fonts'
|
|
|
|
describe('terminal font weights', () => {
|
|
it('falls back to the Orca default when the value is missing', () => {
|
|
expect(normalizeTerminalFontWeight(undefined)).toBe(DEFAULT_TERMINAL_FONT_WEIGHT)
|
|
expect(normalizeTerminalFontWeightBold(undefined)).toBe(DEFAULT_TERMINAL_FONT_WEIGHT_BOLD)
|
|
})
|
|
|
|
it('clamps both weights to the supported xterm range', () => {
|
|
expect(normalizeTerminalFontWeight(10)).toBe(100)
|
|
expect(normalizeTerminalFontWeight(1200)).toBe(900)
|
|
expect(normalizeTerminalFontWeightBold(10)).toBe(100)
|
|
expect(normalizeTerminalFontWeightBold(1200)).toBe(900)
|
|
})
|
|
|
|
it('defaults to a pair that straddles the boundary between real font faces', () => {
|
|
expect(resolveTerminalFontWeights(undefined, undefined)).toEqual({
|
|
fontWeight: 500,
|
|
fontWeightBold: 700
|
|
})
|
|
})
|
|
|
|
it('does not derive bold from the base weight', () => {
|
|
expect(resolveTerminalFontWeights(800, undefined)).toEqual({
|
|
fontWeight: 800,
|
|
fontWeightBold: DEFAULT_TERMINAL_FONT_WEIGHT_BOLD
|
|
})
|
|
expect(resolveTerminalFontWeights(300, 400)).toEqual({
|
|
fontWeight: 300,
|
|
fontWeightBold: 400
|
|
})
|
|
expect(resolveTerminalFontWeights(700, 700)).toEqual({
|
|
fontWeight: 700,
|
|
fontWeightBold: 700
|
|
})
|
|
})
|
|
})
|