diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-08-06 21:33:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-06 21:33:13 +0200 |
commit | 233cb86e864affe3dee8f60503584f1eb7e36287 (patch) | |
tree | e1f57d5803abd1bbcdf296802537892e0289e645 /src/irrlicht_changes | |
parent | 8e757859d6a6bf6482480904e8485e9344e567ab (diff) | |
download | minetest-233cb86e864affe3dee8f60503584f1eb7e36287.tar.gz minetest-233cb86e864affe3dee8f60503584f1eb7e36287.tar.bz2 minetest-233cb86e864affe3dee8f60503584f1eb7e36287.zip |
Clean up and fix freetype=false crashes (#8641)
A IGUIFont of type bitmap/vector cannot be converted to CGUITTFont
Fixes various segfaults in gameplay
Shorter font cache code, cleaned up (?)
Diffstat (limited to 'src/irrlicht_changes')
-rw-r--r-- | src/irrlicht_changes/static_text.cpp | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/irrlicht_changes/static_text.cpp b/src/irrlicht_changes/static_text.cpp index ed1655e0a..5a0f82673 100644 --- a/src/irrlicht_changes/static_text.cpp +++ b/src/irrlicht_changes/static_text.cpp @@ -109,10 +109,22 @@ void StaticText::draw() font->getDimension(cText.c_str()).Width; } - irr::gui::CGUITTFont *tmp = static_cast<irr::gui::CGUITTFont*>(font); - tmp->draw(cText, frameRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), - HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); +#if USE_FREETYPE + if (font->getType() == irr::gui::EGFT_CUSTOM) { + irr::gui::CGUITTFont *tmp = static_cast<irr::gui::CGUITTFont*>(font); + tmp->draw(cText, frameRect, + OverrideColorEnabled ? OverrideColor : + skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), + HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, + (RestrainTextInside ? &AbsoluteClippingRect : NULL)); + } else +#endif + { + font->draw(Text.c_str(), frameRect, + skin->getColor(EGDC_BUTTON_TEXT), + HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, + (RestrainTextInside ? &AbsoluteClippingRect : NULL)); + } } else { @@ -140,18 +152,29 @@ void StaticText::draw() font->getDimension(BrokenText[i].c_str()).Width; } - //std::vector<irr::video::SColor> colors; - //std::wstring str; EnrichedString str = BrokenText[i]; //str = colorizeText(BrokenText[i].c_str(), colors, previous_color); //if (!colors.empty()) // previous_color = colors[colors.size() - 1]; - irr::gui::CGUITTFont *tmp = static_cast<irr::gui::CGUITTFont*>(font); - tmp->draw(str, r, - previous_color, // FIXME - HAlign == EGUIA_CENTER, false, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); +#if USE_FREETYPE + if (font->getType() == irr::gui::EGFT_CUSTOM) { + irr::gui::CGUITTFont *tmp = static_cast<irr::gui::CGUITTFont*>(font); + tmp->draw(str, + r, previous_color, // FIXME + HAlign == EGUIA_CENTER, false, + (RestrainTextInside ? &AbsoluteClippingRect : NULL)); + } else +#endif + { + // Draw non-colored text + font->draw(str.c_str(), + r, skin->getColor(EGDC_BUTTON_TEXT), + HAlign == EGUIA_CENTER, false, + (RestrainTextInside ? &AbsoluteClippingRect : NULL)); + } + r.LowerRightCorner.Y += height; r.UpperLeftCorner.Y += height; |