mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-07-02 06:35:18 +02:00
Merge pull request #18 from WaywardHeart/font-families
Make font families case insensitive
This commit is contained in:
commit
77dedd06db
2 changed files with 17 additions and 0 deletions
|
@ -276,6 +276,9 @@ try { exp } catch (...) {}
|
|||
SET_OPT(frameSkip, boolean);
|
||||
SET_OPT(syncToRefreshrate, boolean);
|
||||
fillStringVec(opts["solidFonts"], solidFonts);
|
||||
for (std::string & solidFont : solidFonts)
|
||||
std::transform(solidFont.begin(), solidFont.end(), solidFont.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
#ifdef __APPLE__
|
||||
SET_OPT(preferMetalRenderer, boolean);
|
||||
#endif
|
||||
|
@ -298,6 +301,9 @@ try { exp } catch (...) {}
|
|||
fillStringVec(opts["preloadScript"], preloadScripts);
|
||||
fillStringVec(opts["RTP"], rtps);
|
||||
fillStringVec(opts["fontSub"], fontSubs);
|
||||
for (std::string & fontSub : fontSubs)
|
||||
std::transform(fontSub.begin(), fontSub.end(), fontSub.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
fillStringVec(opts["rubyLoadpath"], rubyLoadpaths);
|
||||
|
||||
auto &bnames = opts["bindingNames"].as_object();
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
#ifdef MKXPZ_BUILD_XCODE
|
||||
#include "filesystem/filesystem.h"
|
||||
|
@ -149,6 +151,9 @@ void SharedFontState::initFontSetCB(SDL_RWops &ops,
|
|||
std::string family = TTF_FontFaceFamilyName(font);
|
||||
std::string style = TTF_FontFaceStyleName(font);
|
||||
|
||||
std::transform(family.begin(), family.end(), family.begin(),
|
||||
[](unsigned char c){ return std::tolower(c); });
|
||||
|
||||
TTF_CloseFont(font);
|
||||
|
||||
FontSet &set = p->sets[family];
|
||||
|
@ -162,6 +167,9 @@ void SharedFontState::initFontSetCB(SDL_RWops &ops,
|
|||
_TTF_Font *SharedFontState::getFont(std::string family,
|
||||
int size)
|
||||
{
|
||||
std::transform(family.begin(), family.end(), family.begin(),
|
||||
[](unsigned char c){ return std::tolower(c); });
|
||||
|
||||
if (family.empty())
|
||||
family = p->defaultFamily;
|
||||
|
||||
|
@ -219,6 +227,9 @@ _TTF_Font *SharedFontState::getFont(std::string family,
|
|||
|
||||
bool SharedFontState::fontPresent(std::string family) const
|
||||
{
|
||||
std::transform(family.begin(), family.end(), family.begin(),
|
||||
[](unsigned char c){ return std::tolower(c); });
|
||||
|
||||
/* Check for substitutions */
|
||||
if (p->subs.contains(family))
|
||||
family = p->subs[family];
|
||||
|
|
Loading…
Add table
Reference in a new issue