简体   繁体   English

有效的字体系列名称

[英]Valid font-family names

I've made some research and I found this article , but it doesn't completely help me. 我进行了一些研究,发现了这篇文章 ,但并没有完全帮助我。 I am interested in what are valid characters that can be used for naming font families. 我对可用于命名字体系列的有效字符感兴趣。 Theoretically, can I use every character for naming, just by putting everything in quotation marks? 从理论上讲,我可以通过将所有内容都放在引号中来使用每个字符进行命名吗? How is with naming in practice? 在实践中命名如何?

Example: 例:

@font-face {
        font-family: '&This is my font 1234#!&&&';
        src: url('font.eot');
        src: url('font.eot?#iefix') format('embedded-opentype'),
             url('font.woff') format('woff'),
             url('font.ttf') format('truetype');
        font-weight: normal;
        font-style: normal;
}

I would also want to know if there are some standards, conventions used for naming font families? 我还想知道是否有一些用于命名字体系列的标准和约定?

The Mozilla page references the examples from the W3C page . Mozilla页面引用了W3C页面中的示例。

The only font family names which can be unquoted start with an Alpha [a-zA-Z] and contain ONLY alphanumerics afterwards [A-Za-z0-9] . 唯一可以取消引用的字体系列名称以Alpha [a-zA-Z]开头,之后仅包含字母数字[A-Za-z0-9] And possibly also the underscore ( _ ) as well. 可能还有下划线( _ )。

As for quoted, it is unspecified. 至于引用,则未指定。 One could assume anything goes, but who has any idea what browsers will actually accept? 可以假设一切都会发生,但是谁知道浏览器将实际接受什么呢? Best to include tests on supported browsers to ensure continual support and catch breakage quickly in development or user bug reports in new or less used browsers. 最好在受支持的浏览器上包括测试,以确保在新的或较少使用的浏览器中,持续不断的支持并迅速发现开发中的损坏或用户错误报告。

But it should never be absolutely necessary to use such characters which may increase the odds of breaking somewhere, now or in the future. 但是绝对不要绝对需要使用这样的字符,因为这些字符可能会增加现在或将来某个地方发生中断的可能性。 Such naming conventions are most definitely a code smell and need reconsideration. 这样的命名约定绝对是代码的味道,需要重新考虑。

The only restriction on double quoting is that it must quote the entire font family name, ie not "One Two" Three . 对双引号的唯一限制是它必须引用整个字体系列名称,即不能"One Two" Three I've also noticed sporadic breakage if quoting a name that has only Alpha or regex /[a-zA-Z][a-zA-Z0-9_]+/ . 如果引用仅包含Alpha或正则表达式/[a-zA-Z][a-zA-Z0-9_]+/的名称,我也会注意到零星的破损。 "One","Two","Three" , may or may not work, or partly work as expected, or may be fine. "One","Two","Three"可能有效或无效,或部分正常工作,或者可能很好。

Although only tangentially related, there is something that remains stupidly broken in many browsers: the monospace font. 尽管只是切线相关,但在许多浏览器中仍然有些愚蠢的问题: monospace字体。 According to this article - and my observation in Mozilla Firefox recent v58 nightly - this still remains the case. 根据这篇文章 -以及我每天晚上在Mozilla Firefox v58中的观察-仍然如此。 The monospace font is shrunk down way too much. monospace字体缩小得太多了。 The "fix" seems to be a hack where you specify monospace, monospace as the single font family, NO QUOTES. “修复”似乎是一种黑客,您可以将monospace, monospace指定为单个字体系列(没有报价)。 Quoting breaks the behavior and defaults to something like inherit or something different from either inherit or monospace. 引用会破坏行为,并且默认为继承或类似于继承或等宽之类的东西。 Quoting either monospace breaks it. 引用任一等宽字符都会破坏它。 Quoting both breaks it. 引用两者都会破坏它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM