plicatibu Posted October 25, 2013 Share Posted October 25, 2013 I'm wondering how do you guys handle fonts in HTML games. In Android it's just a matter of put the TTF in assets folder and load them. Regards. Quote Link to comment Share on other sites More sharing options...
YellowAfterlife Posted October 25, 2013 Share Posted October 25, 2013 You can use web fonts. With enough font files provided, most of target devices and browsers will be able to load the correct font. There's also a workaround though - use bitmap fonts. That is, all relevant glyphs are rendered into a texture sheet, and then drawn accordingly to display separate characters. Implementations of popular formats like BMFont exist for most of commonly used frameworks. Second method may require slightly more memory for larger fonts, but gives consistent results regardless of browser and device rendering specifics. Quote Link to comment Share on other sites More sharing options...
onefrankguy Posted October 26, 2013 Share Posted October 26, 2013 If you already have the TTF, and own the redistribution and embedding rights for it, Font Squirrel will do the conversion to a webfont for you.http://www.fontsquirrel.com/tools/webfont-generator Quote Link to comment Share on other sites More sharing options...
plicatibu Posted October 26, 2013 Author Share Posted October 26, 2013 onefrankguy, thank you for the tip. It will be very useful. Quote Link to comment Share on other sites More sharing options...
spelagon Posted October 26, 2013 Share Posted October 26, 2013 I typically have this inline code in main html file: <style type="text/css"> @font-face { font-family: "kenpixel"; font-weight: normal; src: url("./assets/kenpixel.woff") format("woff"), url("./assets/kenpixel.otf") format("opentype"); } </style>woff is for Firefox if I remember correctly. Most other browsers can load otf fonts. There are many online tools to convert from ttf to these formats. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.