Japanese font issue (SOLVED)

I have added three Japanese fonts to my game, this is one of them:

These are the glyphs used:

スくきウ原最新あ停使シ秒終らダみ近こ一チパキる今ュ備楽バ削け広難間ッビ記りオぐて長続日試J入教m1ラ倍準いとわ?フ!れア設デ約u利タ購ト…行せ ?復戻ドベイえまレー開無はもすどサ解さ定ロ告ワジ返溶氷草敵再押規の止んコリ元困公除し生ポをゲたン用jっ中信プ0録でブャルか時ィがク了送2完回p

I get this error:

ERROR:RENDER: Out of available cache cells! Consider increasing cache_width or cache_height for the font.

Since the cache_width and cache_height are 0, I imagine the bitmap produced is too big.

What are my options to fix this? Using a bitmap font instead of a distance field? Leaving “Extra Characters” blank?

Edit: The issue happens because of the workaround mentioned in this post:

I suppose a stutter is slightly better than a broken game, so for now I’m going to have to disable the workaround.

Cache width/height documentation: https://defold.com/manuals/font/#properties

“If set to 0 the cache size is set automatically.”

So it could be that the generate font cache becomes too big. What if you reduce the font size and try again (yes, stuff will break, but as a test)?

1 Like

Stumbled on this one again whilst adding translations for a new game, so I did a little digging. It turns out the issue only happens when the text is displayed on screen.

This means that the glyphs aren’t cached before the text is displayed, which is a likely cause of the stutter problem mentioned above. It also seems that the text becomes uncached when the collection is removed, which explains why keeping a text field with all glyphs visible att all time fixes the stutter issue.

Yes, the error happens if the font size is too big and is resolved if the font is made smaller. In my tests setting the value to 0, 0 breaks earlier than setting it to 2048, 2048.

If cache_width and cache_height is set to 0, what is the upper limits before the “Out of available cache cells!” error happens?

In this test project font size 100 works, size 101 breaks with automatic caching: JapaneseGlyphs.zip (3.9 MB)

If cache_width is set to 0 we default to 1024. If cache_height is 0 we guess a height, up to 2048:

1 Like

Hi @totebo . Sorry to bump an old thread. I’m in the process of localising a game for the first time and I’m stumped by how to get a unique list of glyphs to embed. Hitting “All Chars” just freezes my computer, and I presume it wouldn’t work well in game anyway.

How do you do it?

Got an answer from @Dragosha on the Discord. Leaving it here for others.

Get a utf8 module, e.g. https://github.com/d954mas/defold-utf8

Then use a code snippet like this (you’ll need to modify for your setup, this case was for Korean hence the ‘KO’):

local function uniqueSymbols()
    local unique={}
    local extra_characters=""
    for k,v in pairs(M.texts) do
        if v.KO then
            utf8.gsub(v.KO,".", function(c)
            if  not unique[c] then
                unique[c]=1
                extra_characters=extra_characters..c
            else
                unique[c]=unique[c]+1
            end
            end)
        end
    end

    print(extra_characters)

end

To make this list into something I can just paste into the “Extra characters” field, I just did this:

local output = ""
for char, num in pairs(unique) do
    output = output .. char
end
print(output)
2 Likes