gfx_text
gfx_text copied to clipboard
Use rusttype instead of freetype-rs
See https://github.com/dylanede/rusttype
A pure Rust alternative to libraries like FreeType.
Are there any advantages except removing freetype dependency (which is rather inconvenient to setup properly on Windows)? Library looks too young yet. Though I have no objections if it works good with common ttf fonts.
No rush on this, of course, but I figured we need to have an issue at least to keep rusttype on our radars;)
Now that rusttype got gpu caching, it is twice as important to have some glue to it in order to encapsulate all the boiler plate. RustType has an example with glium, and you can see how much code could be saved there. cc @dylanede
Interesting. Though currently in gfx_text we create texture with all needed glyphs on initialization step (i.e. once at start before main loop), so this will probably require architecture changes.
@kvark A lot of the code in the example is probably analogous to existing code in gfx_text. Stuff like keeping track of which glyphs to draw, producing the quads to draw etc. There will need to be a wrapper around the caching mechanism itself though. You will need to decide how to handle exceptional conditions, like what to do if there's not enough room in the cache to fit all the required glyphs for the current frame. I've written up some information about the possible choices in the gpu_cache
module documentation.
I also plan to clean up the caching example to separate the stuff specific to caching from the stuff specific to rendering with glium.
Is there any update on this?
Should not be too hard. We have already ported the Piston 2D graphics backends to RustType. Example: https://github.com/PistonDevelopers/gfx_graphics/blob/master/src/glyph.rs
If it helps, I have replaced the low level gfx_text
debug with a full blown Conrod-based HUD in rust-oids. Conrod uses rusttype
to draw text, which is nice as I now have one fewer native lib to link in. Performance appears worse (not measured it, just perceptual) but given the simple stuff I'm drawing, shouldn't be much of a hassle. Simple debug text based on gfx_text
would be nice to re-add if and when the project switches to rusttype
as I pretty much will have that for free!
Rounding up on older posts on the matter. Is gfx_text
still recommended for simple text drawing, or it has been superseded by something rust-native and better?
rusttype
doesn't support font hinting yet. This makes glyphs look uglier for smaller sizes. Especially because of lack of vertical hinting. For example, the H
letter will have antialiased pixels at the top which is not the case for freetype
and fonts with hinting rules.