Myra
Myra copied to clipboard
Feature Request: Scalable Vector Fonts/Images
Saving multiple bitmaps for different font sizes seems a sub-optimal solution. Sampling a single vector sheet, or at the very least down-scaling one largest-scale bitmap for fonts would be ideal
I second this. The FontStashSharp based text renderering easily fuzzy characters when there is font size scaling. Even a slightest scale causes significant fuzziness effect, compared to MonoGame's vanilla SpriteFont rendering.
example:
var fontSystem = FontSystemFactory.Create(GraphicsDevice, 128, 128);
fontSystem.AddFont(File.ReadAllBytes("Content/Fonts/m5x7.ttf"));
batch.DrawString(fontSystem.GetFont(13), new Vector2(0, 0), Color.White);
batch.DrawString(content.Load<SpriteFont>("Fonts/m5x7"), new Vector2(100, 0), Color.White);
Font source: https://managore.itch.io/m5x7
The problem is not only related with the pixel style font here, but also applies for non-pixel style font. Pixel font enlarges the problem. Also, the antialiased, fuzzy characters look better if the font size is set larger. (smaller size characters is more fuzzy)
In my case, I have to roll back to 1.0.3 to avoid text blurring. Maybe a temporary workaround is to make a SpriteFontBase implementation that use SpriteFont as Underlying text rendering utility, and let user choose between this implementation (for sharp text rendering) and DynamicSpriteFont (for dynamic font features).
Great work for FontStashSharp. I understand the convenience brought by a dynamic font rendering engine, especially for CJK characters. It would be even better if the rendering quality can also be improved on current base.
Unsure, if this fixes the case, however latest FontStashSharp allows to create SpriteFontBase from prerendered fonts: https://github.com/rds1983/FontStashSharp/wiki/Using-FontStashSharp-in-MonoGame,-FNA-or-Stride#staticspritefont
https://user-images.githubusercontent.com/23627133/108641550-0f95d880-74a0-11eb-9151-37ca43de8fa0.mp4
This is a somewhat tuned dynamic font system that can use different font sizes depending on scale, giving it extra crisp quality at most resolutions. This is not going through FontStashSharp but it shares the same underlying font renderer (StbTrueTypeSharp). What this says to me is that either Myra or FontStashSharp are not correctly tuned.
So to put it simply; this is not an issue with the font renderer (StbTrueTypeSharp) but by the usage of it, so it should be somewhat easy to fix (compared to replacing the dynamic runtime renderer with a completely different solution).
@TechnologicalPizza I'm trying to investigate the issue further, is it possible to share your code somehow so I can take a look into how you're solving the scaling problem?
@realvictorprm https://github.com/TechnologicalPizza/MonoGame/blob/0a5b4c226d61cabdb21373d00ed8d3ba453e977b/MonoGame.Testing/GamePLC.cs#L521 All the layout is done in this code block. The font rendering comes from my StbTrueTypeSharp fork. Cloning my MonoGame fork and pulling submodules should include most necessary files (possibly excluding some assets, not sure). I use my MonoGame.Testing project mostly as a playground so everything is extremely messy.
Thank you very much for sharing this @TechnologicalPizza, very much appreciated!