| 617 | #endif // DISABLE_TTF |
| 618 | |
| 619 | static void processStringLiteral(RenderTarget& rt, std::string_view text, TextDrawInfo& info) |
| 620 | { |
| 621 | #ifndef DISABLE_TTF |
| 622 | bool isTTF = info.textDrawFlags.has(TextDrawFlag::ttf); |
| 623 | #else |
| 624 | bool isTTF = false; |
| 625 | #endif // DISABLE_TTF |
| 626 | |
| 627 | if (!isTTF) |
| 628 | { |
| 629 | drawStringRawSprite(rt, text, info); |
| 630 | } |
| 631 | #ifndef DISABLE_TTF |
| 632 | else |
| 633 | { |
| 634 | CodepointView codepoints(text); |
| 635 | std::optional<size_t> ttfRunIndex{}; |
| 636 | for (auto it = codepoints.begin(); it != codepoints.end(); it++) |
| 637 | { |
| 638 | auto codepoint = *it; |
| 639 | if (shouldUseSpriteForCodepoint(codepoint)) |
| 640 | { |
| 641 | if (ttfRunIndex.has_value()) |
| 642 | { |
| 643 | // Draw the TTF run |
| 644 | // This error suppression abomination is here to suppress |
| 645 | // https://github.com/OpenRCT2/OpenRCT2/issues/17371. Additionally, we have to suppress the error for |
| 646 | // the error suppression... :'-( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105937 is fixed in GCC13 |
| 647 | #if defined(__GNUC__) && !defined(__clang__) |
| 648 | #pragma GCC diagnostic push |
| 649 | #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" |
| 650 | #endif |
| 651 | auto len = it.GetIndex() - ttfRunIndex.value(); |
| 652 | drawStringRawTTF(rt, text.substr(ttfRunIndex.value(), len), info); |
| 653 | #if defined(__GNUC__) && !defined(__clang__) |
| 654 | #pragma GCC diagnostic pop |
| 655 | #endif |
| 656 | ttfRunIndex = std::nullopt; |
| 657 | } |
| 658 | |
| 659 | // Draw the sprite font glyph |
| 660 | drawCharacterSprite(rt, codepoint, info); |
| 661 | } |
| 662 | else |
| 663 | { |
| 664 | if (!ttfRunIndex.has_value()) |
| 665 | { |
| 666 | ttfRunIndex = it.GetIndex(); |
| 667 | } |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | if (ttfRunIndex.has_value()) |
| 672 | { |
| 673 | // Final TTF run |
| 674 | auto len = text.size() - *ttfRunIndex; |
| 675 | drawStringRawTTF(rt, text.substr(ttfRunIndex.value(), len), info); |
| 676 | } |
no test coverage detected