mach: text rendering ECS module #877
Labels
No labels
CI
all
basisu
blog
bug
build
contributor-friendly
core
correctness
deferred
dev
direct3d-headers
docs
driver-os-issue
duplicate
dxcompiler
editor
examples
experiment
feature-idea
feedback
flac
freetype
gamemode
gkurve
glfw
gpu
gpu-dawn
harfbuzz
help welcome
in-progress
infrastructure
invalid
libmach
linux-audio-headers
long-term
mach
mach.gfx
mach.math
mach.physics
mach.testing
model3d
needs-triage
object
opengl-headers
opus
os/linux
os/macos
os/wasm
os/windows
package-manager
priority
proposal
proposal-accepted
question
roadmap
slipped
stability
sysaudio
sysgpu
sysjs
validating-fix
vulkan-zig-generated
wayland-headers
website
wontfix
wrench
www
x11-headers
xcode-frameworks
zig-update
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
hexops/mach#877
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There now exists a Text ECS module which is rather experienced/needs a lot of work.
Learnings
OpenType fonts are represented as a bunch of SFNT tables, which have (a) all the metadata needed for proper shaping/etc - and aside from that are just (b) the beziers making up glyphs.
We need (a) for proper unicode / text shaping support, and that makes up the majority of freetype (as a dependency)'s size. You also cannot separate harfbuzz from freetype, because SFNT tables are really what we would need to compose for harfbuzz. With the gkurve experiments experiments it seems likely we can render beziers directly, so if gkurve did have a font format of it's own it would look... exactly like (a) and (b), i.e. exactly how OpenType fonts (ttf and otf) look today. Thus, logically, we should just use those directly most likely. The only difference would be that TrueType Level 2 fonts can contain cubics, which we would need to convert to quadratics on-the-fly.. but that's not a big deal.
The downside is primarily browser support, though: when combined, harfbuzz and freetype dependencies are rather chunky and will suck in a WASM context. The developer of photopea.com for example has been using a WASM compilation of harfbuzz, but even as stripped-down/minimal as they could make it.. it's still the largest part of their application. Not great.
In a browser/WASM context, Ghostty takes a different approach here which we also planned to take: delegating to a HTML5-canvas-based backend for fonts, which seems logical and should be fine for us. The browser ships these font rendering stacks themselves, we just use their API for it. The downside with this approach is we cannot use gkurve/GPU-accelerated beziers for font rendering, because the browser APIs do not provide access to the underlying bezier information.
Decision
So we have a decision to make:
Option 0 is not great for Mach's goals of supporting browsers as a platform.
Option 2 necessitates having two entirely different text renderers / ECS modules entirely, which is a lot of added complexity. Additionally, it is likely there would be performance differences and characteristic differences between the two (you could rely on scalable text natively, but it'd be blurry in the browser - or you'd need to handle resizing rasterization via a platform-specific API.)
So really, we're asking: do we want two different text rendering stacks, one for native and one for web?
I think at this stage, we could do with less complexity & differences between platforms. Not just complexity we have to understand, but complexity our users would have to understand when e.g. writing shaders, too.
Decision: We won't use gkurve for font rendering for now. We'll have a very nice sprite-based texture-atlas text renderer that is integrated very nicely with the ECS, has good browser support, and call it a day for now.
Plan