css - iOS UIWebView totally fails to understand more than one @font-face? -


notice simple css/html being displayed in local uiwebview:

there's simulator showing it...

enter image description here

notice there 2 @font-face definitions.

but ... only second 1 works. if swap them around, second 1 works.

enter image description here

so here ...

@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'); } 

only "bbb" works, other 1 seems "cancelled". here ..

@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'); } 

only "aaa" works, other 1 seems "cancelled".

here's how in swift,

// load simple uiwebview (say, "about" or "legal" screen) // base in template.html import uikit import webkit class minorwebview:uiviewcontroller     {     @iboutlet var wv:uiwebview!     @ibinspectable var filename:string = "?"     // example, "about" "about.html"      ...     func makehtml()         {         print("making html ... " ,filename)          let oursize = grid.yoursizedecisionmechanism         let sizestring = string(format:"%.0f", oursize)          let p1 = nsbundle.mainbundle().pathforresource("template", oftype: "html")         var html:string = try! nsstring(contentsoffile:p1!, encoding:nsutf8stringencoding) string          let p2 = nsbundle.mainbundle().pathforresource(filename, oftype: "html")         let content:string = try! nsstring(contentsoffile:p2!, encoding:nsutf8stringencoding) string          html = html.stringbyreplacingoccurrencesofstring("stuff", withstring:content)         html = html.stringbyreplacingoccurrencesofstring("sizepoints", withstring:sizestring)          print("made html ---\n" ,html ,"\n------")          wv.loadhtmlstring(html string, baseurl:nil)         }     } 

simply drag "template.html" , "about.html" in project (just image); ensure have target membership.

you have error in <style> block: starts <meta> element. throw parser off; apparently thinks until first } bad , needs discarded.

solution: take <meta> out of <style>.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -