Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since there have been so many issues to address with CJK fonts after go-gitea#13204, I decided to try out
unicode-range
as mentioned go-gitea#13784. After doing trial and error for multiple days, the solution seems to work fine on all the platforms I have tested.This approach attempts to minimize the size of the generated CSS while keeping the Less source code largely readable, so modifications could be easily made when things change (could happen in the future when OSes bundles new fonts, for example).
This solution tries to make the look and feel consistent and nuanced (in terms of weight matching) and does further changes to the localized font stacks for optimal results across platforms. For example, on a non-post-OS X 10.11 machine with Source/Noto fonts installed, they are now preferred for Chinese and Japanese as they would match perfectly in weight, and thus win over other candidates in the stack.
The mixed usage of PostScript names and full names in the stack is done as suggested by W3C. For example, since PingFang is most probably macOS only, only PS name is included.
The code points for CJK does not include compatibility glyphs as they are very rarely used and, while I did try to include them, all browsers seemed to invalidate the entire rule, although it clearly matched what is specified in MDN and W3C, but that's where the compromises end. The new font stacks are more sound and less intrusive (no moving-sans-serif-around anymore), yet still generates less CSS than the former solution with preprocessed global replacements. The only real addition is to properly override
<html lang>
when<tag lang>
is defined (with[lang]
rule), an issue introduced in go-gitea#13204 as browsers do not override:root
variables with:root :lang()
variables of the same names.As before, further testing is highly welcome, but I would consider this more mature than the previous solution (which already had
@font-face
rules for Japanese).