Skip to content

Commit d6316be

Browse files
committed
Revert "Fix CJK fonts again as per #12522"
Attempt to fix the issue with unicode-range This reverts commit 2ca3523.
1 parent 2ca3523 commit d6316be

File tree

4 files changed

+115
-42
lines changed

4 files changed

+115
-42
lines changed

templates/base/head.tmpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@
6767
<link rel="stylesheet" href="{{StaticUrlPrefix}}/css/easymde.css?v={{MD5 AppVer}}">
6868
{{end}}
6969
<link rel="stylesheet" href="{{StaticUrlPrefix}}/css/index.css?v={{MD5 AppVer}}">
70-
<script>
71-
if (navigator.userAgent.match('Windows')) { document.documentElement.style.setProperty('--fonts-system-ui', 'Segoe UI'); }
72-
</script>
7370
<noscript>
7471
<style>
7572
.dropdown:hover > .menu { display: block; }

web_src/less/_base.less

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
:root {
22
/* documented customizable variables */
3-
--fonts-proportional: var(--fonts-system-ui), "Roboto", "Helvetica Neue", "Arial", "Noto Sans", "Liberation Sans";
3+
--fonts-proportional: system-ui, -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", "Arial", "Noto Sans", "Liberation Sans", sans-serif;
44
--fonts-monospace: "SFMono-Regular", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
5-
--fonts-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla";
5+
--fonts-emoji: system-emoji;
66
/* other variables */
7-
--fonts-system-ui: system-ui, -apple-system; // will be replaced with "Segoe UI" if user agent is Windows
8-
--fonts-regular: var(--fonts-proportional), var(--fonts-emoji), sans-serif;
7+
--fonts-regular: var(--fonts-emoji), var(--fonts-proportional);
98
--border-radius: .28571429rem;
109
--opacity-disabled: .55;
1110
--color-primary: #4183c4;
@@ -116,42 +115,10 @@
116115
--checkbox-mask-indeterminate: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2 7.75A.75.75 0 012.75 7h10a.75.75 0 010 1.5h-10A.75.75 0 012 7.75z"></path></svg>');
117116
}
118117

119-
:root:lang(ja) {
120-
--fonts-regular: var(--fonts-proportional), var(--fonts-emoji), "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Source Han Sans JP", "Noto Sans CJK JP", "Droid Sans Japanese", "Meiryo", "MS PGothic", sans-serif;
121-
}
122-
123-
:root:lang(zh-CN) {
124-
--fonts-regular: var(--fonts-proportional), var(--fonts-emoji), "PingFang SC", "Hiragino Sans GB", "Source Han Sans CN", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", "Heiti SC", "SimHei", sans-serif;
125-
}
126-
127-
:root:lang(zh-TW) {
128-
--fonts-regular: var(--fonts-proportional), var(--fonts-emoji), "PingFang TC", "Hiragino Sans TC", "Source Han Sans TW", "Source Han Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", "Heiti TC", "PMingLiU", sans-serif;
129-
}
130-
131-
:root:lang(zh-HK) {
132-
--fonts-regular: var(--fonts-proportional), var(--fonts-emoji), "PingFang HK", "Hiragino Sans TC", "Source Han Sans HK", "Source Han Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", "Heiti TC", "PMingLiU_HKSCS", "PMingLiU", sans-serif;
133-
}
134-
135-
:root:lang(ko) {
136-
--fonts-regular: var(--fonts-proportional), var(--fonts-emoji), "Apple SD Gothic Neo", "NanumBarunGothic", "Malgun Gothic", "Gulim", "Dotum", "Nanum Gothic", "Source Han Sans KR", "Noto Sans CJK KR", sans-serif;
137-
}
138-
139-
@font-face {
140-
font-family: "Yu Gothic";
141-
src: local("Yu Gothic Regular"), local("Yu Gothic Medium");
142-
font-weight: 300;
143-
}
144-
145-
@font-face {
146-
font-family: "Yu Gothic";
147-
src: local("Yu Gothic Medium");
148-
font-weight: 400;
149-
}
150-
151118
@font-face {
152-
font-family: "Yu Gothic";
153-
src: local("Yu Gothic Bold");
154-
font-weight: 700;
119+
font-family: system-emoji;
120+
src: local("Apple Color Emoji"), local("Segoe UI Emoji"), local("Noto Color Emoji"), local("Twemoji Mozilla");
121+
unicode-range: ~"U+2310-329F, U+FE0?, U+1F000-1FAFF";
155122
}
156123

