Font-face does not work for me in Windows Phone 8 with Cordova/Phonegap.
Using the stock Cordova WP8 template, I added a simple font-face definition and set *
to use that font OR wingdings (to be extra clear that it's not working).
The file is in the /fonts
folder, set to build as "Content" and "Copy Always".
(wow that image is huge)
If I run this in Chrome, it loads the font properly:
Even if I run it in IE10 (or in IE9 Mode), it loads the font properly:
But, if I run it on the Windows Phone 8 Simulator, I get wingdings:
Any ideas? Workarounds? Should I just go ahead and jump off a bridge?
UPDATE:
Someone suggested using WOFF font format instead, so I went to http://www.font2web.com/ and converted my TTF font. I copied the new files into my www/fonts/
folder. As before, I made sure the "Build Action" is set to Content
and Copy Always
.
Also, I read something about trying to load the fonts after the deviceReady event fires. Worth a try... can't hurt anything.
Here's the css file called `fonts.css' that defines a new font-face with all the possible combinations:
Then, I edited the stock js/index.js
and added some script to dynamically load the new fonts.css
into the DOM after deviceReady:
BTW: loadjscssfile()
is a little script I got from http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml to load the contents of the fonts.css
file into the DOM.
I checked it in Internet Explorer 10/9, Chrome, and Firefox. After 3 seconds, the fonts change. I tried it in the Windows Phone 8 simulator. After 3 seconds, wingdings.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…