我使用的是一种叫做Track
的字体。我有一个正在生产中的create-react-app。该字体可在某些浏览器上使用。我已经通过数字海洋建立了自己的s3存储桶来帮助我提供静态文件。我认为最好也将字体文件下载到同一存储桶中,然后使用URL将其提供给我的生产应用程序。
下面是我如何设置我的index.css
@font-face {
font-family: 'Track';
src: local('Track') url('https://.../fonts/Track-Regular.ttf') format('truetype');
}
然而,这是行不通的。目前只需在safari移动浏览器中查看Times New Roman字体。
我是不是做错了什么?
发布于 2021-05-24 20:56:03
只需添加这个。它将字体应用于组件。
div {
font-family: 'Track';
}
相反,添加这个应该会更好。
/* cyrillic */
@font-face {
font-family: 'Pattaya';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/pattaya/v6/ea8ZadcqV_zkHY-XBdOt9kRHiVqtCg.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* thai */
@font-face {
font-family: 'Pattaya';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/pattaya/v6/ea8ZadcqV_zkHY-XBcOt9kRHiVqtCg.woff2) format('woff2');
unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
/* vietnamese */
@font-face {
font-family: 'Pattaya';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/pattaya/v6/ea8ZadcqV_zkHY-XBdit9kRHiVqtCg.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Pattaya';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/pattaya/v6/ea8ZadcqV_zkHY-XBdmt9kRHiVqtCg.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Pattaya';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/pattaya/v6/ea8ZadcqV_zkHY-XBdet9kRHiVo.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
https://stackoverflow.com/questions/67644257
复制相似问题