简体   繁体   English

IE8或更低版本中的Google Webfonts(加载程序)

[英]Google Webfonts (Loader) in IE8 or lower

I'm trying to load about 40 fonts for a web project. 我正在尝试为一个网络项目加载大约40种字体。 People will have the ability to choose between custom fonts in a web shop. 人们将能够在网上商店中的自定义字体之间进行选择。 I use the Web Font Loader from Google and it works well, except in IE8 and lower. 我使用了Google的Web Font Loader,它运行良好,但IE8及更低版本除外。

So I'm printing my php array with the correct font-families that the Webfont Loader needs to load from Google. 因此,我正在使用Webfont Loader需要从Google加载的正确字体系列打印我的php数组。 If I try to load all 40 fonts, it works in all browsers except in Internet Explorer 8 and below. 如果我尝试加载所有40种字体,则它可以在所有浏览器中使用,但Internet Explorer 8及以下版本除外。

If I limit my font-array to 6 fonts, then those 6 fonts get loaded. 如果我将字体数组限制为6种字体,则将加载这6种字体。 But when I just add one more font to the array IE8 can't load the fonts. 但是当我只向数组中添加另一种字体时,IE8无法加载字体。 I get a Bad Request in my "Network"-tab from the developer tools, yet my url in the http-request seems OK. 我从开发人员工具的“网络”选项卡中收到一个错误请求,但是我在http请求中的网址似乎正常。

Somebody else had had this problem before? 以前有人遇到过这个问题吗? Is the length of a Request URL in a HTTP-Header limited in IE8 and below? IE8和更低版本中的HTTP标头中的请求URL的长度是否受到限制?

<script type="text/javascript">
  WebFontConfig = {
       google: { families: /*json_encode(php array here)*/ },
  };
  (function() {
      var wf = document.createElement('script');
      wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
               '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
      wf.type = 'text/javascript';
      wf.async = 'true';
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(wf, s);
  })();
</script>

I also tried to paste all the families in one 'link'. 我还尝试将所有家庭粘贴到一个“链接”中。 But also.. a Bad Request in IE8 and below. 而且.. IE8及以下版本中的错误请求。

<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family= /* families */">

The request with %7 as '|' %7为“ |”的请求 and the response: 和响应:

GET /css?family=Aclonica%7CAveria+Serif+Libre%7CBoogaloo%7CCandal%7CCantora+One%7CCapriola%7CCarter+One%7CChewy%7CCoda+Caption:800%7CComfortaa%7CCourgette%7CCreepster%7CCrete+Round%7CDamion%7CDays+One%7CFrancois+One%7CFredoka+One%7CGalindo%7CGloria+Hallelujah%7CIndie+Flower%7CIrish+Grover%7CJust+Me+Again+Down+Here%7CLeckerli+One%7CLobster+Two%7CLondrina+Solid%7CLove+Ya+Like+A+Sister%7CMcLaren%7CMiniver%7CPiedra%7CPlaster%7CPoiret+One%7CQuantico%7CRacing+Sans+One%7CRadley%7CRammetto+One%7CRevalia%7CSchoolbell%7CSmokum%7CSniglet%7CStint+Ultra+Condensed%7CSue+Ellen+Francisco%7CUbuntu+Mono%7CUltra%7CUnifrakturCook:700%7CWaiting+for+the+Sunrise%7CYesteryear HTTP/1.1

https://docs.google.com/open?id=0B4anyChu_EhkRFNmRmd3UGY4RlU https://docs.google.com/open?id=0B4anyChu_EhkRFNmRmd3UGY4RlU

And what I think is really weird: I get the correct data back from Google in the ResponseBody.. 我觉得这很奇怪:我从ResponseBody的Google那里获得了正确的数据。

https://docs.google.com/open?id=0B4anyChu_EhkdFVqVjFVUVhFRWs https://docs.google.com/open?id=0B4anyChu_EhkdFVqVjFVUVhFRWs

Solved by loading 5 fonts at a time with WebFontLoader only in IE8 and below. 通过仅在IE8及更低版本中使用WebFontLoader一次加载5种字体来解决。

      <script src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
      <script>
        <?php
          $splitArrays = array_chunk($families, 5);
          foreach ($splitArrays as $id => $split) {
            echo 'WebFont.load({google:{families: ' . json_encode($split) . '}});';
          }
        ?>
      </script>

Google Web Fonts don't work in IE8 . Google Web字体在IE8中不起作用 This article also describes how loading several fonts via a '<link>' tag fails in IE8 - therefore this bug appears not to be specific to using the web fonts loader. 本文还介绍了如何在IE8中通过“ <link>”标记加载几种字体失败-因此,此错误似乎并非特定于使用Web字体加载器。

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

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