embed web font just like @sprite

178 views
Skip to first unread message

Andrey Korzhevskiy

unread,
Aug 21, 2012, 8:33:05 AM8/21/12
to google-we...@googlegroups.com
Is there a way to embed font file into css via data-uri just like @sprite does it to embed images?
i mean if i write this:

@font-face {
    font-family: 'MyFont';
    src: url(MySuperWebFont.otf);
}

then gwt would generate css like this:

@font-face {
    font-family: ' MyFont ';
    src: url("data:font/opentype;base64,[base-encoded font here]");
}

Thanks.


Thomas Broyer

unread,
Aug 21, 2012, 8:37:17 AM8/21/12
to google-we...@googlegroups.com


On Tuesday, August 21, 2012 2:33:05 PM UTC+2, Andrey Korzhevskiy wrote:
Is there a way to embed font file into css via data-uri just like @sprite does it to embed images?

Sure: use a DataResource and the @url CssResource @-rule.

Thomas Broyer

unread,
Aug 21, 2012, 8:39:15 AM8/21/12
to google-we...@googlegroups.com
Note you'll have to use GWT 2.5.0-rc1 to be able to use @font-face in a CssResource, see http://code.google.com/p/google-web-toolkit/issues/detail?id=5247 (and note how I made the exact same answer there a couple months back ;-) ) 

Andrey Korzhevskiy

unread,
Aug 21, 2012, 8:44:02 AM8/21/12
to google-we...@googlegroups.com
Yeah, right, thank you but...

One can use @sprite images without explicit declaring in DataResources etc.

Reply all
Reply to author
Forward
0 new messages