1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:23:52 +00:00

Merged pull request #1927

This commit is contained in:
Marc Zinnschlag 2018-09-20 13:31:41 +02:00
commit 82d37dda20
4 changed files with 17 additions and 22 deletions

View file

@ -264,29 +264,24 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
{ {
} }
Style * createStyle (const std::string& fontName, const Colour& fontColour) Style * createStyle (const std::string& fontName, const Colour& fontColour, bool useBookFont)
{ {
const std::string templateName = "Journalbook "; std::string fullFontName;
std::string bookFont;
if (fontName.empty()) if (fontName.empty())
{ fullFontName = MyGUI::FontManager::getInstance().getDefaultFont();
bookFont = MyGUI::FontManager::getInstance().getDefaultFont();
bookFont = templateName + bookFont;
return createStyle(bookFont, fontColour);
}
if (fontName.compare(0, templateName.size(), templateName) == 0)
bookFont = fontName;
else else
bookFont = templateName + bookFont; fullFontName = fontName;
if (useBookFont)
fullFontName = "Journalbook " + fullFontName;
for (Styles::iterator i = mBook->mStyles.begin (); i != mBook->mStyles.end (); ++i) for (Styles::iterator i = mBook->mStyles.begin (); i != mBook->mStyles.end (); ++i)
if (i->match (bookFont.c_str(), fontColour, fontColour, fontColour, 0)) if (i->match (fullFontName.c_str(), fontColour, fontColour, fontColour, 0))
return &*i; return &*i;
MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(bookFont); MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(fullFontName);
if (!font) if (!font)
throw std::runtime_error(std::string("can't find font ") + bookFont); throw std::runtime_error(std::string("can't find font ") + fullFontName);
StyleImpl & style = *mBook->mStyles.insert (mBook->mStyles.end (), StyleImpl ()); StyleImpl & style = *mBook->mStyles.insert (mBook->mStyles.end (), StyleImpl ());
style.mFont = font; style.mFont = font;

View file

@ -102,7 +102,7 @@ namespace MWGui
static Ptr create (int pageWidth, int pageHeight); static Ptr create (int pageWidth, int pageHeight);
/// Create a simple text style consisting of a font and a text color. /// Create a simple text style consisting of a font and a text color.
virtual Style* createStyle (const std::string& fontName, const Colour& colour) = 0; virtual Style* createStyle (const std::string& fontName, const Colour& colour, bool useBookFont=true) = 0;
/// Create a hyper-link style with a user-defined identifier based on an /// Create a hyper-link style with a user-defined identifier based on an
/// existing style. The unique flag forces a new instance of this style /// existing style. The unique flag forces a new instance of this style

View file

@ -137,7 +137,7 @@ namespace MWGui
if (mTitle != "") if (mTitle != "")
{ {
const MyGUI::Colour& headerColour = MWBase::Environment::get().getWindowManager()->getTextColours().header; const MyGUI::Colour& headerColour = MWBase::Environment::get().getWindowManager()->getTextColours().header;
BookTypesetter::Style* title = typesetter->createStyle("", headerColour); BookTypesetter::Style* title = typesetter->createStyle("", headerColour, false);
typesetter->write(title, to_utf8_span(mTitle.c_str())); typesetter->write(title, to_utf8_span(mTitle.c_str()));
typesetter->sectionBreak(); typesetter->sectionBreak();
} }
@ -182,7 +182,7 @@ namespace MWGui
{ {
const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal); BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal, false);
size_t formatted = 0; // points to the first character that is not laid out yet size_t formatted = 0; // points to the first character that is not laid out yet
for (std::map<Range, intptr_t>::iterator it = hyperLinks.begin(); it != hyperLinks.end(); ++it) for (std::map<Range, intptr_t>::iterator it = hyperLinks.begin(); it != hyperLinks.end(); ++it)
{ {
@ -223,7 +223,7 @@ namespace MWGui
{ {
const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal); BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal, false);
if (topicId) if (topicId)
@ -239,7 +239,7 @@ namespace MWGui
void Message::write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const void Message::write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const
{ {
const MyGUI::Colour& textColour = MWBase::Environment::get().getWindowManager()->getTextColours().notify; const MyGUI::Colour& textColour = MWBase::Environment::get().getWindowManager()->getTextColours().notify;
BookTypesetter::Style* title = typesetter->createStyle("", textColour); BookTypesetter::Style* title = typesetter->createStyle("", textColour, false);
typesetter->sectionBreak(9); typesetter->sectionBreak(9);
typesetter->write(title, to_utf8_span(mText.c_str())); typesetter->write(title, to_utf8_span(mText.c_str()));
} }
@ -567,7 +567,7 @@ namespace MWGui
(*it)->write(typesetter, &mKeywordSearch, mTopicLinks); (*it)->write(typesetter, &mKeywordSearch, mTopicLinks);
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::White); BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::White, false);
typesetter->sectionBreak(9); typesetter->sectionBreak(9);
// choices // choices

View file

@ -14,7 +14,7 @@ namespace MWGui
{ {
TextStyle() : TextStyle() :
mColour(0,0,0) mColour(0,0,0)
, mFont("") , mFont("Journalbook Magic Cards")
, mTextSize(16) , mTextSize(16)
{ {
} }