diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index ced3368..42bbeb1 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -499,6 +499,7 @@ void ScrollingList::update(float dt) ViewInfo *nextvi = scrollPoints_->at(nextI); resetTweens(c, tweenPoints_->at(i), currentvi, nextvi, scrollPeriod_); + c->baseViewInfo.font = nextvi->font; // Use the font settings of the next index c->triggerMenuScrollEvent(); } diff --git a/RetroFE/Source/Graphics/Component/Text.cpp b/RetroFE/Source/Graphics/Component/Text.cpp index c065ae2..5e78063 100644 --- a/RetroFE/Source/Graphics/Component/Text.cpp +++ b/RetroFE/Source/Graphics/Component/Text.cpp @@ -55,7 +55,13 @@ void Text::draw() { Component::draw(); - SDL_Texture *t = fontInst_->getTexture(); + Font *font; + if (baseViewInfo.font) // Use font of this specific item if available + font = baseViewInfo.font; + else // If not, use the general font settings + font = fontInst_; + + SDL_Texture *t = font->getTexture(); float imageHeight = 0; float imageWidth = 0; @@ -64,7 +70,7 @@ void Text::draw() for(unsigned int i = 0; i < textData_.size(); ++i) { Font::GlyphInfo glyph; - if(fontInst_->getRect(textData_[i], glyph)) + if(font->getRect(textData_[i], glyph)) { if(glyph.minX < 0) { @@ -76,7 +82,7 @@ void Text::draw() } - imageHeight = (float)fontInst_->getHeight(); + imageHeight = (float)font->getHeight(); float scale = (float)baseViewInfo.FontSize / (float)imageHeight; float oldWidth = baseViewInfo.Width; @@ -105,7 +111,7 @@ void Text::draw() { Font::GlyphInfo glyph; - if(fontInst_->getRect(textData_[i], glyph) && glyph.rect.h > 0) + if(font->getRect(textData_[i], glyph) && glyph.rect.h > 0) { SDL_Rect charRect = glyph.rect; float h = static_cast(charRect.h * scale); @@ -118,9 +124,9 @@ void Text::draw() { rect.x += static_cast((float)(glyph.minX) * scale); } - if(fontInst_->getAscent() < glyph.maxY) + if(font->getAscent() < glyph.maxY) { - rect.y += static_cast((fontInst_->getAscent() - glyph.maxY)*scale); + rect.y += static_cast((font->getAscent() - glyph.maxY)*scale); } diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 7e9e7b8..b9557e0 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -482,17 +482,17 @@ Font *PageBuilder::addFont(xml_node<> *component, xml_node<> *defaults) if(defaults) { - if(defaults->first_attribute("font")) + if(!fontXml && defaults->first_attribute("font")) { fontXml = defaults->first_attribute("font"); } - if(defaults->first_attribute("fontColor")) + if(!fontColorXml && defaults->first_attribute("fontColor")) { fontColorXml = defaults->first_attribute("fontColor"); } - if(defaults->first_attribute("loadFontSize")) + if(!fontSizeXml && defaults->first_attribute("loadFontSize")) { fontSizeXml = defaults->first_attribute("loadFontSize"); } @@ -843,6 +843,7 @@ void PageBuilder::buildViewInfo(xml_node<> *componentXml, ViewInfo &info, xml_no xml_attribute<> *height = findAttribute(componentXml, "height", defaultXml); xml_attribute<> *width = findAttribute(componentXml, "width", defaultXml); xml_attribute<> *fontSize = findAttribute(componentXml, "fontSize", defaultXml); + xml_attribute<> *fontColor = findAttribute(componentXml, "fontColor", defaultXml); xml_attribute<> *minHeight = findAttribute(componentXml, "minHeight", defaultXml); xml_attribute<> *minWidth = findAttribute(componentXml, "minWidth", defaultXml); xml_attribute<> *maxHeight = findAttribute(componentXml, "maxHeight", defaultXml); @@ -885,6 +886,12 @@ void PageBuilder::buildViewInfo(xml_node<> *componentXml, ViewInfo &info, xml_no info.Angle = angle ? Utils::convertFloat(angle->value()) : 0.f; info.Layer = layer ? Utils::convertInt(layer->value()) : 0; + if(fontColor) + { + Font *font = addFont(componentXml, defaultXml); + info.font = font; + } + if(backgroundColor) { std::stringstream ss(backgroundColor->value()); diff --git a/RetroFE/Source/Graphics/ViewInfo.cpp b/RetroFE/Source/Graphics/ViewInfo.cpp index 0b198f9..bfacb20 100644 --- a/RetroFE/Source/Graphics/ViewInfo.cpp +++ b/RetroFE/Source/Graphics/ViewInfo.cpp @@ -35,6 +35,7 @@ ViewInfo::ViewInfo() , ImageWidth(0) , ImageHeight(0) , FontSize(-1) + , font(0) , Angle(0) , Alpha(1) , Layer(0) diff --git a/RetroFE/Source/Graphics/ViewInfo.h b/RetroFE/Source/Graphics/ViewInfo.h index 38c43f8..944c9b2 100644 --- a/RetroFE/Source/Graphics/ViewInfo.h +++ b/RetroFE/Source/Graphics/ViewInfo.h @@ -19,6 +19,8 @@ #include #include +class Font; + class ViewInfo { public: @@ -53,6 +55,7 @@ public: float ImageWidth; float ImageHeight; float FontSize; + Font *font; float Angle; float Alpha; unsigned int Layer;