Dynamic Font

Monkey Archive Forums/Monkey Projects/Dynamic Font

Aman(Posted 2014) [#1]
I have been working on a new font that is re-sizable (No Scaling) and resolution independent (Look virtually the same on different screen sizes. Here is the result:

Image Link: https://db.tt/KUAxr97p

It's not fully tested on all targets and resolutions yet but you get the idea. Would love to hear your feedback and thoughts. Will update it to fix some expected issues.

To use: "font:=MakeFont(size)" Then: "SetFont(font)
Of course the function has to be called within an OnRender method.

Note: This is 740 lines of code that renders lots of shapes and uses read/write pixles 95 times. So only call it once for each needed size or when resolution changes if necessary.




Shinkiro1(Posted 2014) [#2]
I know it must have taken a while till you coded this, but to be honest you wouldn't be able to use this in a quality game.

It disregards spacing, kerning and a lot of other typography stuff which probably no one here knows about (me included of course).
And the good thing is, we don't need to know about it, because there are tools out there that will take care of these things.

So again, I respect your effort but it's not practical.


Aman(Posted 2014) [#3]
I only started today. I made a tool that allow me to draw stuff and generate Monkey code of the stuff I draw.
As for how practical it is, it is as practical as the font system you use it in. This only generate the bitmap font. The typography limitations are there by default in the Monkey font system. You can modify the code to make it work with fontmachine which I intend to do as soon as I sort out the problems. But until TrueType font becomes supported, there is no other way to have different sizes of a font except for scaling.


Shinkiro1(Posted 2014) [#4]
But until TrueType font becomes supported, there is no other way to have different sizes of a font except for scaling.

That's true. Scaling down a font doesn't look too bad though.
In my game I have 2 fonts depending on the resolution. As long as you don't scale up the font it should look fine.


Supertino(Posted 2014) [#5]
My main concern with this method (as it stands now) is the large number of draw operations, how any DrawRect/Oval/Poly calls would be required to draw a sentence, would it not have a performance hit?


nikoniko(Posted 2014) [#6]
Just idea - move draw font to bitmap to native level where no problem using ttf font, font size, style, international chars, etc and return to DrawText rendered bitmap only.


chrisc2977(Posted 2014) [#7]
Ive been working on ttf. Its not finished, but getting there :)
http://www.challenger-arts.com/wp-content/uploads/tfont.zip


Aman(Posted 2014) [#8]
@Shinkiro1:
That's what I usually do but the problem with this is that drawtext performance isn't that good on some platforms. And using a font that's larger than needed could make it worse specially on low budget devices. To tell you the truth, I only did this because I am creating a game with no resources and this is the only way to win the challenge.


@Supertino:
this creates a bitmap font. You only call it once. Then use the returned Image instead of the one that comes with monkey by default. And if you save it locally(not html5 or flash, you wouldn't need to call it ever again unless the user deletes it.

@nikoniko;
That's how you would support TrueType fonts.

@Chris: I was about to post a link to your page. I tried finding your module here but couldn't. I was searching for True Type which is never mentioned in your topic. It's great what you've done so far.
http://www.challenger-arts.com/monkey-modules/truetype-module/