2 skye_r:
Thanks, I was thinking in the same direction but was looking into ability of STB to do subpixel rendering. Haven't had the chance yet to read about it. I'll try to apply your advice somehow because it definitely feels like a fraction of the pixel. If I expand the width or height of the bitmap even by one pixel I get artefacts in a form of next glyph's contours showing through on the right or on the bottom.
2 mrmixer:
Thanks for advice. I was just looking into the idea of writing out the image into file to see how it looks outside of the rendering engine.
was that you need to render glyphs at a higher resolution that the glyphs display resolution and not do srgb convertion.
What is higher resolution in this case? Right now it's baked into the asset file, the font is scaled to a height of 128.0f pixels (64.0f in my case) and rendered as is inside the actual game. FontScale is set to 1.0f and it is multiplied by width or height of the actual bitmap which is taken out of stb's functions when packing the asset file (see the gist snippet above).
EDIT: Actually, this is a great idea. I scale the glyph to the original size from the video (i.e. to 128 pixels), but apply 0.5 scale instead, looks much nicer and no artefacts!
https://gyazo.com/ccb2a2093f87a5d75399fb0328147ddb Now I only have to figure out the clipping :)
Regarding stbtt_GetCodepointBitmapBox and stbtt_GetCodepointBox, I don't get what is the difference, to be honest.
Here's debug info for stbtt_GetCodepointBox
| X0: 1
X1: 30
Y0: -10
Y1: 24
|
and for stbtt_GetCodepointBitmapBox
| cX0: 1
cX1: 31
cY0: -25
cY1: 11
|
Why the Y's are inverted and why the numbers differ slightly?
I've tried using stbtt_MakeCodepointBitmap but haven't figured out how to do it properly. The best I got is that for each glyph it was rendered four times into bitmap, probably because stb returns an 8 bit bitmap and the resulting bitmap is 4 bytes per pixel. But I didn't spend much time with it yet.