MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / FallbackFont_DrawText

Function FallbackFont_DrawText

src/SystemFonts.c:216–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216void FallbackFont_DrawText(struct DrawTextArgs* args, struct Bitmap* bmp, int x, int y, cc_bool shadow) {
217 cc_string left = args->text, part;
218 int size = args->font->size;
219 int scale = FallbackFont_GetScale(size);
220 char colorCode = 'f';
221 const cc_uint8* rows;
222 BitmapCol color;
223 int i;
224
225 if (shadow) {
226 x += 1 * scale;
227 y += 1 * scale;
228 }
229
230 /* adjust coords to make drawn text match GDI fonts */
231 y += (args->font->height - size) / 2;
232
233 while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
234 {
235 color = Drawer2D_GetColor(colorCode);
236 if (shadow) color = GetShadowColor(color);
237
238 for (i = 0; i < part.length; i++)
239 {
240 cc_uint8 c = part.buffer[i];
241 if (c == ' ') { x += SPACE_WIDTH * scale; continue; }
242
243 rows = FallbackFont_GetRows(c);
244
245 Fallback_DrawCell(bmp, x, y, scale, rows, color);
246 x += Fallback_CellWidth(rows) * scale;
247 }
248 }
249}
250
251static void Fallback_PlotCell(int scale, const cc_uint8* rows, FallbackFont_Plotter plotter, void* ctx) {
252 int xx, srcX, dstX;

Callers 2

SysFont_DrawTextFunction · 0.85
DrawBitmappedTextFunction · 0.85

Calls 4

Drawer2D_UNSAFE_NextPartFunction · 0.85
GetShadowColorFunction · 0.85
Fallback_DrawCellFunction · 0.85
Fallback_CellWidthFunction · 0.85

Tested by

no test coverage detected