font.add_font() fails with "Cannot only add font to a dynamic font collection" even with runtime_generation enabled

Hi everyone,

I’m trying to load a Korean font at runtime via Live Update and add it to an existing font collection using font.add_font(), but I’m getting this error:

ERROR:GAMESYS: Cannot only add font to a dynamic font collection!
Failed to add font '/app/media/fonts/liveupdate/kr/korean-semibold.fontc'
to font collection '/app/media/fonts/100-px-all-nunito.fontc'

My setup:

  • font.runtime_generation = 1 is set in game.project

  • App Manifest with Use full text layout system enabled

  • The Korean font is loaded via a Live Update collection proxy

  • I’m getting the loaded font resource via go.get(url_to_label, "font") and passing font_info.fonts[1].path_hash to font.add_font()

One thing I noticed — font_info.fonts[1].path_hash is empty (hash: []) in the logs:

{ 
  path = hash: [/app/media/fonts/liveupdate/kr/korean-semibold.fontc],
  fonts = {
    1 = {
      path = "/_generated_d0eee2f1.glyph_bankc",
      path_hash = hash: []   -- empty!
    }
  }
}

So I’m falling back to font_info.path instead, but that gives a .fontc path, not a .ttf, and the error persists either way.

Is there something specific that needs to be configured on the .fontc file itself to make it accept font.add_font()? Or does the base font (100-px-all-nunito.fontc) also need to be a .ttf runtime font rather than a bitmap/distance field font?

Any help appreciated!

1 Like

That error rmessage is “broken” imho, I must have missed it.

The issue is that the font you’re adding isn’t a “dynamic font”, as you see from the “.fontc” path.
It should really be a .ttffile in order to work.
E.g. here is the .fontc collection from our example:

{ --[[0x11ab3bd90]]
  fonts = { --[[0x11ab3be20]]
    1 = { --[[0x11ab3be70]]
      path_hash = hash: [/assets/fonts/SourceSansPro-Semibold.ttf],
      path = "/assets/fonts/SourceSansPro-Semibold.ttf"
    }
  },
  path = hash: [/assets/fonts/latin_small.fontc]
}

I suggest comparing with our example (examples/gui/localization at master · defold/examples · GitHub) to see what differs from your project.

1 Like

Okay, I’ll check and come back with results!

1 Like