mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-12 09:38:20 +00:00
Qt: Use Roboto Condensed like on other platforms.
May improve font fallback issues in #7581.
This commit is contained in:
parent
a676721683
commit
cc1fa20afb
@ -106,10 +106,12 @@ public:
|
||||
#if defined(USING_WIN_UI)
|
||||
bool bPauseOnLostFocus;
|
||||
bool bTopMost;
|
||||
std::string sFont;
|
||||
bool bIgnoreWindowsKey;
|
||||
bool bRestartRequired;
|
||||
#endif
|
||||
#if defined(USING_WIN_UI) || defined(USING_QT_UI)
|
||||
std::string sFont;
|
||||
#endif
|
||||
|
||||
bool bPauseWhenMinimized;
|
||||
|
||||
|
@ -105,6 +105,9 @@
|
||||
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
|
||||
#include "Qt/QtHost.h"
|
||||
#endif
|
||||
#if defined(USING_QT_UI)
|
||||
#include <QFontDatabase>
|
||||
#endif
|
||||
|
||||
// The new UI framework, for initialization
|
||||
|
||||
@ -276,7 +279,7 @@ void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, boo
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
|
||||
#if defined(USING_WIN_UI) && !PPSSPP_PLATFORM(UWP)
|
||||
static bool CheckFontIsUsable(const wchar_t *fontFace) {
|
||||
wchar_t actualFontFace[1024] = { 0 };
|
||||
|
||||
@ -558,7 +561,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
// Note to translators: do not translate this/add this to PPSSPP-lang's files.
|
||||
// It's intended to be custom for every user.
|
||||
// Only add it to your own personal copies of PPSSPP.
|
||||
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
|
||||
#if defined(USING_WIN_UI) && !PPSSPP_PLATFORM(UWP)
|
||||
// TODO: Could allow a setting to specify a font file to load?
|
||||
// TODO: Make this a constant if we can sanely load the font on other systems?
|
||||
AddFontResourceEx(L"assets/Roboto-Condensed.ttf", FR_PRIVATE, NULL);
|
||||
@ -568,6 +571,22 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
} else {
|
||||
g_Config.sFont = des->T("Font", "Roboto");
|
||||
}
|
||||
#elif defined(USING_QT_UI)
|
||||
size_t fontSize = 0;
|
||||
uint8_t *fontData = VFSReadFile("Roboto-Condensed.ttf", &fontSize);
|
||||
if (fontData) {
|
||||
int fontID = QFontDatabase::addApplicationFontFromData(QByteArray((const char *)fontData, fontSize));
|
||||
delete [] fontData;
|
||||
|
||||
QStringList fontsFound = QFontDatabase::applicationFontFamilies(fontID);
|
||||
if (fontsFound.size() >= 1) {
|
||||
// Might be "Roboto" or "Roboto Condensed".
|
||||
g_Config.sFont = des->T("Font", fontsFound.at(0).toUtf8().constData());
|
||||
}
|
||||
} else {
|
||||
// Let's try for it being a system font.
|
||||
g_Config.sFont = des->T("Font", "Roboto Condensed");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!boot_filename.empty() && stateToLoad != NULL) {
|
||||
@ -618,7 +637,7 @@ static UI::Style MakeStyle(uint32_t fg, uint32_t bg) {
|
||||
}
|
||||
|
||||
static void UIThemeInit() {
|
||||
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
|
||||
#if (defined(USING_WIN_UI) && !PPSSPP_PLATFORM(UWP)) || defined(USING_QT_UI)
|
||||
ui_theme.uiFont = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 22);
|
||||
ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 15);
|
||||
ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 12);
|
||||
|
@ -23,8 +23,7 @@ TextDrawerQt::~TextDrawerQt() {
|
||||
}
|
||||
|
||||
uint32_t TextDrawerQt::SetFont(const char *fontName, int size, int flags) {
|
||||
// We will only use the default font
|
||||
uint32_t fontHash = 0; //hash::Adler32((const uint8_t *)fontName, strlen(fontName));
|
||||
uint32_t fontHash = fontName && strlen(fontName) ? hash::Adler32((const uint8_t *)fontName, strlen(fontName)) : 0;
|
||||
fontHash ^= size;
|
||||
fontHash ^= flags << 10;
|
||||
|
||||
@ -34,7 +33,7 @@ uint32_t TextDrawerQt::SetFont(const char *fontName, int size, int flags) {
|
||||
return fontHash;
|
||||
}
|
||||
|
||||
QFont* font = new QFont();
|
||||
QFont* font = fontName ? new QFont(fontName) : new QFont();
|
||||
font->setPixelSize(size + 6);
|
||||
fontMap_[fontHash] = font;
|
||||
fontHash_ = fontHash;
|
||||
|
Loading…
x
Reference in New Issue
Block a user