mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
add FontStylesScheme
This commit is contained in:
parent
b15725913e
commit
ce1e9f76cf
7 changed files with 83 additions and 17 deletions
|
|
@ -66,6 +66,8 @@ Label::Label(const std::wstring& text, std::string fontName)
|
|||
cache.update(this->text, multiline, textWrap);
|
||||
}
|
||||
|
||||
Label::~Label() = default;
|
||||
|
||||
glm::vec2 Label::calcSize() {
|
||||
auto font = cache.font;
|
||||
uint lineHeight = font->getLineHeight();
|
||||
|
|
@ -201,10 +203,10 @@ void Label::draw(const DrawContext* pctx, Assets* assets) {
|
|||
if (i < cache.lines.size()-1) {
|
||||
view = std::wstring_view(text.c_str()+offset, cache.lines.at(i+1).offset-offset);
|
||||
}
|
||||
font->draw(*batch, view, pos.x, pos.y + i * totalLineHeight);
|
||||
font->draw(*batch, view, pos.x, pos.y + i * totalLineHeight, styles.get());
|
||||
}
|
||||
} else {
|
||||
font->draw(*batch, text, pos.x, pos.y);
|
||||
font->draw(*batch, text, pos.x, pos.y, styles.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -239,3 +241,7 @@ void Label::setTextWrapping(bool flag) {
|
|||
bool Label::isTextWrapping() const {
|
||||
return textWrap;
|
||||
}
|
||||
|
||||
void Label::setStyles(std::unique_ptr<FontStylesScheme> styles) {
|
||||
this->styles = std::move(styles);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue