Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Multi-font fonts ! — Gideros Forum

Multi-font fonts !

SinisterSoftSinisterSoft Maintainer
edited September 2017 in Code snippets
When programming a game you need to pick the right font that matches your game, now 99% this is great if all you need is text in your own language. But a problem arises when you need to translate your game into multiple languages - the characters tend to be missing from the font you picked.

So the dilemma is you either have to change the font in your game to a different font that supports a larger variety of characters, or you have to have multiple fonts and load a particular font depending on the language.

Gideros (2017.9+) now has a better solution - Multi-font fonts!

Here is an example:
local chrs=" !$%&'()*,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]_`abcdefghijklmnopqrstuvwxyz£ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ¥¢¿¡«»ČčĎďĚěıŇňŒœŘřŠšŤťŮůŸŽž"..'"'
chrs=chrs.."ъяшертыуиопющэасдфгчйкльжзхцвбнм"  -- some extra Cyrillic characters not present in my normal font
 
smallFont=TTFont.new({"retro.ttf","cyrillic.ttf"},33,chrs,3)
What will happen is that if the character exists in the first font then it will be used, else the 2nd font will be used and so on.

Attached is a screenshot of what this looks like.

This is the syntax:

TTFont.new({"retro.ttf","cyrillic.ttf"},size,chrs,smotthing)

or

TTFont.new({{name="retro.ttf",sizeMult=1.0},{name="cyrillic.ttf",sizeMult=1.2}},size,chrs,smoothing)

This makes things 100x easier when dealing with translations and multiple fonts.

Thanks to @hgy29 for implementing this amazing idea (mine! ;) )
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
https://deluxepixel.com
+1 -1 (+9 / -0 )Share on Facebook

Comments

Sign In or Register to comment.