Thursday, September 18, 2008

[javascript] Change text with custom font

There is no ability in html to change font to custom font. I am talking about font-family (e.g.: font-family: Arial). You can't change to other fonts that is not generic. So if you want to change font-family to for example Monotype Corsiva you can use my javascript code snippet.


Now you think what it is doing? It changes characters to images.

Example:

How to use:

First of all you need to make characters images with your desired font. Then add that script in the <head> </head> . In the arrays "a" and "b" change the values to your desired. First array is for "what to change", the second is "change to". And at the end use function customFont("className");. Use <span class="className">Here goes text</span> to change text inside span tag.

To understand it better i will give you a source code. Click here.

No comments: