CJK语言支持困境 ——以Steam为例

NixOS CN Meetup #1 Presentation

幻灯片源码
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#import "@preview/touying:0.6.1": *
#import themes.metropolis: *
#import "@preview/codly:1.0.0": *
#import "@preview/codly-languages:0.1.8": *

#import "@preview/numbly:0.1.0": numbly

#set page(background: image("nix-wallpaper-nineish.src.svg"))
#set text(font: "Sarasa UI SC")
#set par(first-line-indent: 2em)
#set list(indent: 2em)
#let fake_par = {
      v(-1em)
      box()
    }

#show: codly-init.with()
#codly(zebra-fill: none)
#codly(fill: white.transparentize(50%))
#show raw: text.with(font: "JetBrainsMono NF")

#show: metropolis-theme.with(
  aspect-ratio: "16-9",
  footer: self => self.info.institution,
  config-info(
    title: [CJK语言支持困境],
    subtitle: [ #h(2em) ——以Steam为例],
    author: [Cryolitia],
    date: datetime(
      year: 2025,
      month: 08,
      day: 09,
    ),
    institution: [NixOS 社区],
  ),
  config-common(preamble: {
    codly(languages: codly-languages)
  }),
)

#show: touying-set-config.with(config-colors(
  primary: rgb("#4D6FB7"),
  primary-light: rgb("#5FB8F2"),
  secondary: black.transparentize(100%),
  neutral-lightest: black,
  neutral-dark: black,
  neutral-darkest: black,
))

#set heading(numbering: numbly("{1}.", default: "1.1"))

#title-slide()

#focus-slide[
  警告:非线性时间线
]


= 起

什么?2024年了NixOS上的Steam还不能用?

---

== 豆腐块

- #link("https://github.com/NixOS/nixpkgs/issues/178121")
- #link("https://github.com/Jovian-Experiments/Jovian-NixOS/issues/355")

#grid(
  columns: (1fr, 1fr),
  [#align(center, image("0001.png", width: 80%))],
  [#align(center, image("0002.png", width: 80%))],
)

== 字体

=== 文泉驿?

梦回初中

#link("https://wiki.archlinux.org/index.php?title=Steam&oldid=809160")

#align(center, image("0003.png", width: 70%))

#pagebreak()

=== Variable font?

#link("https://github.com/flathub/com.valvesoftware.Steam/issues/1070")

#align(center, image("0004.png", width: 60%))#align(center, image("0005.png", width: 60%))

= 承

上面提到的修复方法怎么都没用?

== 跑起来了……吗?

至少我们知道了如何向Steam提供正确的字体文件

#[

#show raw: text.with(size: 0.8em)

```nix
# pkgs/by-name/st/steam/package.nix
{
  extraPkgs ? pkgs: [ ], # extra packages to add to targetPkgs
}:
buildRuntimeEnv {
  pname = "steam";
  inherit (steam-unwrapped) version meta;

  extraPkgs = pkgs: [ steam-unwrapped ] ++ extraPkgs pkgs;
```

```nix
programs.steam.extraPkgs = p: (cfg.extraPackages ++ lib.optionals (prev ? extraPkgs) (prev.extraPkgs p));
```
]

但是?


== 如何证明他实际不能用

=== 找不同

#image("0006.png", width: 100%)

#[
#show raw: text.with(size: 0.5em)
```nix
    fontconfig = {
      defaultFonts = {
        emoji = [
          "Source Han Serif SC"
          "JetBrainsMono Nerd Font"
          "Noto Color Emoji"
        ];
        monospace = [
          "Source Han Serif SC"
          "Sarasa Mono SC"
          "JetBrainsMono Nerd Font Mono"
        ];
        sansSerif = [ "Source Han Serif SC" ];
        serif = [ "Source Han Serif SC" ];
      };
      cache32Bit = true;
    };
```
]

=== 俺寻思没问题

#image("0007.png", width: 100%)
#image("0008.png", width: 100%)

=== 再看看?

#align(center, image("0009.png", width: 50%))

== 我文件呢?

#[
#show raw: text.with(size: 0.5em)
```nix
fonts.fontconfig.localConf = ''
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <description>Load local customization file</description>
	<!-- Load local system customization file -->
	<match>
	    <test name="prgname" compare="contains" ignore-blanks="true">
		    <string>steam</string>
    	</test>
		<test name="family" compare="eq">
			<string>Arial</string>
		</test>
		<edit binding="same" mode="prepend" name="family">
			<string>sans-serif</string>
		</edit>
 	</match>
</fontconfig>
``
```
]

`$ strace -f steam:`

`[pid 11930] access("/etc/fonts/local.conf", R_OK) = -1 ENOENT (No such file or directory)`

---

这不是在这吗!

#align(center, image("0010.png", width: 80%))

= 转

盗梦空间

== 解铃还需系铃人

#link("https://github.com/ValveSoftware/steam-for-linux/issues/10422#issuecomment-1944396010")

#align(center, image("0011.png", width: 80%))

== 柳暗花明疑无路

#link("https://github.com/ValveSoftware/steam-for-linux/issues/10915")

#align(center, image("0012.png", width: 90%))

== 层层套娃

- NixOS
  - buildFHSEnv
    - Steam Linux Runtime

#line(length: 80%)

`/etc/fonts/local.conf` or `.config/fontconfig/fonts.conf`, that is the question.

= 合
愉快的游玩CJK游戏吧!
---

== 合并!

#link("https://github.com/NixOS/nixpkgs/pull/312268")

#[
#show raw: text.with(size: 0.8em)
```nix
fontPackages = lib.mkOption {
      type = lib.types.listOf lib.types.package;
      default = config.fonts.packages;
      defaultText = lib.literalExpression "fonts.packages";
      example = lib.literalExpression "with pkgs; [ source-han-sans ]";
      description = ''
        Font packages to use in Steam.
        Defaults to system fonts, but could be overridden to use other fonts — useful for users who would like to customize CJK fonts used in Steam. According to the [upstream issue](https://github.com/ValveSoftware/steam-for-linux/issues/10422#issuecomment-1944396010), Steam only follows the per-user fontconfig configuration.
      '';
    };
```
]

== 问题看起来完美的解决了!

但是……以后呢……

#align(center, image("0013.png", width: 90%))

`nixpkgs-cjk-maintainer team` 可能性微存

#focus-slide[
  完结&提问 \
  #line(length: 80%)
  #set text(size: 0.8em)
  特别感谢 `@CoelacanthusHex` (aka 浅见沙织)的帮助
]
Image 01
Image 02
Image 03
Image 04
Image 05
Image 06
Image 07
Image 08
Image 09
Image 10
Image 11
Image 12
Image 13
Image 14
Image 15
Image 16
Image 17
Image 18
Image 19
Image 20
Image 21
Image 22
Licensed under CC BY-NC-SA 4.0
Last updated on 2025-08-16
Built with Hugo
Theme Stack designed by Jimmy