2

我想使用 Arial 旁边的嵌入字体作为替代。嵌入的字体需要更大的字体大小。

对于同一个元素,我如何确保 Arial 显示为 15pt,而 Bebas 显示为 20pt。(对于同一段文字)

谢谢!

*让我进一步解释:

我有一串文字。我希望它显示为 Bebas 或 Arial。当 Arial 作为替代加载时,它需要具有不同的字体大小和粗细,因为共享字体大小不适用于这些字体(Bebas 很小)。

4

1 回答 1

1

You could use a script like FontChecker to check if a font is available. It relies on MooTools and gets called like this:

window.addEvent('domready',function() {
  var fc = new FontChecker();
  if (!fc.check('Bebas')) {
    $$('.someclass').setStyles({'font-size': '15pt'});
  }
});

If Bebas isn't available, it sets the font size for all elements with class someclass to 15pt.

Your CSS file:

.someclass {
  font-family:Bebas,Arial,sans-serif;
  font-size:20pt;
}

If you don't use MooTools, maybe there's a similar script for other libraries or vanilla JS (=plain JS without libraries). Or just rewrite it, it's quite short.

edit:

Some other scripts (I don't know them, I only use FontChecker):

于 2013-10-17T15:28:59.517 回答