2

我正在尝试将 Google 字体嵌入 iPad 的 WebView 中。

如果我把它放在头上一切正常:

<link href='http://fonts.googleapis.com/css?family=Monofett' rel='stylesheet' type='text/css'>

html 是本地的,然后我需要在我的 iPad 中复制 CSS 和字体。

当我这样做时,字体不起作用:

html:

<link href='fonts/fonts.css' rel='stylesheet' type='text/css'>

字体/fonst.css:

@font-face {
  font-family: 'Monofett';
  font-style: normal;
  font-weight: normal;
  src: local('Monofett'), url('http://themes.googleusercontent.com/static/fonts/monofett/v1/94n9d8-lEEaOz-Sn4plHGPesZW2xOQ-xsNqO47m55DA.woff') format('woff');
}

我知道我仍在进行远程连接,但为什么不起作用?

网络在 Safari 和 Firefox 中看起来不错。

4

3 回答 3

2

男孩,我有一个很好的答案给你!我有同样的问题,这就像一个魅力。

您必须使用 Google API 加载程序。这是我放入标题标签的代码。

<!-- Google API Loader -->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>

<script type="text/javascript">
    //load jQuery
    google.load("jquery", "1.7.1");

    //Google Fonts
    google.load("webfont", "1");

    google.setOnLoadCallback(function() {
        WebFont.load({
            google: {
              families: [ 'Lobster+Two:700italic,700,400italic,400', 'Alegreya:400,400italic,700' ]
            }
        });
    });
    </script>

以下是有关 API 加载器的一些信息: https ://developers.google.com/loader/?hl=ja#intro

以及一些关于使用谷歌字体的信息: https ://developers.google.com/webfonts/docs/webfont_loader

于 2012-03-13T12:29:38.867 回答
1

问题是 woff 格式。谷歌知道这一点,当你在 PC 或 iPad 上使用 Safari 时,他会返回一个不同的 CSS。正确的 CSS 是:

@font-face {
 font-family: 'Monofett';
 font-style: normal;
 font-weight: normal;
 src: local('Monofett'), url('./BezoWS-9nng_g31KmAteQ3YhjbSpvc47ee6xR_80Hnw.ttf') format('truetype');
}
于 2011-09-08T13:21:38.107 回答
0

这是一个 cwTeXHei 版本,用于在 iPhone 浏览器上支持谷歌网络字体

@font-face {
  font-family: 'cwTeXHei';
  font-style: normal;
  font-weight: normal;
  src: local('cwTeXHei'), url('./fonts/cwTeXHei-zhonly.ttf') format('truetype');
}

url 将从 css 文件夹开始。
这适用于 ios 10 Safari
感谢 Brais Gabin。

于 2017-08-24T17:02:41.293 回答