The wordmark says bright as a colour, because bold is not brightness everywhere
On a Mac the splash drew muted, and the dithers that fade one colour into another faded toward the wrong end. An art editor spells brightness the DOS way: 1m lifts the foreground into the bright bank and the spans after it inherit that. It is true of a DOS console and of the PicoCalc's, and it is false on macOS Terminal, where bold asks for a heavier face and leaves the colour alone. There 1;30 is not dark grey but plain black -- and the wide mark carries seventy-nine such spans, much of it on a black ground, so the shading and bevels flattened into the background. The gradients went with them: a fade drawn as a bright stipple over a dim ground loses its top end when the bright half stops being bright, and what is left reads as a dotted pattern that has not come out right. So the bright bank is emitted as the colour it means -- 9N, which cannot be mistaken for a font weight, and which is how the PicoCalc's own console spells bright anyway. Which colour is being asked for does not change, and neither does a single cell: only the spelling, from one a terminal may read as a weight to one that can only be a colour. Bold is now asked for nowhere in the mark. The art files are untouched. They stay authored the way the editors that drew them write, and the loader goes on being the place where what DOS assumed is translated into what a terminal can be told. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b1f21664ff
commit
9a58bc04bb
2 files changed
+81
-15
No files matched your search
+43
-15
@@ -158,13 +158,25 @@ def _rewrap(line: str, width: int) -> list[str]:
|
||||
|
||||
|
||||
def _state_intensity(row: str) -> str:
|
||||
"""Rewrite the row's colour changes so every one says whether it is bright.
|
||||
"""Rewrite the row's colour changes so brightness is stated as a colour, not as bold.
|
||||
|
||||
An art editor spells brightness the DOS way — ``1m`` lifts the bank and each span after
|
||||
it inherits that — which reads correctly only while the escapes stay one unbroken
|
||||
stream. They don't here: a row is handed to Rich on its own, and the console draws bold
|
||||
*as* the bright bank, so a span that never mentions intensity is read against whatever
|
||||
happened to be set. Saying it outright changes no colour; it just stops one drifting.
|
||||
An art editor spells brightness the DOS way — ``1m`` lifts the foreground into the
|
||||
bright bank, and each span after it inherits that. Two things then have to be settled
|
||||
before the row can be drawn anywhere else.
|
||||
|
||||
The first is that the inheritance does not survive: a row is handed to Rich on its own,
|
||||
so a span that never mentions intensity is read against whatever the *previous row* left
|
||||
set. That is resolved by working the state out here and saying it outright.
|
||||
|
||||
The second is that **bold is not brightness everywhere**. It is on the PicoCalc console
|
||||
and on a DOS one; it is not on macOS Terminal, where bold asks for a heavier face and
|
||||
leaves the colour alone. There ``1;30`` is not dark grey but plain black — and this art
|
||||
leans on it, seventy-nine spans of the wide mark being bold-black, much of that on a
|
||||
black ground. The mark came out muted, and the ``░▒▓`` dithers that fade one colour into
|
||||
another faded toward the wrong end. So brightness is emitted as the colour it means:
|
||||
``9N`` (the aixterm bright bank), which needs no bold and is also how the PicoCalc's own
|
||||
console spells bright. Nothing about *which* colour is being asked for changes; only the
|
||||
spelling, from one a terminal may read as a font weight to one that can only be a colour.
|
||||
"""
|
||||
out: list[str] = []
|
||||
bright = False
|
||||
@@ -177,16 +189,32 @@ def _state_intensity(row: str) -> str:
|
||||
continue
|
||||
params = found.group()[2:-1]
|
||||
parts = params.split(";") if params else [""]
|
||||
for part in parts: # what this sequence leaves the intensity set to
|
||||
if part in ("", "0", "22"):
|
||||
bright = False
|
||||
elif part == "1":
|
||||
bright = True
|
||||
dim = any(_DIM_FG.fullmatch(p) for p in parts)
|
||||
if dim and not any(p in _SAYS_INTENSITY for p in parts):
|
||||
out.append("\x1b[" + ";".join(["1" if bright else "22"] + parts) + "m")
|
||||
# What this sequence leaves the intensity set to, for the spans that follow it.
|
||||
says = [p for p in parts if p in ("", "0", "1", "22")]
|
||||
for part in says:
|
||||
bright = part == "1"
|
||||
# Whether *this* sequence's own foreground is bright: what it says, else what stands.
|
||||
here = bright
|
||||
fg = next((p for p in parts if _DIM_FG.fullmatch(p)), None)
|
||||
if fg is None:
|
||||
# No foreground to restate. A bare "1" has nothing left to do once brightness
|
||||
# travels as a colour, and dropping it keeps bold off glyphs a terminal may
|
||||
# redraw at another weight; a reset still has to go through.
|
||||
kept = [p for p in parts if p != "1"]
|
||||
if kept:
|
||||
out.append("\x1b[" + ";".join(kept) + "m")
|
||||
else:
|
||||
out.append(found.group())
|
||||
rewritten = []
|
||||
for part in parts:
|
||||
if part == "1":
|
||||
continue # brightness is in the colour now
|
||||
if part == fg:
|
||||
rewritten.append(str(int(fg) + 60) if here else fg)
|
||||
else:
|
||||
rewritten.append(part)
|
||||
if not here and "22" not in rewritten:
|
||||
rewritten.insert(0, "22") # say dim outright; never inherit a bank
|
||||
out.append("\x1b[" + ";".join(rewritten) + "m")
|
||||
at = found.end()
|
||||
return "".join(out)
|
||||
|
||||
|
||||
@@ -504,6 +504,44 @@ def test_every_mark_is_as_wide_as_its_name_says() -> None:
|
||||
assert logo_width(_rows(name)) == declared, f"{name} is not {declared} cells wide"
|
||||
|
||||
|
||||
def test_the_mark_says_bright_as_a_colour_not_as_bold() -> None:
|
||||
"""No span of the wordmark depends on the terminal reading bold as brightness.
|
||||
|
||||
An art editor spells brightness the DOS way, ``1m`` lifting the foreground into the
|
||||
bright bank. That is true of the PicoCalc console and of a DOS one -- and false on
|
||||
macOS Terminal, where bold asks for a heavier face and leaves the colour alone. There
|
||||
``1;30`` is not dark grey but plain black, and the wide mark carries seventy-nine such
|
||||
spans, much of it on a black ground: the mark drew muted, and the dithers that fade one
|
||||
colour into another faded toward the wrong end. So the loader emits the bright bank as
|
||||
the colour it means (``9N``), which cannot be mistaken for a font weight.
|
||||
"""
|
||||
import re
|
||||
|
||||
from meshterm.ui.logo import _NAMED_WIDTH, _rows, _variants, logo_width
|
||||
|
||||
sgr = re.compile(chr(27) + r"\[([0-9;]*)m")
|
||||
for name in _variants():
|
||||
rows = _rows(name)
|
||||
codes = [m.group(1) for row in rows for m in sgr.finditer(row)]
|
||||
assert codes, f"{name} carries no colour at all"
|
||||
|
||||
params = [p for code in codes for p in code.split(";")]
|
||||
# Nothing asks for bold: brightness travels as 90-97 instead.
|
||||
assert "1" not in params, f"{name} still leans on bold for brightness"
|
||||
assert any(p.isdigit() and 90 <= int(p) <= 97 for p in params), (
|
||||
f"{name} lost its bright spans entirely"
|
||||
)
|
||||
# A foreground on the dim bank still says so outright, so it cannot inherit a bank
|
||||
# from whatever the row above left set (each row reaches Rich on its own).
|
||||
for code in codes:
|
||||
parts = code.split(";")
|
||||
if any(re.fullmatch(r"3[0-7]", p) for p in parts):
|
||||
assert "22" in parts, f"{name} has a dim foreground that never says so: {code}"
|
||||
|
||||
# And the spelling change moves no cells: the art measures exactly as it did.
|
||||
assert logo_width(rows) == int(_NAMED_WIDTH.search(name).group(1))
|
||||
|
||||
|
||||
def test_the_mark_the_console_picks_stays_inside_its_font() -> None:
|
||||
"""The wordmark obeys the glyph contract every other screen does.
|
||||
|
||||
|
||||
Reference in new issue
Block a user