MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / processStringLiteral

Function processStringLiteral

src/openrct2/drawing/Drawing.String.cpp:619–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 }

Callers 2

processStringCodepointFunction · 0.85
processStringFunction · 0.85

Calls 10

drawStringRawSpriteFunction · 0.85
drawStringRawTTFFunction · 0.85
drawCharacterSpriteFunction · 0.85
valueMethod · 0.80
hasMethod · 0.65
endMethod · 0.65
beginMethod · 0.45
GetIndexMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected