Is casey using st_truetype for text rendering the whole time?

Hey, im wondering if casey uses stb_truetype which he implements in E.163 until the the latest episode today,
does he use it both with the software renderer and the OpenGL hardware renderer?

If not, what does he use instead?


And also, casey says in E.163 that one should use the stbtt_BakeFontBitmap() API,
but sean barrett write's in his file that one shouldn't ship with that API.....??

1
2
3
//   Simple 3D API (don't ship this, but it's fine for tools and quick start)
//           stbtt_BakeFontBitmap()               -- bake a font to a bitmap for use as texture
//           stbtt_GetBakedQuad()                 -- compute quad to draw for a given char



So i guess one should use this API then..??

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//   Improved 3D API (more shippable):
//           #include "stb_rect_pack.h"           -- optional, but you really want it
//           stbtt_PackBegin()
//           stbtt_PackSetOversampling()          -- for improved quality on small fonts
//           stbtt_PackFontRanges()               -- pack and renders
//           stbtt_PackEnd()
//           stbtt_GetPackedQuad()
//
//   "Load" a font file from a memory buffer (you have to keep the buffer loaded)
//           stbtt_InitFont()
//           stbtt_GetFontOffsetForIndex()        -- indexing for TTC font collections
//           stbtt_GetNumberOfFonts()             -- number of fonts for TTC font collections
//
//   Render a unicode codepoint to a bitmap
//           stbtt_GetCodepointBitmap()           -- allocates and returns a bitmap
//           stbtt_MakeCodepointBitmap()          -- renders into bitmap you provide
//           stbtt_GetCodepointBitmapBox()        -- how big the bitmap must be
//
//   Character advance/positioning
//           stbtt_GetCodepointHMetrics()
//           stbtt_GetFontVMetrics()
//           stbtt_GetFontVMetricsOS2()
//           stbtt_GetCodepointKernAdvance()
//


Edited by C_Worm on
Hello,

Starting at the next episode (164), he reimplements what he did with stb_truetype with Windows' font API, since the goal is still to not use any external library at all (even though I remember him mentioning he may be more lax about it when developing tools as opposed to the game's executable).

He uses font-rendering in an offline tool to generate bitmap fonts as part of the assets, so there's no direct relation with his renderer when he does it. I stopped following around episode ~200, so I don't know how this has evolved since.

Edited by Guntha on
Okay cool, acutally, when i think about it, my question should rather be, how does he implements text with OpenGL ?? :)

As far as I know Casey still uses the Windows API to get font metrics and render the glyphs to a texture.

The rendering is the same in software and hardware renderers: you draw a rectangle with the glyph (character) bitmap you want to display, advance and draw the next glyph...

I think that the "simple" API gives less control on the quality of the font rendering and doesn't try to minimize the texture space, so the second API is recommended if that matters to you.