solenum/msdf-c

Improving the quality of small text

Opened this issue · 1 comments

Hey,
I'm using an almost identical version of main.c but with the following changes:

  char fontdefault[] = "hiragino-kaku-gothic-pron-w3.otf";
  int size_sdf = 50;
  int size_bitmap = 14;

  char *c     = "あ";
  char *out   = "out.png";
  char *fontf = fontdefault;

The result is pretty blurry:
msdf_out
out

I tried setting size_sdf to smaller values like 14 but the quality is still not too great:
msdf_out
out

Perhaps I'm doing something wrong. How can I improve the result?

Hi,

I'm sorry I'm not really around at the moment so I can't take a proper look at this, but I've found that the clarity and sharpness of the resulting rendered glyph also largely depends on how you utilize the msdf to render the text.

Here is an example of usage, where the resulting rendered text is pretty good looking at even small sizes.

Also keep in mind that the glyph size of the msdf bitmap shouldn't be pushed too small, I'd personally stick to ~32x32 or so, anything smaller and the quality starts to decline pretty quickly.

I think this was done using a 32x32 msdf glyph size.
https://i.imgur.com/MXTKOYV.mp4

https://github.com/solenum/exengine/blob/master/src/exengine/data/shaders/text.glsl
https://github.com/solenum/exengine/blob/master/src/exengine/render/text.c#L73
https://github.com/solenum/exengine/blob/master/src/exengine/render/text.c#L145

Personal note - I think this is a really janky implementation, and I wouldn't really use this for production. if you can afford it, then I recommend using Viktor Chlumský.'s implementation to pre-generate the msdf bitmap. If you do this and find that you're still getting blurry text, then I guess the issue is further down your rendering pipeline.