| 565 | } |
| 566 | |
| 567 | static int MeasureBitmappedWidth(const struct DrawTextArgs* args) { |
| 568 | int i, point = args->font->size; |
| 569 | int xPadding, width; |
| 570 | cc_string text; |
| 571 | |
| 572 | if (!fontBitmap.scan0) return FallbackFont_TextWidth(args); |
| 573 | |
| 574 | /* adjust coords to make drawn text match GDI fonts */ |
| 575 | xPadding = Drawer2D_XPadding(point); |
| 576 | width = 0; |
| 577 | |
| 578 | text = args->text; |
| 579 | for (i = 0; i < text.length; i++) { |
| 580 | char c = text.buffer[i]; |
| 581 | if (c == '&' && Drawer2D_ValidColorCodeAt(&text, i + 1)) { |
| 582 | i++; continue; /* skip over the color code */ |
| 583 | } |
| 584 | width += Drawer2D_Width(point, c) + xPadding; |
| 585 | } |
| 586 | if (!width) return 0; |
| 587 | |
| 588 | /* Remove padding at end */ |
| 589 | if (!(args->font->flags & FONT_FLAGS_PADDING)) width -= xPadding; |
| 590 | |
| 591 | if (args->useShadow) { width += Drawer2D_ShadowOffset(point); } |
| 592 | return width; |
| 593 | } |
| 594 | |
| 595 | void Context2D_DrawText(struct Context2D* ctx, struct DrawTextArgs* args, int x, int y) { |
| 596 | struct Bitmap* bmp = (struct Bitmap*)ctx; |
no test coverage detected