| 158 | } |
| 159 | |
| 160 | int 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 | |
| 185 | static void Fallback_DrawCell(struct Bitmap* bmp, int x, int y, |
| 186 | int scale, const cc_uint8* rows, BitmapCol color) { |
no test coverage detected