mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Added support for changing the medium and large system font sizes automatically depending on screen orientation.
Also fixed an issue where the font size was not calculated correctly when using a vertical screen orientation.
This commit is contained in:
parent
397ad15de6
commit
3d1261b6d2
|
@ -435,14 +435,16 @@ std::shared_ptr<Font> Font::getFromTheme(const ThemeData::ThemeElement* elem,
|
||||||
if (!(properties & FONT_PATH) && !(properties & FONT_SIZE))
|
if (!(properties & FONT_PATH) && !(properties & FONT_SIZE))
|
||||||
return orig;
|
return orig;
|
||||||
|
|
||||||
float size {static_cast<float>(orig ? orig->mFontSize : FONT_SIZE_MEDIUM)};
|
float size {static_cast<float>(orig ? orig->mFontSize : FONT_SIZE_MEDIUM_FIXED)};
|
||||||
std::string path {orig ? orig->mPath : getDefaultPath()};
|
std::string path {orig ? orig->mPath : getDefaultPath()};
|
||||||
|
|
||||||
float screenHeight {static_cast<float>(Renderer::getScreenHeight())};
|
const float screenSize {Renderer::getIsVerticalOrientation() ?
|
||||||
|
static_cast<float>(Renderer::getScreenWidth()) :
|
||||||
|
static_cast<float>(Renderer::getScreenHeight())};
|
||||||
|
|
||||||
if (properties & FONT_SIZE && elem->has("fontSize")) {
|
if (properties & FONT_SIZE && elem->has("fontSize")) {
|
||||||
size = glm::clamp(screenHeight * elem->get<float>("fontSize"), screenHeight * 0.001f,
|
size = glm::clamp(screenSize * elem->get<float>("fontSize"), screenSize * 0.001f,
|
||||||
screenHeight * 1.5f);
|
screenSize * 1.5f);
|
||||||
// This is used by the carousel where the itemScale property also scales the font size.
|
// This is used by the carousel where the itemScale property also scales the font size.
|
||||||
size *= sizeMultiplier;
|
size *= sizeMultiplier;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,12 @@
|
||||||
|
|
||||||
class TextCache;
|
class TextCache;
|
||||||
|
|
||||||
#define FONT_SIZE_MINI 0.030f * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())
|
#define FONT_SIZE_MINI Font::getMiniFont()
|
||||||
#define FONT_SIZE_SMALL 0.035f * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())
|
#define FONT_SIZE_SMALL Font::getSmallFont()
|
||||||
#define FONT_SIZE_MEDIUM 0.045f * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())
|
#define FONT_SIZE_MEDIUM Font::getMediumFont()
|
||||||
#define FONT_SIZE_LARGE 0.085f * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())
|
#define FONT_SIZE_MEDIUM_FIXED Font::getMediumFixedFont()
|
||||||
|
#define FONT_SIZE_LARGE Font::getLargeFont()
|
||||||
|
#define FONT_SIZE_LARGE_FIXED Font::getLargeFixedFont()
|
||||||
|
|
||||||
#define FONT_PATH_LIGHT ":/fonts/Akrobat-Regular.ttf"
|
#define FONT_PATH_LIGHT ":/fonts/Akrobat-Regular.ttf"
|
||||||
#define FONT_PATH_REGULAR ":/fonts/Akrobat-SemiBold.ttf"
|
#define FONT_PATH_REGULAR ":/fonts/Akrobat-SemiBold.ttf"
|
||||||
|
@ -39,6 +41,45 @@ public:
|
||||||
static std::shared_ptr<Font> get(float size,
|
static std::shared_ptr<Font> get(float size,
|
||||||
const std::string& path = getDefaultPath(),
|
const std::string& path = getDefaultPath(),
|
||||||
const bool linearMagnify = false);
|
const bool linearMagnify = false);
|
||||||
|
static float getMiniFont()
|
||||||
|
{
|
||||||
|
static float sMiniFont {0.030f *
|
||||||
|
std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())};
|
||||||
|
return sMiniFont;
|
||||||
|
}
|
||||||
|
static float getSmallFont()
|
||||||
|
{
|
||||||
|
static float sSmallFont {0.035f *
|
||||||
|
std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())};
|
||||||
|
return sSmallFont;
|
||||||
|
}
|
||||||
|
static float getMediumFont()
|
||||||
|
{
|
||||||
|
static float sMediumFont {
|
||||||
|
(Renderer::getIsVerticalOrientation() ? 0.040f : 0.045f) *
|
||||||
|
std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())};
|
||||||
|
return sMediumFont;
|
||||||
|
}
|
||||||
|
static float getMediumFixedFont()
|
||||||
|
{
|
||||||
|
// Fixed size regardless of screen orientation.
|
||||||
|
static float sMediumFixedFont {
|
||||||
|
0.045f * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())};
|
||||||
|
return sMediumFixedFont;
|
||||||
|
}
|
||||||
|
static float getLargeFont()
|
||||||
|
{
|
||||||
|
static float sLargeFont {(Renderer::getIsVerticalOrientation() ? 0.080f : 0.085f) *
|
||||||
|
std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())};
|
||||||
|
return sLargeFont;
|
||||||
|
}
|
||||||
|
static float getLargeFixedFont()
|
||||||
|
{
|
||||||
|
// Fixed size regardless of screen orientation.
|
||||||
|
static float sLargeFixedFont {
|
||||||
|
0.085f * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth())};
|
||||||
|
return sLargeFixedFont;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the expected size of a string when rendered. Extra spacing is applied to the Y axis.
|
// Returns the expected size of a string when rendered. Extra spacing is applied to the Y axis.
|
||||||
glm::vec2 sizeText(std::string text, float lineSpacing = 1.5f);
|
glm::vec2 sizeText(std::string text, float lineSpacing = 1.5f);
|
||||||
|
|
Loading…
Reference in a new issue