在 Windows Phone 8 网络浏览器控件中使用 Google Webfonts [英] Using Google Webfonts in Windows Phone 8 web browser control

查看:19
本文介绍了在 Windows Phone 8 网络浏览器控件中使用 Google Webfonts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 Windows 手机应用程序中使用网络字体.从我阅读的评论中,我了解到无法使用嵌入到 XAP 文件中的字体.因此,我正在尝试打开一个包含 Google Web Fonts 的网页,该网页位于:http://omercelik.com/e.htm

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

当我在手机上从 Internet Explorer 打开此页面时,它正确显示了字体.但是当我尝试从 webBrowser 控件加载此页面时,它不会加载此页面.除了这个,我在我的应用上什么都不做:

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?

推荐答案

在使用 WebBrowser 控件时,如果您想获得正确的 IE10 行为(即不怪癖模式)在 Windows Phone 8...

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>

为了将来参考,Windows Phone 7 的 WebBrowser 控件(基于 IE9)不支持 Web 字体.

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

这篇关于在 Windows Phone 8 网络浏览器控件中使用 Google Webfonts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