Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to embed font files into html just like css?

In a project I work on, I need to generate a one page HTML file which contains everything inside it (JavaScript code, CSS, Images, etc.). So, there should be no outside references.

I am also planning to use Bootstrap but I am not sure if it is possible to embed font files inside HTML just like CSS.

Any idea?

like image 353
tugberk Avatar asked Mar 30 '15 15:03

tugberk


1 Answers

Yes, that's actually possible. You can embed the font as a base64 encoded font like this:

@font-face{
    font-family: FontName;
    src: url(data:font/ttf;base64,THESTRING… ) format('truetype');
}

But it's not advisable as the base64 string can get rather big and cause performance issues.

like image 53
damian Avatar answered Oct 06 '22 01:10

damian