aboutsummaryrefslogtreecommitdiffstats
path: root/symbols/symbols-gl.c
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-27 14:54:53 +0100
committereunhhu <[email protected]>2026-09-27 14:54:53 +0100
commit993871c6dfa19cf4e0bd4a16c9aad26cb0025d70 (patch)
treea83e5bc75d859ca5bee96b26700a9419e687cd1a /symbols/symbols-gl.c
parent2c1e29780da41bba13ac84ad01472d550e6d02e8 (diff)
downloadvega-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-gl.c')
-rw-r--r--symbols/symbols-gl.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/symbols/symbols-gl.c b/symbols/symbols-gl.c
index c1ce64e..d91a5dc 100644
--- a/symbols/symbols-gl.c
+++ b/symbols/symbols-gl.c
@@ -87,14 +87,6 @@ bool vega_gl_open(VegaGl *gl, char *error, size_t error_size) {
return true;
}
-/* The pixels a symbol reaches at scale, one more on each side. */
-static VegaPlace place_of(const VegaSymbol *symbol, float scale) {
- if (!symbol->count) return (VegaPlace){0};
- int left = (int)floorf(symbol->left * scale) - 1, right = (int)ceilf(symbol->right * scale) + 1;
- int top = (int)ceilf(symbol->top * scale) + 1, bottom = (int)floorf(symbol->bottom * scale) - 1;
- return (VegaPlace){0, 0, right - left, top - bottom, left, top};
-}
-
bool vega_gl_atlas(VegaGl *gl, const VegaSymbols *s, float scale, const uint32_t *wanted, uint32_t count, VegaAtlas *out,
char *error, size_t error_size) {
(void)gl;
@@ -112,7 +104,7 @@ bool vega_gl_atlas(VegaGl *gl, const VegaSymbols *s, float scale, const uint32_t
uint32_t index = wanted ? wanted[i] : i;
if (index >= s->symbols) continue;
VegaSymbol symbol = vega_symbol_at(s, index);
- VegaPlace p = place_of(&symbol, scale);
+ VegaPlace p = vega_symbol_place(&symbol, scale);
area += (uint64_t)p.width * (uint64_t)p.height;
}
int width = 64;
@@ -122,7 +114,7 @@ bool vega_gl_atlas(VegaGl *gl, const VegaSymbols *s, float scale, const uint32_t
uint32_t index = wanted ? wanted[i] : i;
if (index >= s->symbols) continue;
VegaSymbol symbol = vega_symbol_at(s, index);
- VegaPlace p = place_of(&symbol, scale);
+ VegaPlace p = vega_symbol_place(&symbol, scale);
if (!p.width) continue;
if (p.width > width) width = p.width;
if (x + p.width > width) { x = 0; y += shelf; shelf = 0; }