| 411 | } |
| 412 | |
| 413 | RectF TextPainter::doRenderLine(StringView text, TextPositioning const& position, bool reallyRender, unsigned* charLimit) { |
| 414 | if (m_reloadTracker->pullTriggered()) |
| 415 | reloadFonts(); |
| 416 | TextPositioning pos = position; |
| 417 | |
| 418 | |
| 419 | if (pos.hAnchor == HorizontalAnchor::RightAnchor) { |
| 420 | StringView trimmedString = charLimit ? text.substr(0, *charLimit) : text; |
| 421 | pos.pos[0] -= stringWidth(trimmedString); |
| 422 | pos.hAnchor = HorizontalAnchor::LeftAnchor; |
| 423 | } else if (pos.hAnchor == HorizontalAnchor::HMidAnchor) { |
| 424 | StringView trimmedString = charLimit ? text.substr(0, *charLimit) : text; |
| 425 | pos.pos[0] -= floor((float)stringWidth(trimmedString) / 2); |
| 426 | pos.hAnchor = HorizontalAnchor::LeftAnchor; |
| 427 | } |
| 428 | |
| 429 | String escapeCode; |
| 430 | RectF bounds = RectF::withSize(pos.pos, Vec2F()); |
| 431 | Text::TextCallback textCallback = [&](StringView text) { |
| 432 | for (String::Char c : text) { |
| 433 | if (charLimit) { |
| 434 | if (*charLimit == 0) |
| 435 | return false; |
| 436 | else |
| 437 | --*charLimit; |
| 438 | } |
| 439 | RectF glyphBounds = doRenderGlyph(c, pos, reallyRender); |
| 440 | bounds.combine(glyphBounds); |
| 441 | pos.pos[0] += glyphBounds.width(); |
| 442 | } |
| 443 | return true; |
| 444 | }; |
| 445 | |
| 446 | Text::CommandsCallback commandsCallback = [&](StringView commands) { |
| 447 | applyCommands(commands); |
| 448 | return true; |
| 449 | }; |
| 450 | |
| 451 | m_fontTextureGroup.switchFont(m_renderSettings.font); |
| 452 | Text::processText(text, textCallback, commandsCallback); |
| 453 | |
| 454 | return bounds; |
| 455 | } |
| 456 | |
| 457 | RectF TextPainter::doRenderGlyph(String::Char c, TextPositioning const& position, bool reallyRender) { |
| 458 | if (c == '\n' || c == '\v' || c == '\r') |
nothing calls this directly
no test coverage detected