[solved] Adding fonts...?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

[solved] Adding fonts...?

Post by aubergine18 »

EDIT: Fixed in 0.14.3

I'm trying to add a new font (an fontello .ttf icon font) so that I can display nicely scalable icons on buttons (eg. a cog on a settings button).

Looking at core/prototypes/fonts.lua....

Code: Select all

data:extend(
{
  {
    type = "font",
    name = "default",
    from = "default",
    size = 14
  },
 etc.....
How is "default" associated with the actual .ttf file on disk? There doesn't seem to be anything that links the file name to the font prototype.

If I want to add a new font, is there something I need to do to make it available in the prototype?
Last edited by aubergine18 on Sun Sep 04, 2016 6:28 pm, edited 4 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: [solved] Adding 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] Adding fonts...?

Post by aubergine18 »

There is currently a blocking bug preventing custom fonts from being used: viewtopic.php?f=7&t=31916

FIXED in 0.14.3 :D
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
Kuxynator
Inserter
Inserter
Posts: 31
Joined: Wed Sep 23, 2020 5:02 pm
Contact:

Re: [solved] Adding fonts...?

Post by Kuxynator »

Update for 1.1 (and some earlier)

data.lua

Code: Select all

data:extend(
{
   {
     type = "font",
     name = "myfont14",
     from = "myfont",  -->  locale/_language_/info.json
     size = 14
  }
}
locale/_language_/info.json

Code: Select all

{
    "language-name": "English",
    "font": {
        "myfont":
        [
        "__core__/fonts/NotoMono-Regular.ttf",
        "__core__/fonts/NotoSans-Regular.ttf",
        "__core__/fonts/NotoSansCJKtc-Regular.ttf",
        "__core__/fonts/NotoSansThai-Regular.ttf",
        "__core__/fonts/NotoSansArabic-Regular.ttf",
        "__core__/fonts/NotoSansHebrew-Regular.ttf",
        "__core__/fonts/DejaVuSansMono.ttf"
        ]
    }
}
Refer to data/core/locale/_language_/info.json for examples.

Post Reply

Return to “Modding help”