Sekai-World / sekai-viewer

Web Database Viewer of Project Sekai
https://sekai.best
GNU General Public License v3.0
328 stars 38 forks source link

Add support for language specific fonts & Add Thai fonts support #379

Closed C0NS03L closed 2 years ago

C0NS03L commented 2 years ago

add support for fonts for each language

Description

Making it possible to edit fonts priority for each country by using a ternary operator with the lang variable in font_family. I'm currently not sure what the lang variable gives since I am unable to normally change the language on my dev branch. The fonts are exported from Fonts.tsx in Stores

Related Issue

https://github.com/Sekai-World/sekai-viewer/issues/376

Motivation and Context

To make the fonts for the Thai language look better. I think there are more fonts out there that are more attractive and look better. I think this is also the case with some other languages, so I think that it might be a good idea to add support for custom fonts set that change with the locale.

How Has This Been Tested?

Tested that the fonts are working fine, Didn't check if it would change when the language is changed since the language selection didn't appear for me.

Screenshots (if appropriate):

image

C0NS03L commented 2 years ago

The fonts are currently determined using a ternary operator chain in mui theme part. Let me know if there's a better place to put it or if there's a better way of determining the fonts that will be used

C0NS03L commented 2 years ago

The EN and JP Fonts are there for demonstrating purposes and will be removed once the code is final (Unless you want to keep them of course)

FontsComparison

C0NS03L commented 2 years ago

Can't really put ja/zh fonts in the form of font face though since their Unicode range are unbelievably long so I put it as a link for now. Therefore, when Overpass and Prompt can not be loaded, it will fall back to using Latin characters from Noto Sans JP (cause I can't unicode-range it) which doesn't look too bad Imo compared to 119*4 font faces of Japanese char.

dnaroma commented 2 years ago

Can't really put ja/zh fonts in the form of font face though since their Unicode range are unbelievably long so I put it as a link for now. Therefore, when Overpass and Prompt can not be loaded, it will fall back to using Latin characters from Noto Sans JP (cause I can't unicode-range it) which doesn't look too bad Imo compared to 119*4 font faces of Japanese char.

I thought to add fontface for Japanese characters however they are quite large, can cause slow page loading.

C0NS03L commented 2 years ago

I thought to add fontface for Japanese characters however they are quite large, can cause slow page loading.

I think so, I guess I will remove the jp fonts before the merge

C0NS03L commented 2 years ago

This "should" be good to go, didn't find any unexpected behavior while testing.

Also, about the performance of JP fonts, from testing on a local server, it has little to moderate performance impact (about 1-3 extra load time for first-time visit aka. uncached). but after they have been cached, I noticed no performance impact. Results on the dedicated server might vary though. So it could be left in there if you want. I can't really read Japanese so I don't know if the default fonts are more readable or not.