gfx: one glyph blitter, and a terminal cell is a surface
Gate 0's last item, "delete the cell grid" -- done as far as it should be, and the rest of it retired, which is the part worth explaining. include/text.h made the case against the grid in four charges: it cannot do variable-width glyphs, cannot position text off a multiple of eight, cannot anti-alias, and cannot hold a codepoint above 255. Every one of those was about the *drawing layer*, and every one is now false -- glyphs carry metrics, PSOGM positions text at arbitrary pixels, the TrueType path blends 8-bit coverage, and vtcell.ch is a uint32. What is left is a grid in vt.c, and deleting that would not modernise the console; it would stop it being a terminal. VT100 escapes address columns, TIOCGWINSZ reports rows and columns, and every program that draws a box assumes both. So the item is checked with its remainder rewritten to say what was actually wrong, rather than ticked as if the original wording had been carried out. **What was actually wrong was the duplicate.** gfx.c walked font_data and blitted glyphs its own way; text.c did the same job into a struct surface, for no caller but a sysrq self-test. Two implementations of bearings, coverage and clipping, which had to agree about a cell size only one of them was told had changed -- and they did not agree, which is why every line of PSOGM once drew the next character's bitmap underneath itself. There is one now, and the mechanism is the pleasing part: the console hands text_draw_glyph() **the cell as a surface of its own** -- same pixels, same stride, origin moved and bounds set to that cell. Clipping a tall ascender to its line is then the same bounds check that clips to the edge of a screen, and there is no second notion of clipping in the tree. `surface_sub()` is six lines and replaced fourteen of hand-written comparisons. The bitmap is reached through font_builtin() like any other provider, so the early console and the real one are one path with different metrics, and the `if (!cfont)` branch that walked the array is gone. gfx.c no longer includes font.h; text.c does, being the only file left that reads it -- which also retires the note in text.c explaining why it could not. struct surface gained a bpp, because gfx_draw_pixel handles 16, 24 and 32 and whatever replaces it has to as well. Zero means 32: a UEFI GOP has no other format and the loader publishes 32 unconditionally, so callers that do not care say nothing. One behaviour change, and it is the documented one: a codepoint the font cannot draw is now a substituted glyph rather than a blank cell. text.h argues for that directly -- "a missing glyph that draws nothing makes text silently shorter and the fault impossible to see". Verified by screendump: the console renders correctly, PSOGM renders correctly, and `echo t > /proc/sysrq` still draws its specimen through the surface path with the back buffer at 32bpp. Both supported configurations: one boot each, no traps, no panics, socktest and memfdtest green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
d85274dbd9
commit
c84d06c5b1
6 changed files with 183 additions and 72 deletions
|
|
@ -301,6 +301,35 @@ implausible size, no memory, a short read, or a file that will not parse. The
|
|||
last of those says so in the log, because a font that silently did not load
|
||||
looks exactly like a font that did.
|
||||
|
||||
### One glyph blitter, and a cell is a surface
|
||||
|
||||
`gfx.c` used to walk `font_data` and blit glyphs itself, while `text.c` did the
|
||||
same job into a `struct surface` for no caller but a self-test. Two
|
||||
implementations of the hardest small thing in a renderer — bearings, coverage,
|
||||
clipping — that had to agree about a cell size only one of them was told had
|
||||
changed. They did not agree, and every line of PSOGM drew the next character's
|
||||
bitmap underneath itself.
|
||||
|
||||
There is one now. The console hands `text_draw_glyph()` **the cell as a
|
||||
surface of its own**: same pixels, same stride, origin moved and bounds set to
|
||||
that one cell. Clipping a tall ascender to its line is then the same bounds
|
||||
check that clips to the edge of a screen, and there is no second idea of
|
||||
clipping anywhere in the tree.
|
||||
|
||||
The bitmap font is reached through `font_builtin()` like any other provider,
|
||||
so the early console and the real one are one code path with different
|
||||
metrics. `gfx.c` does not include `font.h` any more; `text.c` does, being the
|
||||
only file that reads the array.
|
||||
|
||||
`struct surface` gained a `bpp` for this, because `gfx_draw_pixel` handles 16,
|
||||
24 and 32 and a renderer replacing it had to as well. Zero means 32, which is
|
||||
what a UEFI GOP always is and what the loader publishes unconditionally.
|
||||
|
||||
**What is still a grid is `vt.c`**, and that is not a leftover. A terminal *is*
|
||||
rows and columns: VT100 escapes address them, `TIOCGWINSZ` reports them, and
|
||||
every program that draws a box assumes both. The grid that was in the way was
|
||||
the one in the *drawing* layer, and it is gone.
|
||||
|
||||
### The TrueType rasteriser
|
||||
|
||||
`kernel/dev/ttf.c`: `glyf` outlines, composite glyphs with their component
|
||||
|
|
|
|||
|
|
@ -252,10 +252,33 @@ These are the galling ones — the replacement exists, is tested, and is unused.
|
|||
was **one byte** holding a CP437 index, so `Ą` (U+0104) could not be
|
||||
*stored*, whatever was drawing it. The cell is a `uint32` codepoint now
|
||||
and the cell size comes from the font's measured advance.
|
||||
- [ ] **Delete the cell grid.** The other half of the original item, and still
|
||||
open. The console is a fixed grid of codepoints; `text.c`'s proportional
|
||||
path has no caller. Nothing needs this before the compositor, which is
|
||||
why it is separated from the row above rather than left blocking it.
|
||||
- [x] ~~**Delete the cell grid.**~~ Done as far as it should be done, and the
|
||||
rest of it retired — which needs explaining, because the item as written
|
||||
asked for something a terminal cannot be.
|
||||
|
||||
`include/text.h` made the case against the grid in four charges: it
|
||||
cannot do variable-width glyphs, cannot position text off a multiple of
|
||||
eight, cannot anti-alias, and cannot hold a codepoint above 255. **All
|
||||
four were about the drawing layer, and all four are now false** — glyphs
|
||||
carry metrics, PSOGM positions text at arbitrary pixels, the TrueType
|
||||
path blends 8-bit coverage, and `vtcell.ch` is a `uint32`.
|
||||
|
||||
What is left is a grid in `vt.c`, and that one is not in the way: it is
|
||||
what a terminal *is*. VT100 escapes address columns, `TIOCGWINSZ`
|
||||
reports rows and columns, and every program that draws a box assumes
|
||||
both. Deleting it would not modernise the console, it would stop it
|
||||
being a terminal.
|
||||
|
||||
So the real remainder was the duplicate: `gfx.c` walked `font_data`
|
||||
itself and blitted glyphs its own way, while `text.c` did the same job
|
||||
into a `struct surface` for nobody but a self-test. Two implementations
|
||||
that had to agree about a cell size only one of them was told had
|
||||
changed — and they did not agree, which is why every line of PSOGM once
|
||||
drew the next character's bitmap underneath itself. There is one blitter
|
||||
now: `gfx.c` hands `text_draw_glyph` the cell *as a surface of its own*,
|
||||
so clipping a tall glyph to its line is the same bounds check that clips
|
||||
to a screen. The bitmap is reached through `font_builtin()` like any
|
||||
other provider, and `gfx.c` no longer includes `font.h`.
|
||||
- [x] ~~**Load a font from disk**~~ and point the console at it. The built-in
|
||||
one is linked in on purpose — an early panic has to be readable — so this
|
||||
is about a *replaceable* font, not about having one. Drop a TrueType file
|
||||
|
|
|
|||
Loading…
Reference in a new issue