The only reliable way I have found to load fonts in the WebBrowser control on Windows Phone is to avoid loading them as a file.
Instead of using:
@font-face {
font-family: "MyFont";
src: url("fonts/myfont.woff?v=1.1") format("woff");
}
we use:
@font-face {
font-family: "MyFont";
src:url(data:application/x-font-woff;base64,xxPUT_BASE64_WOFF_DATA_HERExx) format("woff");
}
In javascript we create a style tag, put the CSS into the style tag, and append the style tag to the head. Helper function (I edited to make it plain JavaScript - I think correct):
function insertStyle(cssText) {
var styleElement = document.createElement('style');
styleElement.setAttribute('type', 'text/css');
styleElement.setAttribute('rel', 'stylesheet');
if (styleElement.styleSheet) { // IE11 IE docMode < 11
styleElement.styleSheet.cssText = cssText || '';
} else {
styleElement.appendChild(document.createTextNode(cssText || ''));
}
(document.head || document.getElementsByTagName('head')[0]).appendChild(styleElement);
}
I think that this is a nasty workaround, but it works (even in GDR2), and is easy to implement if you have a good build pipeline.
Note that we use this for iOS and Android too (we don't support Android 2.x). It seems to be a fairly robust solution.
For use with an html app (Ajax) served over the internet it has the great advantage that we can reliably detect if a javascript file has loaded and run correctly, whereas detecting if a CSS file (or font-face) has failed to fetch is very hard to do cleanly (cross-browser and backwards compatibly).
Also note, we use woff format for maximum backwards compatibility. There are lots of ttf to woff converters you can use. We don't need other formats because this code doesn't happen to be used by desktop browsers, and we don't support some obsolete devices.
Edit: If you want to use code to detect <= GDR1, you can use: https://stackoverflow.com/a/32431077/436776