mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 22:11:51 +00:00
fix: missing font usage produces fatal error
This commit is contained in:
parent
5284d4acaa
commit
420d0daf28
3 changed files with 8 additions and 3 deletions
|
|
@ -9,8 +9,8 @@ class Font;
|
||||||
struct FontMetrics {
|
struct FontMetrics {
|
||||||
std::optional<std::weak_ptr<Font>> font;
|
std::optional<std::weak_ptr<Font>> font;
|
||||||
|
|
||||||
int lineHeight;
|
int lineHeight = 0;
|
||||||
int yoffset;
|
int yoffset = 0;
|
||||||
int _glyphInterval = 8;
|
int _glyphInterval = 8;
|
||||||
|
|
||||||
~FontMetrics();
|
~FontMetrics();
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,9 @@ uint Label::getLinesNumber() const {
|
||||||
void Label::draw(const DrawContext& pctx, const Assets& assets) {
|
void Label::draw(const DrawContext& pctx, const Assets& assets) {
|
||||||
auto batch = pctx.getBatch2D();
|
auto batch = pctx.getBatch2D();
|
||||||
auto font = assets.getShared<Font>(fontName);
|
auto font = assets.getShared<Font>(fontName);
|
||||||
|
if (font == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
cache.prepare(
|
cache.prepare(
|
||||||
font,
|
font,
|
||||||
font->getMetrics(),
|
font->getMetrics(),
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,9 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) {
|
||||||
|
|
||||||
void TextBox::drawBackground(const DrawContext& pctx, const Assets& assets) {
|
void TextBox::drawBackground(const DrawContext& pctx, const Assets& assets) {
|
||||||
auto font = assets.getShared<Font>(label->getFontName());
|
auto font = assets.getShared<Font>(label->getFontName());
|
||||||
rawTextCache.prepare(font, font->getMetrics(), label->getSize().x);
|
if (font != nullptr) {
|
||||||
|
rawTextCache.prepare(font, font->getMetrics(), label->getSize().x);
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec2 pos = calcPos();
|
glm::vec2 pos = calcPos();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue