【问题标题】:Embedding fonts in iPad在 iPad 中嵌入字体
【发布时间】:2011-09-07 11:08:11
【问题描述】:

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

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

<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 中看起来不错。

【问题讨论】:

    标签: css ipad uiwebview embedded-fonts


    【解决方案1】:

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

    您必须使用 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

    还有一些关于将它与 Google 字体一起使用的信息: https://developers.google.com/webfonts/docs/webfont_loader

    【讨论】:

    • iOS 4.2 及更高版本支持 Webfont 加载器,因此这不适用于 iPad1。
    • @Bjorn。不对。 iPad1 不限于 iOS 4.2。
    【解决方案2】:

    问题在于 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');
    }
    

    【讨论】:

      【解决方案3】:

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

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

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

      【讨论】:

        猜你喜欢
        • 2011-02-28
        • 2013-03-17
        • 2023-04-04
        • 2011-05-28
        • 2014-11-06
        • 1970-01-01
        • 2012-07-07
        • 2013-02-23
        • 2010-10-12
        相关资源
        最近更新 更多