diff --git a/resources/gui/default.theme.txt b/resources/gui/default.theme.txt index c2f306ebdb..dc2ee5a07a 100644 --- a/resources/gui/default.theme.txt +++ b/resources/gui/default.theme.txt @@ -1,6 +1,8 @@ [base] { font: gui/fonts/BigShouldersDisplay-SemiBold.ttf - + # Positive offset moves the font down, negative moves it up. + font_offset: 0.0 + [button] { color: #ffffff size: 30 @@ -75,7 +77,7 @@ image.focus: gui/widget/TextEntryBackground.focused.png } } - + [luaconsole] { size: 12 font: gui/fonts/RobotoMono-SemiBold.ttf @@ -164,5 +166,6 @@ # Stronger font used at a few locations without UI widgets. [bold] { font: gui/fonts/BigShouldersDisplay-ExtraBold.ttf + offset: 0.0 } } \ No newline at end of file diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 707289efcb..36036212e3 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -99,6 +99,7 @@ bool GuiTheme::loadTheme(const string& name, const string& resource_name) else global_style.color = {255, 255, 255, 255}; global_style.font = getFont(input["font"]); + global_style.font_offset = input["font_offset"].toFloat(); global_style.size = input["size"].toFloat(); global_style.sound = input["sound"]; for(unsigned int n=0; n fonts = findResources("gui/fonts/*.ttf"); if(fonts.size() > 0) - { fallback_state.font = getFont(fonts[0]); - } + fallback_state.font_offset = 0.0f; fallback_state.texture = ""; GuiThemeStyle fallback; for(unsigned int n=0; nsetMusicVolume(PreferencesManager::get("music_volume", "50").toFloat()); soundManager->setMasterSoundVolume(PreferencesManager::get("sound_volume", "50").toFloat()); - main_font = GuiTheme::getCurrentTheme()->getStyle("base")->states[0].font; - bold_font = GuiTheme::getCurrentTheme()->getStyle("bold")->states[0].font; + const auto& active_theme = GuiTheme::getCurrentTheme(); + main_font = active_theme->getStyle("base")->get(GuiElement::State::Normal).font; + bold_font = active_theme->getStyle("bold")->get(GuiElement::State::Normal).font; if (!main_font || !bold_font) { LOG(ERROR, "Missing font or bold font."); @@ -167,6 +168,11 @@ int main(int argc, char** argv) sp::RenderTarget::setDefaultFont(main_font); + // Apply baseline offset adjustments to fonts + // Positive values move text down, negative values move text up + main_font->setBaselineOffset(active_theme->getStyle("base")->get(GuiElement::State::Normal).font_offset); + bold_font->setBaselineOffset(active_theme->getStyle("bold")->get(GuiElement::State::Normal).font_offset); + // On Android, this requires the 'record audio' permissions, // which is always a scary thing for users. // Since there is no way to access it (yet) via a touchscreen, compile out.