How to use custom font in html pages for UIWebView?

I have a font file "Futura.ttf". I am displaying an HTML page in a UIWebView, but my requirement is that I want to use a custom font in my css file.

so is there a way i can use custom font in my css file ???

All suggestions are welcome.

Thanks.

+4
source share
2 answers

UIWebView user interface can load custom fonts in iOS3.2 and higher. Add the font to your kit (see here ), and then simply specify the font in your UIWebView style sheet, just like any other font:

<style type='text/css'>font { font-family: DroidSerif; } </style> 
+9
source

You have Cufon and sIFR as your options.

Typeface.js is a pure JavaScript replacement Cufon is a pure JavaScript sIFR replacement - Flash and Java implementation, FLIR JavaScript and PHP implementation

Some comparisons

Below is the question. It is worth reading the entire stream, it has great details.

Typeface.js

Benefits:

  • User must not have Flash plugin installed in browser
  • Easier to create just a few lines of Javascript
  • To load the page you just need to download Javascript

Disadvantages:

  • Text is not selected because it displays it as an image. I looked at some examples, right-click on the word and should have been seen as an image. Each word had this behavior. Thumbs down.
  • Using copy bodies slows down loading times, so it is recommended that you use only headers.
  • Not readable by screen readers
  • Visibility looks blurry.
  • Not all browser compatible and still have a lot of development. Done.

Sifr

Benefits:

  • It can be read by screen readers as a normal heading, because this is the level of behavior on top of the markup and style.
  • Text can be selected
  • SEO friendly
  • Displays text just like any other web font. Crispy and not blurry!
  • There are add-ons like jQuery sIFR Plugin!

Disadvantages:

  • Javascript required
  • Flash plugin must be installed in browser
  • Adobe Flash Studio is required for its creation BUT there is a pretty elegant sIFR generator that creates a file for you!
  • When loading the page, you need to request for Flash, Javascript and CSS files attached to it, which can potentially get bogged down if you use sIFR in too many places.
  • Unable to display on iPhone. Nonetheless...

Cuf贸n (similar to Typeface.js)

Introduce Cuf贸n, a Javascript-based font replacement solution that makes heavy use of canvas and VML. This is a great alternative to other solutions - no flash or image required.

There are some problems with using Cuf贸n on a real site, the most noticeable of which is the inability to select and copy / paste text, which is the biggest problem for your site users.

Combine this with EULA issues that prevent you from legally embedding fonts in Javascript files for most fonts on the market today.

Another problem is to know which fonts can be used with Cuf贸n. For sIFR, most fonts are fair play, as the font is embedded in the Flash movie, which is usually the approved use of most font foundries for most fonts. With Cuf贸n, the Javascript files used for the font can be easily "stolen" and used either on another website or in reverse engineering.

+1
source

Source: https://habr.com/ru/post/1286807/


All Articles