[solved] Ability to add custom fonts

Things that already exist in the current mod API
Post Reply
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

[solved] Ability to add custom fonts

Post 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).
Last edited by aubergine18 on Sun Sep 04, 2016 7:58 pm, edited 3 times in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Ability to add custom fonts

Post 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!
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [solved]Ability to add custom fonts

Post by aubergine18 »

There is currently a blocking bug preventing custom fonts from being used: viewtopic.php?f=7&t=31916
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Post Reply

Return to “Already exists”