Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

register a font with Raphael using CSS3 @font-face

In my pages I often use custom fonts with the Raphaël .print with the .getFont. for SVG text, and the CSS3 @font-face (with Font Squirrel kits) for normal text. Is maybe possible to automatically register a font from the @font-face property, without create a JSON with Cufon?

I saw that in Font Squirrel kit there's the format('svg') used for old iPhone/iPad ("This is an XML format required by iOS devices before version 4.2.") maybe it could be useful also for desktop...

Thank you

like image 266
Mik Avatar asked Nov 05 '22 11:11

Mik


1 Answers

If you define a font using @font-face in your css, you can then apply it to a Raphaël paper.text object in this way :

var someText = paper.text(0, 0, 'this is some text');           
someText.attr({'font-family':'myCustomFont'});
like image 78
Choy Avatar answered Nov 09 '22 15:11

Choy