iOS UIWebView ne parvient pas à comprendre plus d'un @ font-face?

Notez ce simple css / html qui est affiché dans un UIWebView local:

il y a le simulateur qui le montre …

entrez la description de l'image ici

Notez qu'il existe deux définitions de font-face @.

Mais … seulement le second fonctionne. Si vous les échangez, seul le second fonctionne.

entrez la description de l'image ici

Alors là …

@font-face { font-family:'aaa'; src: local('SourceSansPro-Regular'), url('SourceSansPro-Regular.ttf') format('truetype'); } @font-face { font-family:'bbb'; src: local('SourceSansPro-BoldIt'), url('SourceSansPro-BoldItalic.ttf') format('truetype'); } 

seulement "bbb" fonctionne , l'autre semble être "annulé". Alors là ..

 @font-face { font-family:'bbb'; src: local('SourceSansPro-BoldIt'), url('SourceSansPro-BoldItalic.ttf') format('truetype'); } @font-face { font-family:'aaa'; src: local('SourceSansPro-Regular'), url('SourceSansPro-Regular.ttf') format('truetype'); } 

seulement "aaa" fonctionne , l'autre semble être "annulé".

Voici comment le faire dans Swift,

 // load a simple UIWebView (say, an "about" or "legal" screen) // base is in template.html import UIKit import WebKit class MinorWebView:UIViewController { @IBOutlet var wv:UIWebView! @IBInspectable var filename:Ssortingng = "?" // for example, "about" for "about.html" ... func makeHtml() { print("making html for ... " ,filename) let ourSize = grid.yourSizeDecisionMechanism let sizeSsortingng = Ssortingng(format:"%.0f", ourSize) let p1 = NSBundle.mainBundle().pathForResource("template", ofType: "html") var html:Ssortingng = try! NSSsortingng(contentsOfFile:p1!, encoding:NSUTF8SsortingngEncoding) as Ssortingng let p2 = NSBundle.mainBundle().pathForResource(filename, ofType: "html") let content:Ssortingng = try! NSSsortingng(contentsOfFile:p2!, encoding:NSUTF8SsortingngEncoding) as Ssortingng html = html.ssortingngByReplacingOccurrencesOfSsortingng("STUFF", withSsortingng:content) html = html.ssortingngByReplacingOccurrencesOfSsortingng("SIZEPOINTS", withSsortingng:sizeSsortingng) print("Made html like this ---\n" ,html ,"\n------") wv.loadHTMLSsortingng(html as Ssortingng, baseURL:nil) } } 

Faites simplement glisser "template.html" et "about.html" dans le projet (comme vous le feriez avec une image); assurez-vous qu'ils ont une adhésion cible.

Vous avez une erreur dans le bloc <style> : il commence par un élément <meta> . Cela va jeter l'parsingur; apparemment, il pense que tout est mauvais et doit être abandonné.

Solution: sortez la <meta> du <style> .