font-name
属性的自定义值?e.g。如果我有适当工作的CSS:
@font-face
与
@font-face {
font-family: "foo";
src: url(foo.otf) format('otf');
}
的内容有关,或者将上述CSS更改为:是有效的。
font-family: "foo"
当然,我将更新对其他地方的所有参考。 IE。我将更改为
foo.otf
。某些上下文 在以下情况下,我遇到了问题。我有一个复杂的在线网站(网站A)。我正在为该网站开发一个微额定版本。该网站不希望我加载任何字体,并且在该网站的上下文运行时,我不想加载任何字体。
但是还有另一个网站(网站B),在我希望我的微额定字体上加载字体。 So, I need to have the
@font-face {
font-family: "bar";
src: url(foo.otf) format('otf');
}
section in my CSS.
现在,问题似乎是CSS中的某个地方的网站A具有font-family
,并且在加载字体之前,也会加载我的Microfrontend,即在其处理自己的font-family: "foo";
部分之前。 So, it seems to rely on my font-family: "bar";
to load the @font-face
font. And it fails due to CORS restrictions on the server which hosts my microfrontend. The CORS configruations can not be changed due to application domain, they are there as expected.
所以,我正在考虑在自定义字体名称的帮助下,将我的“@font-face”范围范围用于我的微额定,并担心检查是否是一种理智的方法。
https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family:
The value is used for name matching against a particular
font-family: "foo";
when styling elements using the @font-face
property.任何名称都可以使用,这覆盖了基础字体数据中指定的任何名称。
基本上,您可以指定要参考字体的名称。它不需要匹配所用字体的“固有”名称。