mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
Don't crash if FontManager::getByName returns NULL (Fixes #3552)
This commit is contained in:
parent
7bbdeb5f85
commit
7bd445fb83
2 changed files with 9 additions and 3 deletions
|
@ -275,9 +275,12 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
||||||
if (i->match (fontName, fontColour, fontColour, fontColour, 0))
|
if (i->match (fontName, fontColour, fontColour, fontColour, 0))
|
||||||
return &*i;
|
return &*i;
|
||||||
|
|
||||||
StyleImpl & style = *mBook->mStyles.insert (mBook->mStyles.end (), StyleImpl ());
|
MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(fontName);
|
||||||
|
if (!font)
|
||||||
|
throw std::runtime_error(std::string("can't find font ") + fontName);
|
||||||
|
|
||||||
style.mFont = MyGUI::FontManager::getInstance().getByName(fontName);
|
StyleImpl & style = *mBook->mStyles.insert (mBook->mStyles.end (), StyleImpl ());
|
||||||
|
style.mFont = font;
|
||||||
style.mHotColour = fontColour;
|
style.mHotColour = fontColour;
|
||||||
style.mActiveColour = fontColour;
|
style.mActiveColour = fontColour;
|
||||||
style.mNormalColour = fontColour;
|
style.mNormalColour = fontColour;
|
||||||
|
|
|
@ -413,7 +413,10 @@ namespace MWGui
|
||||||
int TextElement::currentFontHeight() const
|
int TextElement::currentFontHeight() const
|
||||||
{
|
{
|
||||||
std::string fontName(mTextStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mTextStyle.mFont);
|
std::string fontName(mTextStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mTextStyle.mFont);
|
||||||
return MyGUI::FontManager::getInstance().getByName(fontName)->getDefaultHeight();
|
MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(fontName);
|
||||||
|
if (!font)
|
||||||
|
return 0;
|
||||||
|
return font->getDefaultHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TextElement::getHeight()
|
int TextElement::getHeight()
|
||||||
|
|
Loading…
Reference in a new issue