-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternative scalable font type? #1392
Comments
Original comment by Sasha Szpakowski (Bitbucket: slime73, GitHub: slime73). LÖVE can load BMFont files, and there are tools to produce BMFont glyph atlases which use signed distance fields for the glyphs. You can then write a shader which renders those. https://github.com/libgdx/libgdx/wiki/Distance-field-fonts It might be worth looking into making a shader included by default in LÖVE for that, although I'm not sure how useful that would be since typically you'd want to tailor things a bit to how your game is going to use the distance field font. Some documentation on the wiki about this would be good, in any case. |
Definite +1 here, I did search for SDF so missed this issue. Adding SDF to the comments so that it will be found for anyone else searching for that. |
The Unity engine does a good job at implementing SDF text rendering with its TextMesh Pro component. It might be a good reference implementation. It would be good if the render function allowed the font size to be specified each time |
All that you need is a shader that works with distance field font glyphs and a |
For now I've figured out you can use a simple shader that will use the antialiasing as a small section of a distance field, although it only works for upscaling: uniform float scl; // the scale factor you use to draw the text
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 sc) {
vec4 c = gammaToLinear(color);
float d = clamp(Texel(texture, tc).a * scl - 0.5 * scl + 0.5, 0.0, 1.0);
return linearToGamma(vec4(c.rgb, c.a * d));
} |
@Labrium it would be cool if you did open a PR for this :D I am still wanting this |
#1966 :) |
This is implemented now. |
Original report by jarodwright (Bitbucket: jarodwright, ).
Because fonts are rasterized, when applying a transform to a font it doesn't scale well like most other draw functions.
For performance reasons rasterizing should be kept, however I propose that an alternative dynamic font which renders characters each frame would be desirable for scaling text.
An argument against this would be that you shouldn't ever be drawing text to the world and should instead be drawing it to the UI at a screen position based on the world.
The text was updated successfully, but these errors were encountered: