Arcan

Text Rendering Improvements
Login

Text Rendering Improvements

Improving Text Rendering

These are ongoing items and notes for improving text rendering improvements.

Glyph Atlas

With text raster context sharing / caching now working, the logical next step is expanding it with a texture backed vstore that builds an atlas, mainly for text_surface and external segments that has a tui backend but ideally also for render_text lookup since they share enough code for that to work.

We can then expand tui_raster_renderagp with a slicer that builds quads based on this and pushed into AGP as a list of quads to pack into one larger drawing operation. Since contexts are grouped based on size attributes, exotic packing tactics is likely not needed, and we can just flood-fill on power-of-two base texture and advance x,y with +w and increment y with +h when hitting the edge.

The quad generation should clip its texture coordinates as the surface bound and be able to handle an x,y offset so that we can later implement smooth scrolling animation.

With that in place we can use a reference vstore to slot in mSDFs to get cheap scalable rendering in both 2D and 3D as well as retaining the original maps for cheap fallbacks for glyphs that doesn't have a good SDF representation.

TPack Line attributes

The tpack format has attributes for switching between shaped, monospaced and other forms of rendered items, but are currently not in use. Extending text_surface to set line attributes only requires grabbing more attributes from the provided table, and an arcan_tui_rowattr(T, row, (struct tui_rowattr) to set

The bigger challenge here is that the client end resolves cursor actions, and respecting the cell attribute for 're-aligning'. For that the provisions are in place in frameserver.c:push_buffer to retrieve feedback of offsets from x=0 for each cell. This feedback buffer can then be read back after SIGVID unblocks (or on STEPFRAME event) and attached to the line attribute as an offset table, then on mouse/cursor action, walk this from left to right until the correct offset has been found.

Smoother Scrolling

There already is an arcan_tui_scrollhint to indicate that a specific region has shifted in one or both axes by n number of cells. This is enough to use the sliced renderer to clip/draw at an offset.

With that we can permit, server-side first, larger-than-surface tui context where you set an active viewport that can slide around. This permits bigger documents to be submitted in one go and just pan around.

Substitution and glyph- only tables.

Right now, target_fonthint sends the full truetype/opentype font and they get quite large. Since TUI clients doesn't raster themselves, much of the information in them is unnecessary. What we really want is an offline pass to extract the relevant tables (coverage, substitution etc.) for the client to avoid having a dependency to truetype and harfbuzz as well as making a12 initial setup quicker.