【发布时间】:2022-09-27 12:44:54
【问题描述】:
我需要导入字体(特别是在我的应用程序的 TTF 中),我从https://fonts.google.com/specimen/Montserrat 页面选择了“可变重量”版本,按钮“下载系列”。这个可变重量版本称为“Montserrat-VariableFont_wght.ttf”。
为什么font-weight 在这里不起作用?只有 2 个权重:正常和粗体,而不是所有的可变权重。为什么?
*_VariableFont_wght.ttf vesion 的目的不就是具有可变权重吗?
@font-face { font-family: Montserrat; src: url(Montserrat-VariableFont_wght.ttf); }
* { font-family: Montserrat; } /* for the snippet to work, we need a CDN link for this TTF file */
.w400 { font-weight: 400; }
.w500 { font-weight: 500; }
.w600 { font-weight: 600; }
.w700 { font-weight: 700; }
.w800 { font-weight: 800; }
<div class=\"w400\">weight 400</div>
<div class=\"w500\">weight 500</div>
<div class=\"w600\">weight 600</div>
<div class=\"w700\">weight 700</div>
<div class=\"w800\">weight 800</div>
从字体自述文件:
Montserrat 是具有此轴的可变字体:wght
这意味着所有样式都包含在这些文件中:
蒙特塞拉特-VariableFont_wght.ttf
标签: css fonts font-face google-font-api