diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index dbd829176..0f412042b 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -275,9 +275,12 @@ struct TypesetBookImpl::Typesetter : BookTypesetter if (i->match (fontName, fontColour, fontColour, fontColour, 0)) 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.mActiveColour = fontColour; style.mNormalColour = fontColour; diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 6a8145e97..b7e24a7ee 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -413,7 +413,10 @@ namespace MWGui int TextElement::currentFontHeight() const { 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()