MCPcopy Create free account
hub / github.com/defold/defold / FontDebug

Function FontDebug

engine/font/src/font.cpp:205–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205void FontDebug(HFont hfont, float scale, float padding, const char* text)
206{
207 int indent = 0;
208
209 FontType type = FontGetType(hfont);
210 printf("DebugFont: '%s' type: %d\n", FontGetPath(hfont), type);
211
212 Indent(indent+1); printf("ascent: %.3f\n", FontGetAscent(hfont, scale));
213 Indent(indent+1); printf("descent: %.3f\n", FontGetDescent(hfont, scale));
214 Indent(indent+1); printf("line gap: %.3f\n", FontGetLineGap(hfont, scale));
215 printf("\n");
216
217 FontGlyphOptions options;
218 options.m_Scale = scale;
219 options.m_GenerateImage = true;
220
221 options.m_StbttSDFPadding = padding;
222 const char* cursor = text;
223 uint32_t codepoint = 0;
224 while ((codepoint = dmUtf8::NextChar(&cursor)))
225 {
226 FontGlyph glyph;
227 FontGetGlyph(hfont, codepoint, &options, &glyph);
228 FontDebugGlyph(&glyph, indent+2);
229
230 if (options.m_GenerateImage && (type == FONT_TYPE_STBTTF || type == FONT_TYPE_STBOTF))
231 {
232 if(glyph.m_Bitmap.m_Data)
233 {
234 Indent((indent+3)); printf("Bitmap: %u x %u x %u flags: %u\n",
235 glyph.m_Bitmap.m_Width, glyph.m_Bitmap.m_Height, glyph.m_Bitmap.m_Channels, glyph.m_Bitmap.m_Flags);
236 FontDebugPrintBitmap(glyph.m_Bitmap.m_Data, glyph.m_Bitmap.m_Width, glyph.m_Bitmap.m_Height);
237 }
238 }
239
240 FontFreeGlyph(hfont, &glyph);
241 }
242}

Callers

nothing calls this directly

Calls 11

FontGetTypeFunction · 0.85
FontGetPathFunction · 0.85
IndentFunction · 0.85
FontGetAscentFunction · 0.85
FontGetDescentFunction · 0.85
FontGetLineGapFunction · 0.85
NextCharFunction · 0.85
FontGetGlyphFunction · 0.85
FontDebugGlyphFunction · 0.85
FontDebugPrintBitmapFunction · 0.85
FontFreeGlyphFunction · 0.85

Tested by

no test coverage detected