157124
textarea {

web_src/less/_font_i18n.less

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* font i18n */
2+
:root {
3+
/* customizable localized variables */
4+
:lang(ja) {
5+
--fonts-regular: var(--fonts-emoji), system-ui-ja, var(--fonts-proportional);
6+
}
7+
:lang(zh-CN) {
8+
--fonts-regular: var(--fonts-emoji), system-ui-zh-cn, var(--fonts-proportional);
9+
}
10+
:lang(zh-TW) {
11+
--fonts-regular: var(--fonts-emoji), system-ui-zh-tw, var(--fonts-proportional);
12+
}
13+
:lang(zh-HK) {
14+
--fonts-regular: var(--fonts-emoji), system-ui-zh-hk, var(--fonts-proportional);
15+
}
16+
:lang(ko) {
17+
--fonts-regular: var(--fonts-emoji), system-ui-ko, var(--fonts-proportional);
18+
}
19+
}
20+
21+
[lang] {
22+
font-family: var(--fonts-regular);
23+
}
24+
25+
each(@fonts, {
26+
@weights: .gen-weights-all(@value);
27+
@locale: replace(@key, "@", "-");
28+
.font-face-cjk(~"system-ui@{locale}", @weights[@light], 300);
29+
.font-face-cjk(~"system-ui@{locale}", @weights[@regular], 400);
30+
.font-face-cjk(~"system-ui@{locale}", @weights[@medium], 500);
31+
.font-face-cjk(~"system-ui@{locale}", @weights[@bold], 700);
32+
});
33+
34+
@fonts: {
35+
@ja:
36+
"HiraginoSans-:{W2,W4,W5,W6}", "Hiragino Kaku Gothic ProN :{W3,W6}",
37+
.shs("JP")[], .shs("J")[], .noto("JP")[], .shs("")[],
38+
/* https://acetaminophen.hatenablog.com/entry/2016/02/15/225009 */
39+
"Yu Gothic :{Regular,Medium,Medium,Bold}", "YuGothic :{Regular,Medium,Medium,Bold}",
40+
"Droid Sans Japanese:{}", "Meiryo:{, Bold}", "MS PGothic:{}";
41+
@zh-cn:
42+
.pingfang("SC")[],
43+
.shs("CN")[], .shs("SC")[], .noto("SC")[],
44+
"HiraginoSansGB-:{W3,W6}", "Hiragino Sans GB :{W3,W6}",
45+
"Microsoft YaHei:{ Light,, Bold}", "Heiti SC :{Light,Medium}", "SimHei:{}";
46+
@zh-tw:
47+
.pingfang("TC")[],
48+
.shs("TW")[], .shs("TC")[], .noto("TC")[],
49+
"HiraginoSansTC-:{W3,W6}", "Hiragino Sans TC :{W3,W6}",
50+
"Microsoft JhengHei:{ Light,, Bold}", "Heiti TC :{Light,Medium}", "PMingLiU:{}";
51+
@zh-hk:
52+
.pingfang("HK")[],
53+
.shs("HK")[], .shs("HC")[], .noto("HK")[], .shs("TC")[], .noto("TC")[],
54+
"Microsoft JhengHei:{ Light,, Bold}", "Heiti TC :{Light,Medium}", "PMingLiU_HKSCS:{}", "PMingLiU:{}";
55+
@ko:
56+
"AppleSDGothicNeo-:{Light,Regular,Medium,Semibold}",
57+
.shs("KR")[], .shs("K")[], .noto("KR")[],
58+
"NanumBarunGothic:{ Light,, Bold}",
59+
"Malgun Gothic:{ Semilight,, Bold}", "Nanum Gothic:{, Bold}", "Dotum:{}";
60+
}
61+
62+
.noto(@suffix) { @value: "Noto Sans CJK @{suffix} ", "NotoSansCJK@{suffix}-"; }
63+
.shs(@suffix) { @value: replace("Source Han Sans @{suffix} ", " ", " "), "SourceHanSans@{suffix}-"; }
64+
.pingfang(@suffix) { @value: "PingFang@{suffix}-:{Light,Regular,Medium,Semibold}"; }
65+
.font-face-cjk(@family, @src, @weight) {
66+
@font-face {
67+
font-family: @family;
68+
src: @src;
69+
font-weight: @weight;
70+
unicode-range: ~"U+11??, U+2E80-4DBF, U+AC00-D7FF, U+4E00-9FFF, U+FF00-FFEF, U+1F2??";
71+
}
72+
}
73+
74+
.gen-weights(@family) when (isstring(@family)) {
75+
@family-str: replace(@family, ":\{.*\}$", "");
76+
// apply standard style names if none is given
77+
// should the font have no styles, use :{}, as in "SimHei:{}"
78+
@weights-str: if(@family = @family-str, "Light,Regular,Medium,Bold", replace(@family, ".*:\{(.*)\}$", "$1"));
79+
@lightest: replace(@weights-str, ",.*", "");
80+
@boldest: replace(@weights-str, ".*,", "");
81+
@2ndboldest: replace(@weights-str, "(?:.*,|)([^,]*),.*$", "$1");
82+
@2ndlightest: if(@2ndboldest = @lightest, @lightest, replace(@weights-str, "^.*?,([^,]*).*", "$1"));
83+
84+
@light: local("@{family-str}@{lightest}");
85+
@regular: local("@{family-str}@{2ndlightest}");
86+
@medium: local("@{family-str}@{2ndboldest}");
87+
@bold: local("@{family-str}@{boldest}");
88+
}
89+
.gen-weights(@family) when not (isstring(@family)) {
90+
.gen-weights-all(@family);
91+
}
92+
.gen-weights(@family, @last) {
93+
@this: .gen-weights(@family);
94+
95+
@light: @last[@light], @this[@light];
96+
@regular: @last[@regular], @this[@regular];
97+
@medium: @last[@medium], @this[@medium];
98+
@bold: @last[@bold], @this[@bold];
99+
}
100+
.gen-weights-all(@family) when not (isstring(@family)) {
101+
.gen-weights-all(@family, length(@family));
102+
}
103+
.gen-weights-all(@family, 1) when not (isstring(@family)) {
104+
.gen-weights(extract(@family, 1));
105+
}
106+
.gen-weights-all(@family, @ctr) when not (isstring(@family)) and (@ctr > 1) and (@ctr <= length(@family)) {
107+
.gen-weights(extract(@family, @ctr), .gen-weights-all(@family, @ctr - 1));
108+
}

web_src/less/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@import "_svg";
1414
@import "_tribute";
15+
@import "_font_i18n";
1516
@import "_base";
1617
@import "_markdown";
1718
@import "_home";

0 commit comments

Comments
 (0)