-
Notifications
You must be signed in to change notification settings - Fork 85
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
switch/application : shared font workaround #79
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! The mechanism of font loading has been changed in the yoga rework. The rule of thumb is: I don't want to see any Fonts are defined in a fully platform agnostic way in the Each platform font loader loads as much font as it can. At runtime, one platform is selected and its code is executed. Then, the platform agnostic code in So the proper approach would be to add the fonts in the header, as you did, and then load them in the Switch font loader. The glfw one should stay empty (but put a comment to say that the fonts are not supported). Then setup the fallback the same way it's done for Korean at the moment. That requires abstracting out the system language ( |
I just pushed something that abstracts out the system locale - you can use |
I don't really get how you did fallback with korean atm, it is loaded but fallback wasn't set. |
Did I forget to do Korean fallback? My bad then Then I would only load Korean or Chinese in the font loaders IF the language is set to Korean or Chinese, and then setup fallback if the Korean or Chinese font are loaded. In the font loader: if the locale is Chinese then load Chinese font in the stash And do the same for Korean if you want, while you are at it |
Now I get your point: am i right? also i have concern on locale string. we can't use string in still, as a multilinguist, i want to have full fallback in non-applet mode, in order to display as much unicode chars as we can |
You should not consider the Chinese and Korean fonts as Switch exclusive fonts. They are Borealis fonts, of which the Switch provides one implementation (the shared fonts). PC (glfw) could provide an implementation too, by loading whatever TTF on the disk. So you should not see if you are on Switch, you should see if the fonts are loaded (aka if the platform implementation loaded the font).
I don't think we can avoid if panic sadly, but do you have an example of what you have in mind with the if panic?
This is why the regular font should always be loaded, Chinese font should be set as fallback, what do you think? |
You might not aware, but for hanzi/kanji (chinese glyphs) they have numerous difference (different stroke in different part) in general for different regions. I also want to get the glyphs displaying correct, and that's why I insist to replace regular font stash with respective shared font (and have slightly different fallback order). I think i18n should be implement correctly and so I spent some effort on the library instead of just counting on others, even I'm not really a programmer. |
Now I detects if But there's one more minor problem here: Let me know if any further modification is needed, but I'm afraid that may exceed my current skill... |
65acc8d
to
97361b8
Compare
Oh so what you are saying is that the Chinese system uses a different latin font AND a Chinese font on top of that? So for English we need the standard font, and for Chinese we need the standard Chinese + the extented Chinese, and not the standard font? I just want to fully understand the problem before continuing to comment haha |
the fallback mechanism of HOS is more complicated, Chinese and Korean shared fonts complies corresponding national standards in respective regions, in terms of supported characters and scripting (the writing difference I mentioned previously). But, yeah, when western languages and Japanese share a same font file, and many games only available in Japanese (in terms of metadata), fallback to In short: you need both standard font and locale specific font, and let latter have highest priority. |
oh i get what you talk about, the extend chinese font just add extra chinese glyphs in order to complies with latest national standard |
Okay, I see. So what prevents you from implementing exactly that, while keeping the current design? Is it code legibility? |
I'm not very good at English, so I might get my demand unclear. At the very beginning, I just wanted to solve the font loading problem for Switch correctly by
Personally I don't care of cross-platform at all, as 99% of that glyph missing problem happens on Switch, when you can just use one Source Han Sans font for other platform to solve it dirty but for good. You later told me on yoga branch it should be all abstracted out, I totally agree with it as I don't want to break the intergration you (the author) intended. But... I am not that skilled, and I tried my best to make changes. As of my latest commit, it works as I intended on Switch, and now I'm generally okay with it. |
I also have another question in mind (maybe unrelated?): |
I checked the new code, and the logic you implemented seems correct to me, and the approach is right too. However is there a need to load all 4 Chinese and Korean fonts if the system locale is not a Chinese or Korean locale? I feel like it might take a lot of RAM for nothing on non-Chinese devices.
The TTF itself is made available using shared memory, so the TTF itself is never copied anywhere. However loading the TTF takes more RAM and VRAM as it's transformed in some internal structure + a gfx texture. |
force pushed.
Since it checks for title takeover, I think it is acceptable though? (assuming it have enough RAM to waste) If we must do it, we will need to check for certain languages, and another bunch of (i guess |
Just because RAM is available doesn't mean we can waste it indeed. I would rather use as least as possible, especially if it's not used.
Sure, I don't mind having more conditions in the code if it's to achieve proper design. However GetSharedFontInOrderOfPriority is a really good find. The wiki here explains how to use it: https://switchbrew.org/wiki/Shared_Database_services#GetSharedFontInOrderOfPriority Do you think we could replace our entire manual fallback logic to only use that function? |
If I know how to I would do it, but I just don't know lol Don't see any example use and totally headache with C/++ |
What is blocking you? The wiki says how to use the function, I can assist if you want |
I just can't understand how to use it without a real use example. and fyi I'm not available recently. if you can provide me example i will see what i can do when i have spare time |
Alright I'll have a look at it. I have to warn you that the license of the library has been changed from GPLv3 to Apache 2.0, if you don't agree to that change please close the PR. Otherwise you can add your name to the authors file and copyright if you haven't already. |
I'm always ok with that |
Would it be feasible to implement some sort of compile-time flag to make Borealis load all fonts, even if the console region isn't Chinese or Korean, and let the developer decide? Let me elaborate. I'm currently looking into implementing Borealis in a project where listing available titles is a must. Due to the region-free nature of the Switch, it could be possible to import Chinese/Korean games and use them with a unit from a different region. Most of the time, these games only hold Chinese/Korean name entries as part of their application control data, which in turn wouldn't be properly displayed under consoles with a different locale because not all fonts would be loaded. Defaulting to only load a subset of the shared fonts based on the configured locale seems alright, but letting the developer decide if all fonts should be loaded may also be benefitial for cases like this. |
|
ca6bf55
to
ff1cc86
Compare
- utilized the use of plGetSharedFont(), leaving possibility to utilize HOS native fallback order - adjusted fallback chain, now identical with HOS - added compile-time flag: SW_STANDARD_FONT_ONLY and SW_DISABLE_FONT_FALLBACK
Necromancer approaching - I think i am close, but i have no clue about building fallback chain completely with |
I might have done my work, but if you need any sorta collab guildline compliance etc. , just leave comment... |
ec93a22
to
57df225
Compare
- utilize HOS native fallback order - may still dirty but works...... - force push: some cleanups
replaces #76
added a wrapper
Application::addFontFallback()
for adding font fallback, to make the code looks neatto be discussed:
should
setGetSystemLanguage()
andsetMakeLanguage()
of libnx get warpped for developers' sake?