Page 1 of 1

[solved] Ability to add custom fonts

Posted: Wed Aug 31, 2016 1:11 am
by aubergine18
UPDATE: Fixed in 0.14.3 :D

Looking at many of the mod GUIs that are on the portal, there seems to be an aversion to sprite buttons - in many cases mods are using single alpha characters, and < >, etc., rather than sprites... a glyph font would provide a trivial way for those mods (and mine) to quickly spice up GUI buttons without resorting to sprites.

In __core__/prototypes/fonts.lua, the various font prototypes are defined, but there seems to be no way to associate a font proto with an actual .ttf file. The link between font protos and .ttf files seems to be hardcoded and not accessible to the lua API?

I was hoping to add an icon font, which would make lots of glyphs available for use in captions via simple locale strings like `{ glyph.settings }' (which would equate to the char code for a cog glyph).

This would make it much easier for mods to quickly get nice glyphs for their buttons, with added benefits of font scaling and runtime color changing (I'm aware graphic sprites can be tinted, but only at design time in the prototypes, which is somewhat limiting, and even then they still wouldn't scale as nicely as a font).

Re: Ability to add custom fonts

Posted: Wed Aug 31, 2016 1:38 am
by aubergine18
From Rseding91 on IRC:

fonts are linked to the .ttf files through locale
Look at data\locale\en\core.cfg [font]

Which looks like this:

Code: Select all

[font]
default=fonts/TitilliumWeb-Regular.ttf
default-semibold=fonts/TitilliumWeb-SemiBold.ttf
default-bold=fonts/TitilliumWeb-Bold.ttf
And there was much rejoicing!

Re: [solved]Ability to add custom fonts

Posted: Wed Aug 31, 2016 4:12 am
by aubergine18
There is currently a blocking bug preventing custom fonts from being used: viewtopic.php?f=7&t=31916