简体   繁体   English

什么是跨浏览器,跨平台的网络安全字体?

[英]What are cross-browser, cross platfom web safe fonts?

如何使跨浏览器,跨平台和所有设备兼容的css字体堆栈?

You cannot guarantee the fonts that will be used on a mobile device the same way you can guarantee which fonts are available on a normal computer. 您不能保证将在移动设备上使用的字体与保证普通计算机上可用的字体相同。

A safe bet is to use a generic font family that can be interpreted by the mobile browser to show you the relevant font, eg 一个安全的选择是使用可以由移动浏览器解释的通用字体系列来向您显示相关字体,例如

font-family: serif; /* (e.g., Times) */
font-family: sans-serif; /* (e.g., Helvetica) */
font-family: monospace; /* (e.g., Courier) */

最好的解决方案是在任何特定字体之后始终提供通用字体系列

font-family: "Foo Regular", "Bar Sans", sans-serif;

Maybe this link can give you some more ideas: 也许这个链接可以给你一些更多的想法:

http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html

Using the above font families never gave me problems. 使用上面的字体系列从未给我带来任何问题。

It points out in 15.3 of the W3C Recommendation regarding the 'font-family' property that you should have fallback fonts in a font stack so that your website visitor has some viable choices. 它在W3C建议书的15.3中指出了'font-family'属性,你应该在字体堆栈中有后备字体,以便你的网站访问者有一些可行的选择。

The 'web safe' font stacks I use, which cover most if not all devices are as follows: 我使用的'web safe'字体堆栈,涵盖了大多数(如果不是全部)设备,如下所示:

/* Web Safe Font Stacks (classes set in CSS) */
.head {font-family: Georgia,'Times New Roman',serif}
.para {font-family: Verdana,Arial,sans-serif}
.mono {font-family:'Courier New',Courier,monospace}
.fant {font-family: Papyrus,Impact,fantasy}
.curs {font-family:'Apple Chancery','Lucida Calligraphy',cursive}

This covers headers, paragraphs, monospace for code samples, fantasy for special items, and cursive for emphasis. 这包括标题,段落,代码样本的等宽,特殊项目的幻想和强调草书。 You may just need one for headers (H1~H6) and another for body text: 您可能只需要一个用于标题(H1~H6)而另一个用于正文:

body {font-family: Verdana,Arial,sans-serif}
h1, h2, h3, h4, h5, h6 {font-family: Georgia,'Times New Roman',serif}

Check the following cheatsheet from 2010 that includes Linux and iOS. 查看2010年包含Linux和iOS的以下备忘单。 It gives the average percentages for usage between Windows, Mac, Linux, and iOS: Web Safe Fonts 它给出了Windows,Mac,Linux和iOS之间平均使用百分比: Web安全字体

Forget about cross browser cross platform font stacks, the web examples usually only care about windows and OSX for basic latin, they fail on international languages and Linux, and new form factors. 忘掉跨浏览器的跨平台字体堆栈,Web示例通常只关心Windows和OSX的基本拉丁语,它们在国际语言和Linux上失败,以及新的外形。

Linux never used the same fonts as Windows and OSX for licensing reasons, and font design tools have become mature enough you find a lot of diversity nowadays (not that creating a large encoding font is easy, but a lot of users only care about fonts that cover their particular language). 出于许可的原因,Linux从未使用过与Windows和OSX相同的字体,字体设计工具已经变得足够成熟,你现在发现了很多不同的东西(并不是说创建一个大的编码字体很容易,但很多用户只关心那些字体涵盖他们的特定语言)。

Font creation has become cheap enough big corporations (including mobile manufacturers) now like to differentiate by commissioning new fonts for big releases (new device or major OS version). 字体创建已经变得足够便宜大公司(包括移动制造商)现在喜欢通过为大版本(新设备或主要操作系统版本)调试新字体来区分。

When font surveys were still popular the DejaVu font family had a lot of reach on Linux, that may not be the case anymore. 当字体调查仍然很受欢迎时,DejaVu字体系列在Linux上有很多功能,可能不再是这种情况了。 DejaVu and Arial have different metrics. DejaVu和Arial有不同的指标。

Just use generic CSS font families in your stack, avoid any helvetica derivative, do not use a design that depends on particular font metrics and you'll be ok. 只需在堆栈中使用通用的CSS字体系列,避免使用任何helvetica衍生产品,不要使用依赖于特定字体指标的设计,您就可以了。

Some "Web Safe Fonts" links from Google top: Google顶部的一些“Web安全字体”链接:

https://www.cssfontstack.com/ https://www.cssfontstack.com/

http://web.mit.edu/jmorzins/www/fonts.html http://web.mit.edu/jmorzins/www/fonts.html

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

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