Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Adobe TypeKit fonts in an SVG object embedded in an HTML page

How can I use fonts from Adobe TypeKit in an SVG object embedded in an HTML page?

I'm able to use web fonts directly (e.g. via a google stylesheet: http://fonts.googleapis.com/css?family=Spicy+Rice), but TypeKit uses a different javascript-based loading strategy which doesn't seem to be applying font availability to the SVG object.

Is this possible, and if so, how can I go about doing this?

Thanks!

like image 616
EmpireJones Avatar asked Sep 09 '13 00:09

EmpireJones


People also ask

Can I use Adobe Fonts in HTML?

Web fonts from Adobe Fonts can be used on your websites, HTML email campaigns, articles in Google's AMP format, and many other types of projects where web fonts are supported.

How do I embed an Adobe font in HTML?

Add an Adobe Fonts to your SiteHead to your Adobe Fonts account. Select the font you want to include on your PageCloud site. Activate the font, and add the font to your Web Project. Copy the embed code provided in your Adobe Web Project.


1 Answers

SVG is stylable with CSS stylesheets, so you should be able to apply it that way.

And as long as the font is registered on the page, you can use textElToApplyFontTo.attr({ "font-family": "myFont" });

Note that IE<9 will likely have problems, I don't know much about VML font support. IE9+ has SVG support, so it should work with that, and all other modern [desktop] browsers.

One important thing to consider is that Typekit and other JS-based loading mechanisms work asynchronously, so fonts will only be available once they're loaded.

Some modern browsers won't load the font unless a DOM element is using it, so that may also be causing problems (you can try to load the font by using it on a DOM element, preferably above the SVG file. A dirty trick but it works...).

like image 140
imelgrat Avatar answered Oct 20 '22 00:10

imelgrat