| 382 | } |
| 383 | |
| 384 | RectF TextPainter::doRenderText(StringView s, TextPositioning const& position, bool reallyRender, unsigned* charLimit) { |
| 385 | Vec2F pos = position.pos; |
| 386 | if (s.empty()) |
| 387 | return RectF(pos, pos); |
| 388 | |
| 389 | List<StringView> lines = wrapTextViews(s, position.wrapWidth); |
| 390 | |
| 391 | TextStyle backup = m_savedRenderSettings = m_renderSettings; |
| 392 | int height = (lines.size() - 1) * backup.lineSpacing * backup.fontSize + backup.fontSize; |
| 393 | if (position.vAnchor == VerticalAnchor::BottomAnchor) |
| 394 | pos[1] += (height - backup.fontSize); |
| 395 | else if (position.vAnchor == VerticalAnchor::VMidAnchor) |
| 396 | pos[1] += (height - backup.fontSize) / 2; |
| 397 | |
| 398 | RectF bounds = RectF::withSize(pos, Vec2F()); |
| 399 | for (auto& i : lines) { |
| 400 | bounds.combine(doRenderLine(i, { pos, position.hAnchor, position.vAnchor }, reallyRender, charLimit)); |
| 401 | pos[1] -= m_renderSettings.fontSize * m_renderSettings.lineSpacing; |
| 402 | |
| 403 | if (charLimit && *charLimit == 0) |
| 404 | break; |
| 405 | } |
| 406 | |
| 407 | m_renderSettings = std::move(backup); |
| 408 | m_fontTextureGroup.switchFont(m_renderSettings.font); |
| 409 | |
| 410 | return bounds; |
| 411 | } |
| 412 | |
| 413 | RectF TextPainter::doRenderLine(StringView text, TextPositioning const& position, bool reallyRender, unsigned* charLimit) { |
| 414 | if (m_reloadTracker->pullTriggered()) |
nothing calls this directly
no test coverage detected