FontStashSharp / FontStashSharp

C# port of https://github.com/memononen/fontstash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Text not stop smoothing!

MrScautHD opened this issue · comments

Its a MonoGame Bug but i would like to see this lib fix it!
MonoGame/MonoGame#7065

Try setting FontSystemSettings.PremultiplyAlpha to false.

grafik

With FontSystemSettings.PremultiplyAlpha to false.

grafik

(I used Paint.net to zoom in)

Also you could try playing with different BlendStates that are passed to SpriteBatch.Begin

ok that did work but it still smooth

We have this exact problem as well. BlendStates did not fix the issue.

This is with blendState: BlendState.AlphaBlend & PremultiplyAlpha = true
image

This is with blendState: BlendState.NonPremultiplied & PremultiplyAlpha = false
image

We're using FontResolutionFactor = 4f. This applies to all images above.

If we set it back to the default (1f), the issue is still present (and small text is obviously very blurry):
image
image

Is there a way to just let pixelart fonts be pixel-perfect without having blurry edges?

Edit: Increasing the FontResolutionFactor to extreme values such as 32f didn't resolve the issue either. It looks better, but the antialiasing is still there.

What about samplerState: SamplerState.PointWrap or samplerState: SamplerState.PointClamp?

Disabling everything I could think of that would be manipulating the drawing, this was as far as I can get.

point

So far as I can tell, the default rasterization adds 1 layer pixel of AA, regardless of size. I suspect the reason raising your resolution factor might help is because that 1 pixel layer is getting increasingly crushed out by its surroundings. Otherwise, if you truly want pixel perfect, you'd probably want a resolution factor of 1.

You could look at custom a rasterizer and see if they do any better https://github.com/FontStashSharp/FontStashSharp/wiki/Custom-Font-Rasterizer

Or use a StaticSpriteFont with BMFont data. That should get you your pixel perfect fonts, however it might not be viable depending on how and for what reason you're using FontStashSharp.

I played a bit with stb_truetype compiled with STBTT_RASTERIZER_VERSION set to 1(see this for more info).
However it didnt help. The old rasterizer does the anti-aliasing too. And generally it seems to produce similar result as the new rasterizer.

So, I agree with the previous poster. There are two ways to get rid of anti-aliasing:

  1. Use different rasterizer.
  2. Use StaticSpriteFont.

Actually, on the second thought, this might solve the problem: https://github.com/FontStashSharp/FontStashSharp/releases/tag/1.3.4