Can We Use True Type Fonts

Monkey Forums/Monkey Programming/Can We Use True Type Fonts

c.k.(Posted 2012) [#1]
Is there a way for us to use True Type fonts (or fonts that we can specify the size for and then render to screen)?

If not, what about using Web fonts (http://www.google.com/webfonts/). That should be easy! :-)


Nobuyuki(Posted 2012) [#2]
unfortunately, supporting a consistent font metric across all platforms using truetype format isn't as easy as it may seem. Subtle things like differences in hinting, subpixel rendering, system DPI and such throw off casual attempts to have consistent text through basic system calls. Don't expect Mark to implement something like freetype2, either. It's just too much hassle compared to throwing some raster fonts up there, and kinda goes against the "basic and consistent" mentality of mojo.

There's nothing stopping you from making the proper system call hooks on the various platforms yourself, though. It might be a pain getting the Extern code importing the font resources to work, since that works differently on pretty much every platform, but the blit routines might be relatively similar once you have a handle to the font location. Expect to run into the issues I pointed out above, unless implementing a full cross-platform type rasterizing lib.


c.k.(Posted 2012) [#3]
There's an HTML5 product called Construct 2 that is able to use web fonts. I thought it would be easy to add something like that for monkey. But I see what you're saying.

We still need a way to scale fonts. I'd like to be able to use one font for multiple interface elements, some of which need the font size smaller and some larger.

All the games I play on my phone- do they all use bitmap fonts (and therefore, all different sizes of the same font is loaded)? or do you think they have some kind of rendering so they can use all different sizes with just one font file?


Tibit(Posted 2012) [#4]
Super tiny fonts for small text usually needs to be rendered for that purpose to looks really good.

For other kinds of non paragraph text you can often get away with loading a bigger font and scale it.

However I have found that 3ish fonts is enough for most games I make atm so I simple load three fonts, in three sizes, that looks different and use that.

If you have a game that have high demands in the design for many different fontsizes then that might hint that text is an important part of your game design and then maybe it is well worth the extra bytes to have those fonts made for their purpose - with font, color, shadow, italic, color, fade and so on using a bitmap font?

What are the specific use case you had in mind?


Beaker(Posted 2012) [#5]
Don't forget that often some in-game text doesn't use fonts at all, but uses pre-rendered screens and/or words (think "SCORE"), often in combination with some dynamic text using bitmap fonts. Also, you can reduce your games need for text (and increase your international appeal, as well as shrink your game package) by judicious use of icons.

Are you only interested in the HTML5 target? Obviously the solution for each target would be quite different.


NoOdle(Posted 2012) [#6]
A lot of games render text using sprite sheets now. It was the Cocos2D way as well.

Although its more hassle to get working initially, I actually prefer using sprite sheets and making them has been made much easier with programs like GlyphDesigner. My text looks so much better and I have more control over what I can do with it. The size problem you mention is an issue but a minor one from experience, you can get away with scaling by quite a bit before it fudges the text.


Tibit(Posted 2012) [#7]
When rendering in the Art, consider localization.

I use TexturePacker now for sprite sheets and FontMachine for the Font creation and loading.

I looked at GlyphDesigner now, looks awesome. Do you know if it has advantages/disadvatages compared to FontMachine, and in what ways?

So far I do not pack my FontMachine fonts into TexturePacker, but it should be possible, anyone who have tried?


c.k.(Posted 2012) [#8]
Thanks for the input guys.

Tibit, my primary concern with fonts is the different screen resolutions. The best case would be that I have total control over the size of the font, especially for things like leaderboards, where I'll want to display different amounts of data and on differently sized screens. On some screens, I can get away with using a bigger font than on others. Being able to scale the font is probably going to work just fine.

And Beaker, that's a good point. Design the leaderboard screen, then the actual list can be dynamic. I've also started converting all text "buttons" to image buttons, for international appeal! I'm interested in all targets, but mostly the mobile ones for now. I do have projects in the pipeline that will be multi-platform, from HTML5 to Win/MacOS executables to mobile.


Fred(Posted 2012) [#9]
What about using an overlay layer ?
With HTML5 something like a <div> over the canvas enabling the use of standard fonts ?
But it means very dedicated system for every platform.