2012-09-24 44 views
2

我正在尝试为Web项目加载大约40种字体。人们将有能力在网上商店中选择自定义字体。我使用谷歌的Web Font Loader,它运行良好,除了IE8和更低版本。在IE8或更低版本中的Google Webfonts(Loader)

因此,我打印了我的php数组,其中包含Webfont加载器需要从Google加载的正确字体系列。如果我尝试加载全部40种字体,则可以在除Internet Explorer 8及更低版本以外的所有浏览器中使用。

如果我将字体数组限制为6种字体,那么这6种字体会被加载。但是,当我只是添加一个字体的数组IE8无法加载字体。我在开发人员工具中的“网络”选项卡中收到了错误的请求,但是http请求中的网址似乎正常。

别人之前有过这个问题吗? HTTP-Header中的请求URL的长度是否限于IE8及更低版本?

<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> 

我也尝试在一个'链接'中粘贴所有的家庭。但也是..在IE8及以下的错误请求。

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

用7%作为请求 '|'和响应:

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

而且我认为是很奇怪:我得到正确的数据来自谷歌早在ResponseBody ..

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

回答

1

通过加载5解决一次只能在IE8及以下版本的WebFontLoader中使用字体。

 <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。本文还介绍如何通过''链接>'标记加载多个字体在IE8中失败 - 因此此错误似乎不是特定于使用Web字体加载器。

相关问题