diff options
| author | eunhhu <[email protected]> | 2026-09-27 14:54:53 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-27 14:54:53 +0100 |
| commit | 993871c6dfa19cf4e0bd4a16c9aad26cb0025d70 (patch) | |
| tree | a83e5bc75d859ca5bee96b26700a9419e687cd1a /symbols/symbols.h | |
| parent | 2c1e29780da41bba13ac84ad01472d550e6d02e8 (diff) | |
| download | vega-993871c6dfa19cf4e0bd4a16c9aad26cb0025d70.tar.gz vega-993871c6dfa19cf4e0bd4a16c9aad26cb0025d70.zip | |
Draw the TUI's cells as pixels with the symbols' glyphs
vega pixels runs the same scripts as tui --dump and writes each frame as
an image: the view's cells (only those on screen are evaluated) become
glyphs, each drawn once per size with the exact area of its curves, in its
tone's colour on its row's background. No page, no scene in between. A
1920x1350 grid takes 12 ms a frame here, writing the image included.
Symbol files carry the font's line now (format 3: ascent and descent where
format 2 kept zeros), the cell height and baseline; and the build tool takes
fonts in order, later ones filling the codes earlier ones lack: a CJK font
alone drew ambiguous-width arrows two cells wide in a one-cell grid, which
the new check caught, so a monospace Latin font comes first and Hangul after.
Diffstat (limited to 'symbols/symbols.h')
| -rw-r--r-- | symbols/symbols.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/symbols/symbols.h b/symbols/symbols.h index 20fbd22..0af3412 100644 --- a/symbols/symbols.h +++ b/symbols/symbols.h @@ -23,7 +23,8 @@ typedef struct { typedef struct { const unsigned char *bytes; size_t size; - uint16_t units; /* per em */ + uint16_t units; /* per em */ + int16_t ascent, descent; /* a font's line, in units from the baseline, y up (0 and 0 for icons) */ uint32_t symbols, points; } VegaSymbols; @@ -35,7 +36,7 @@ bool vega_symbols_open(VegaSymbols *, const unsigned char *bytes, size_t size, c /* The symbol of code (a binary search), or false. */ bool vega_symbol(const VegaSymbols *, uint32_t code, VegaSymbol *out); VegaSymbol vega_symbol_at(const VegaSymbols *, uint32_t index); -VegaPoint vega_point(const VegaSymbols *, uint32_t index); +VegaPoint vega_symbols_point(const VegaSymbols *, uint32_t index); /* The curve that point index of symbol begins, if any: an off point is the * control of one, and an on point followed by another on point in the same * contour starts a line. Every curve of a symbol is had once this way, from @@ -47,9 +48,24 @@ uint32_t vega_symbol_curves(const VegaSymbols *, const VegaSymbol *, VegaCurve * /* The coverage (0 to 1) of the pixel whose center is (x, y) in units, at * scale pixels per unit: the exact area the curves' outline covers. */ double vega_coverage(const VegaCurve *, uint32_t count, double scale, double x, double y); +/* The pixels a symbol reaches at scale (pixels per unit), one more on each + * side: width and height, and the offset of the box's top left from the + * symbol's origin (right, up). x and y are where a set of bitmaps (an atlas) + * keeps it. A symbol with nothing to draw has an empty box. */ +typedef struct { int32_t x, y, width, height, left, top; } VegaPlace; +VegaPlace vega_symbol_place(const VegaSymbol *, float scale); /* width x height 8-bit coverage, rows top first, stride bytes apart; pixel * (i, j) has its center at (left + (i + 0.5) / scale, top - (j + 0.5) / scale) * in units. */ void vega_symbol_raster(const VegaSymbols *, const VegaSymbol *, double scale, double left, double top, int width, int height, unsigned char *out, size_t stride); + +/* Symbols drawn once at one scale and kept, for surfaces that compose them + * on the CPU: each the first time it is asked for. */ +typedef struct { VegaPlace place; const unsigned char *pixels; } VegaBitmap; /* pixels: place.width per row */ +typedef struct VegaGlyphs VegaGlyphs; +VegaGlyphs *vega_glyphs_open(const VegaSymbols *, float scale); +/* The bitmap of code, or NULL when the file has no such symbol. */ +const VegaBitmap *vega_glyph(VegaGlyphs *, uint32_t code); +void vega_glyphs_close(VegaGlyphs *); #endif |
