如何在本地机器上测试网页,就像没有某种字体一样?
例如,我的网页使用Roboto字体。我的电脑已经本地安装了Roboto字体。我该如何查看在没有安装这种字体的电脑上,这个网页会是什么样子呢?
假设该字体不是通过CDN或其他方法包含在网页中。
暂时停用或卸载字体,或改变样式表以在从本地主机请求时不包含该声明。
Font Book.app
实用程序中右键单击以禁用字体,如 https://photos.app.goo.gl/9U7v9KdtCwZ3awfm8。 - Michael将CSS中的字体系列重命名,以便不再像这样定义字体系列 -
@font-face {
font-family: 'Roboto';
src: url('../fonts/roboto.eot');
src: url('../fonts/roboto.woff') format('woff'),
url('../fonts/roboto.ttf') format('truetype'),
url('../fonts/roboto.svg') format('svg');
font-weight: normal;
}
如果安装了Roboto字体,系统将使用它。把它更改为类似这样的东西 -
@font-face {
font-family: 'Roboto_web'; //notice the name here
src: url('../fonts/roboto.eot');
src: url('../fonts/roboto.woff') format('woff'),
url('../fonts/roboto.ttf') format('truetype'),
url('../fonts/roboto.svg') format('svg');
font-weight: normal;
}
因此,Roboto_web 字体不是安装在您系统中的字体,所以它将始终使用 Web 字体。这种方式您就不需要从系统中卸载或禁用此字体。
在 CSS 中,您可以像这样使用它 -
.sample_class{font-family:"Roboto_web"}
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">