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

Function FallbackFont_TextWidth

src/SystemFonts.c:160–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160int FallbackFont_TextWidth(const struct DrawTextArgs* args) {
161 cc_string left = args->text, part;
162 int size = args->font->size;
163 int scale = FallbackFont_GetScale(size);
164 char colorCode = 'f';
165 int i, width = 0;
166
167 while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
168 {
169 for (i = 0; i < part.length; i++)
170 {
171 cc_uint8 c = part.buffer[i];
172 if (c == ' ') {
173 width += SPACE_WIDTH * scale;
174 } else {
175 width += Fallback_CellWidth(FallbackFont_GetRows(c)) * scale;
176 }
177 }
178 }
179
180 width = max(1, width);
181 if (args->useShadow) width += 1 * scale;
182 return width;
183}
184
185static void Fallback_DrawCell(struct Bitmap* bmp, int x, int y,
186 int scale, const cc_uint8* rows, BitmapCol color) {

Callers 2

SysFont_TextWidthFunction · 0.85
MeasureBitmappedWidthFunction · 0.85

Calls 2

Drawer2D_UNSAFE_NextPartFunction · 0.85
Fallback_CellWidthFunction · 0.85

Tested by

no test coverage detected