gfx_text icon indicating copy to clipboard operation
gfx_text copied to clipboard

Use rusttype instead of freetype-rs

Open kvark opened this issue 9 years ago • 10 comments

See https://github.com/dylanede/rusttype

A pure Rust alternative to libraries like FreeType.

kvark avatar Feb 05 '16 17:02 kvark

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.

Kagami avatar Feb 05 '16 18:02 Kagami

No rush on this, of course, but I figured we need to have an issue at least to keep rusttype on our radars;)

kvark avatar Feb 05 '16 19:02 kvark

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

kvark avatar Mar 21 '16 13:03 kvark

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.

Kagami avatar Mar 21 '16 13:03 Kagami

@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.

dylanede avatar Mar 21 '16 17:03 dylanede

Is there any update on this?

aschuhardt avatar Mar 03 '17 02:03 aschuhardt

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

bvssvni avatar Mar 04 '17 16:03 bvssvni

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!

norru avatar Nov 29 '17 23:11 norru

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?

norru avatar Nov 29 '17 23:11 norru

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.

marek-g avatar Mar 12 '18 19:03 marek-g