MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / doRenderText

Method doRenderText

source/rendering/StarTextPainter.cpp:384–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382}
383
384RectF 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
413RectF TextPainter::doRenderLine(StringView text, TextPositioning const& position, bool reallyRender, unsigned* charLimit) {
414 if (m_reloadTracker->pullTriggered())

Callers

nothing calls this directly

Calls 4

switchFontMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
combineMethod · 0.45

Tested by

no test coverage detected