Skip to content
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

Fontstack with @font-face #5

Merged
merged 1 commit into from
Feb 14, 2021
Merged

Conversation

CL-Jeremy
Copy link
Owner

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).

Attempt to fix the issue with unicode-range

This reverts commit 2ca3523.
@CL-Jeremy
Copy link
Owner Author

Okay, testing in Windows 7 Japanese does still reveal the problem with the lacking weights, cf. go-gitea#12966... going to consider that as a non-issue now as Chromium/Chromium Edge now does the same even when I'm set to German locale for browser & Windows UI (uses Segoe UI Semibold for weight 500, which is against the rules. May also be a bug of Windows Insider build...

Merging this anyway.

@CL-Jeremy CL-Jeremy merged commit 8679303 into fontstack-var Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant