Pergunta

I am trying to use CTFontDescriptorMatchFontDescriptorsWithProgressHandler to download a font. As same as the example provided by Apple: https://developer.apple.com/library/ios/samplecode/DownloadFont/Listings/DownloadFont_ViewController_m.html

It works fine, and I can display the downloaded font in my application, but after I restart my application I can not create the UIFont with fontWithName:size:, and [UIFont familyNames] does not include the downloaded font. To solve this problem, I record the font path and use CTFontManagerRegisterFontsForURL to register the font when start the application. After doing this, everything is OK on simulator, but not works on device!!! Help!!!

Foi útil?

Solução

Finally, I found the problem is that CTFontManagerRegisterFontsForURL will fail when the font file url is something like: /var/mobile/.../XXX.ttc, and after I fixed the url to be file:///var/mobile/.../XXX.ttc, everything will be OK.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top