2

我正在尝试了解字体粗细,以便我可以从 Google 字体中请求特定的字体粗细。

我已经在 Ubuntu 16 上安装了所有 Google 字体(所有 TrueType),如果我这样做了:

fc-list : family : weight

然后我得到这样的结果:

Nunito,Nunito Black:weight=210
Nunito,Nunito ExtraBold:weight=205
Nunito,Nunito ExtraLight:weight=48
Nunito,Nunito Light:weight=50
Nunito,Nunito SemiBold:weight=180
Nunito Sans,Nunito Sans Black:weight=210
Nunito Sans,Nunito Sans ExtraBold:weight=205
Nunito Sans,Nunito Sans ExtraLight:weight=48
Nunito Sans,Nunito Sans Light:weight=50
Nunito Sans,Nunito Sans SemiBold:weight=180
Nunito Sans:weight=200
Nunito Sans:weight=80
Nunito:weight=200
Nunito:weight=80
OdorMeanChey:weight=80
Offside:weight=80
OFL Sorts Mill Goudy TT:weight=100
Oldenburg:weight=80
Old Standard TT:weight=200
Old Standard TT:weight=80
Oleo Script Swash Caps:weight=200
Oleo Script Swash Caps:weight=80
Oleo Script:weight=200
Oleo Script:weight=80
Open Sans Condensed,Open Sans Condensed Light:weight=50
Open Sans Condensed:weight=200
Open Sans Hebrew Condensed,Open Sans Hebrew Condensed Extra Bold:weight=205
Open Sans Hebrew Condensed,Open Sans Hebrew Condensed Light:weight=50
Open Sans Hebrew Condensed:weight=200
Open Sans Hebrew Condensed:weight=80
Open Sans Hebrew,Open Sans Hebrew Extra Bold:weight=205
Open Sans Hebrew,Open Sans Hebrew Light:weight=50
Open Sans Hebrew:weight=200
Open Sans Hebrew:weight=80
Open Sans,Open Sans ExtraBold:weight=205
Open Sans,Open Sans Light:weight=50
Open Sans,Open Sans SemiBold:weight=180
Open Sans:weight=200
Open Sans:weight=80
Oranienbaum:weight=80
Orbitron,Orbitron Black:weight=210
Orbitron,Orbitron Medium:weight=100
Orbitron:weight=200
Orbitron:weight=80
Oregano:weight=80
Orienta:weight=80
Original Surfer:weight=80
Oswald,Oswald ExtraLight:weight=48
Oswald,Oswald Light:weight=50
Oswald,Oswald Medium:weight=100
Oswald,Oswald SemiBold:weight=180

看起来很多情况下默认的粗细似乎是 80(我预计默认为 400 正常),而其他字体粗细则到处都是。

我曾期望 fc-list 报告的字体权重与此页面上的“通用权重名称映射”相对应:https ://developer.mozilla.org/en-US/docs/Web/CSS/font-weight但是显然他们没有。

Value   Common weight name
100 Thin (Hairline)
200 Extra Light (Ultra Light)
300 Light
400 Normal
500 Medium
600 Semi Bold (Demi Bold)
700 Bold
800 Extra Bold (Ultra Bold)
900 Black (Heavy)

所以我的第一个问题是为什么报告的字体粗细与上面的地图不对应?

第二个问题,考虑到它们不匹配,而我的 TrueType 字体直接来自 Google Fonts,如果我想从 Google Fonts 请求字体,我应该指定什么重量 - 上面映射表中的重量,或者报告的重量通过 fc 列表?

4

1 回答 1

0

FontConfig使用自己的内部权重系统,可以根据下表映射值。表中的常量是使用fontconfig header手动翻译的。

0    <-> (0) FC_WEIGHT_THIN
100  <-> (0) FC_WEIGHT_THIN
200  <-> (40) FC_WEIGHT_EXTRALIGHT, FC_WEIGHT_ULTRALIGHT
300  <-> (50) FC_WEIGHT_LIGHT
350  <-> (55) FC_WEIGHT_DEMILIGHT, FC_WEIGHT_SEMILIGHT
380  <-> (75) FC_WEIGHT_BOOK
400  <-> (80) FC_WEIGHT_REGULAR, FC_WEIGHT_NORMAL
500  <-> (100) FC_WEIGHT_MEDIUM
600  <-> (180) FC_WEIGHT_DEMIBOLD, FC_WEIGHT_SEMIBOLD
700  <-> (200) FC_WEIGHT_BOLD
800  <-> (205) FC_WEIGHT_EXTRABOLD, FC_WEIGHT_ULTRABOLD
900  <-> (210) FC_WEIGHT_BLACK, FC_WEIGHT_HEAVY
1000 <-> (215) FC_WEIGHT_EXTRABLACK, FC_WEIGHT_ULTRABLACK
于 2021-11-17T21:22:10.330 回答