PistonDevelopers / gfx_text

Draw text for gfx using freetype
http://docs.piston.rs/gfx_text/gfx_text/
MIT License
22 stars 12 forks source link

Use rusttype instead of freetype-rs #38

Open kvark opened 8 years ago

kvark commented 8 years ago

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

A pure Rust alternative to libraries like FreeType.

Kagami commented 8 years ago

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.

kvark commented 8 years ago

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

kvark commented 8 years ago

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

Kagami commented 8 years ago

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.

dylanede commented 8 years ago

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

aschuhardt commented 7 years ago

Is there any update on this?

bvssvni commented 7 years ago

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

norru commented 6 years ago

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 commented 6 years ago

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?

marek-g commented 6 years ago

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.