📜 ⬆️ ⬇️

Use any font with javascript.

We all know the wonderful libraries sIFR3 and FLIR, which on the fly help to use any font on web pages.
However, from my point of view, their use (namely, installation and configuration) cannot be considered easy work.

Today I will talk about the library Typeface.js, which, as the name implies, works on pure JavaScript.


A bit of theory


The official site of the library Typeface.js - http://typeface.neocracy.org/ . On this resource you can find all the additional information.

How it works


The library is based on the vector drawing capabilities built into the browser. For quite a long time, browsers support vector graphics rendering, Firefox has support for canvas and SVG objects, and IE supports VML . Browser support announced by developer David Chester: Firefox 1.5+, Safari 2+, Internet Explorer 6+.
The library consists of two components: a perl module for converting truetype fonts into vector coordinates and a javascript file that renders text in a browser using a vector font description.
')

Benefits




Example


Training




Process



Everything, you can load the page in the browser and watch the result!
And here is an example of such a page entirely:
blockquote>
  1. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  2. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  3. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  4. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  5. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  6. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  7. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  8. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  9. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  10. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  11. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  12. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  13. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  14. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  15. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  16. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >
  17. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < title > </ title > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < script type ="text/javascript" src ="js/typeface-0.11.js" ></ script > <script type= "text/javascript" src= "js/als_agrus__regular.typeface.js" > </ script > </ head > < body > < div class ="myclass typeface-js" style ="font-family: ALSAgrus; font-size:40px;" > . </ div > < div > , < br /> Typeface.js ALS Agrus </ div > </ body > </ html >


For example, I use the ALS Agrus paid font to see the result in more complex fonts. What happened with me can be seen in the picture in the top.

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


All Articles