Using Google Webfonts in Windows Phone 8 web browser control

不问归期 提交于 2019-12-12 01:29:25

问题


I am trying to use web fonts in my Windows phone application. From the comments I have read, I understood that it is not possible to use fonts embedded into XAP file. So, I am trying to open a webpage that contains Google Web Fonts which is at: http://omercelik.com/e.htm

When I open this page from Internet Explorer on phone, it shows the font correctly. But when I try to load this page from a webBrowser control, it doesn't loads this page. I don't do anything else but this on my app:

    private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
    {
        webBrowser.Navigate(new Uri("http://omercelik.com/e.htm"));
    }

So, still no success to show custom fonts in my application. There are suggestions to host font remotely and cache but even without caching, I couldn't show fonts. Can someone provide a working example of this?


回答1:


When using the WebBrowser control, it's very important to include the HTML doctype if you want to get proper IE10 behaviour (ie. not quirks mode) in Windows Phone 8...

<!DOCTYPE html>
<html>
  <head>
    <style>
      @import url(http://fonts.googleapis.com/css?family=Tangerine);
    </style>
  </head>
  <body>
    <div id="para" style="font-family:'Tangerine', serif;">Making the Web Beautiful</div>
  </body>
</html>

For future reference, Windows Phone 7's WebBrowser control (based on IE9) does not support Web Fonts.




回答2:


It is possible to embed truetype fonts in Windows Phone 8 webapps by setting the embeddable tag on the font to 0 using software like TTFEdit. This might prove a more reliable and elegant solution to your problem.

See my answer to another Stack Overflow question here for all the details.



来源:https://stackoverflow.com/questions/15411808/using-google-webfonts-in-windows-phone-8-web-browser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!