Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Very cool, how are you handling glyphs? Do you have an LRU font cache or something simpler?


Glyphs are rasterized once and stored in a texture atlas. When rendering a glyph, the fragment shader pulls from that texture. Once loaded, the glyph stays loaded for the duration of the program.


Got it, just a heads-ups that texture atlas tends to hammer your GPU texture upload if you want to support UTF or non-latin(esp glyph-based) character sets.

Not trying to be discouraging just something to keep in mind if that's a direction you want to go. Pretty excited to see a GPU + Rust based stuff making it out into the wild.


Question:

With a modern discrete GPU card wouldn't the texture atlas just end up in it's VRAM as cards these days commonly have >1GB of VRAM?

(Sorry if this is a stupid question, still trying to grok opengl)


Sure, but you're either going to have to generate the whole font up-front(can be many thousand characters) or you need to re-upload as you use/generate new characters which can thrash unless you're very careful about the regions you lock(and you have a driver that behaves appropriately).

Most font renderers I know do a tiered LRU cache of 3-4 texture "pages" which hurts your drawcall batching but tends to be a nice tradeoff in texture usage.


Okay so I dug into this. There is a font cache on the GPU and another in CPU ram. I believe it will fall into the drawcall batching issue you are concerned about... but terminals don't need to get >60FPS in most cases.


You really have nothing better to render on your GPU and store in that video memory than your terminal? I also use a web browser, and feel like it could use a performance boost a lot more than my terminal (particularly as I don't actually believe that using textures in this way is actually the most efficient way to render fonts with OpenGL).


What's your currently preferred way to render text with OpenGL?


There's Distance Fields[1] and Loop-Blinn[2] aside from standard textures that I'm aware of.

Valve uses the first, very few people use the second because of patent issues. They're more computationally expensive in some cases so there's always tradeoffs to be made depending on your hardware.

[1] - http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_...

[2] - http://http.developer.nvidia.com/GPUGems3/gpugems3_ch25.html


Any idea how much memory it takes to store the full atlas for a font with full Unicode/emoji support? Also does it work for colored emoji?


~95k UTF characters x font sizes x font styles(bold, italic, etc) x outline size.

It's pretty large.


Don't combining characters, ligatures or scripts that fuse characters lead to a combinatorical explosion?

can it handle zalgo?


Terminal emulators tend to prefer fixed-width fonts so you don't really have to worry about those too much.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: