-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application: General i18n workaround for shared font loading #76
Conversation
library/include/borealis/i18n.hpp
Outdated
@@ -64,6 +64,14 @@ void loadTranslations(); | |||
*/ | |||
std::string getCurrentLocale(); | |||
|
|||
#ifdef __SWITCH__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why put it here? Technically it's i18n related but it doesn't belong to the i18n system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean it depends on the Switch implementation, and i18n is supposed to be generic (and eventually will)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this id only make sense for libnx i think
removed #ifdef
library/lib/application.cpp
Outdated
Logger::warning("Non applet mode, font full fallback is enabled!"); | ||
} | ||
|
||
if (locale == 6 || locale == 15 || isFullFallback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of magic values here, could you define them somewhere instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
substituted with enforcing SetLanguage
enum
library/lib/application.cpp
Outdated
if (at == AppletType_Application || at == AppletType_SystemApplication) // title takeover | ||
{ | ||
isFullFallback = true; | ||
Logger::warning("Non applet mode, font full fallback is enabled!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really a warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to INFO
library/lib/i18n.cpp
Outdated
} | ||
else | ||
{ | ||
brls::Logger::error("Unable to convert system language ID (error 0x{0:x}), using the default one: {1}", res, DEFAULT_LOCALE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use {0:#x}
instead of 0x{0x:}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Thanks for the PR!
I am going to wait for you to add proper names to the locale magic values since I am having a real hard time to understand the second part of the code without it. |
library/lib/application.cpp
Outdated
Logger::info("Using Switch shared font"); | ||
Application::fontStash.regular = Application::loadFontFromMemory("regular", font.address, font.size, false); | ||
Logger::info("Adding Switch shared standard font"); | ||
Application::fontStash.standard = Application::loadFontFromMemory("regular", font.address, font.size, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that be standard
as well in the loadFontFromMemory
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
I am very sorry but I am currently rewriting the entirety of font handling for the yoga rework (yoga branch, my work is not pushed yet). I am currently adapting Behemoth's work of splitting borealis in two "platforms", glfw and switch. That means the Switch will have its own font loading code, which is no longer in Would you mind redoing what you did on the yoga branch once I push what I have? I will notify you here. The core of what you did will not be altered, you will just need to put it in the new font code dedicated to the Switch platform. |
i'm okay with that
|
Hey @CaiMiao, I finished working on the new font abstraction layer. It's on the yoga branch, feel free to PR to that branch if you want to. Now fonts are defined in a fully platform agnostic file, and every platform implementation loads them as they wish. The fallback code is still in |
have problem with building demo
|
It looks like your |
I'm compiling the demo under the yoga branch, and everything is unmodified, so i don't really know where I did wrong. |
Can you try again with the changes of this commit please? |
this works for me, ty. once i tested the implement okay i will PR them again asap. |
replaced by #79 |
well i think it is not bad to merge this to legacy though, in case anyone need to include the shared font workaround without need to update to yoga. |
The thing is, I don't want to maintain this version anymore. The yoga rework is too hard to rebase since so many things changed 😕 |
This is similar to #49 but I made a more graceful implement (at least imo), and I didn't aware of #49 when I was writing this lol
For memory consuming concern, we do not load full fallback chain when we are not in title takeover mode.
Confirmed working for my WIP tiny tool.
I'm not really a programmer so let me know if cleanup/optimization is needed.
Still I have a question, I can't really figure out how
nvgAddFallbackFontId
push the fallback order so I may have reversed my intend.For example:
does make the order
regular
->korean
->symbol
(appending) orregular
->symbol
->korean
(prepending)?