让网络字体在 HTML5 Windows Phone 应用程序上工作? [英] Getting a web-font to work on an HTML5 Windows Phone App?

查看:22
本文介绍了让网络字体在 HTML5 Windows Phone 应用程序上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 Windows Phone 8 HTML5 应用程序,用于在网络上显示一个外部网站.当页面加载时,它会显示所有内容以及正确的 css 样式,除了 web 字体.网络字体不包含在项目中,它是从网站在线运行的.另外,我知道 javascript 正在运行,因为其他 javascript 正在页面上运行.有谁知道让网络字体在应用程序内工作的解决方案?如果有帮助,当我将 Windows Phone 8 中的主 Web 浏览器定向到相关网页时,Webfonts 加载良好.

I'm building a Windows Phone 8 HTML5 app that shows an external website on the web. When the page loads, it shows all the content along with the correct css styling except for the web font. The web font is not included in the project, it is run from the website online. Also, I know javascript is running because other javascripts are working on the page. Does anyone know a solution to get web fonts working inside apps? If it helps, when I direct the main web browser in Windows Phone 8 to the webpage in question, the webfonts load fine.

推荐答案

自定义字体可以在 Windows Phone 8 HTML5 应用程序中使用,就像在网站和其他移动平台的 web 视图中使用一样.有两点需要注意,

Custom fonts can be used in Windows Phone 8 HTML5 apps in the same way as they are used on websites and other mobile platforms' webviews. There are two things to watch out for,

  1. 在 Visual Studio 中,确保字体的Properties>Advanced>Build Action 设置为Content",以便在构建和部署项目时将其复制到设备.
  2. 确保您使用的字体已获得嵌入许可,并且truetype 中的可嵌入标志font 设置为 0 以允许嵌入.iOS 和 Android 会忽略此可嵌入标签,但 IE10 会尊重它.
  1. Within Visual Studio make sure that the font's Properties>Advanced>Build Action is set to "Content" so it is copied to the device when the project is built and deployed.
  2. Make sure that the font you are using is licensed for embedding and that the embeddable flag in the truetype font is set to 0 to allow embedding. iOS and Android ignore this embeddable tag but IE10 respects it.

您可以使用开源的 TTFEdit 检查任何 truetype 字体的可嵌入标志.您可以通过将 View>Show>Advanced>Legal rights for embedding 中的值更改为 0 并重新保存来使字体可嵌入.仅当字体获得嵌入许可时才更改标志.

You can inspect the embeddable flag of any truetype font using the open-source TTFEdit. You can make a font embeddable by changing the value in View>Show>Advanced>Legal rights for embedding to 0 and re-saving it. Only change the flag if the font is licensed for embedding.

我已经用许多 truetype 字体进行了测试,没有任何问题.到目前为止,我唯一的问题是包含 font-awesome 库,其中 font-awesome.min.css 中的 src: 值需要更改以修复 IE10 移动版中的错误.使用 font-awesome 时,

I've tested with a number of truetype fonts with no problem. My only issue so far has been when including the font-awesome library where the src: values in font-awesome.min.css needed changing to fix a bug in IE10 mobile. When using font-awesome,

src:url('../fonts/fontawesome-webfont.ttf?v=4.0.3') 不起作用.src:url('../fonts/fontawesome-webfont.ttf') 会.

这篇关于让网络字体在 HTML5 Windows Phone 应用程序上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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