Page 1 of 1

[solved] Adding fonts...?

Posted: Tue Aug 30, 2016 4:00 pm
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?

Re: [solved] Adding fonts...?

Posted: Wed Aug 31, 2016 1:40 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] Adding 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

FIXED in 0.14.3 :D

Re: [solved] Adding fonts...?

Posted: Thu Nov 03, 2022 7:47 pm
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.