Page MenuHome

Font preview malfuction in Blender 2.8
Closed, ResolvedPublic


As show below, in Blender 2.79b or previous versions, we can use translated and compiled to preview Chinese fonts with Chinese charactor in file browser.

But this doesn't work work for Blender 2.80.

I think it's an common issue for non-english users, and hope this to be fixed.

Event Timeline

Those strings are all meant to be translated. I see them marked as such:

static const char *thumb_str[] = {
    N_("The quick"),
    N_("brown fox"),
    N_("jumps over"),
    N_("the lazy dog"),

But I'm not seeing the font previews using translated strings when I test any languages that are marked as complete.

The function that actually does the preview (BLF_thumb_preview() in blf_thumbs.c) has a comment that it is "called from a thread, so it bypasses the normal BLF_* api (which isn't thread-safe)"

But the function calls BLT_translate_do() to do the translation but that function does not do that if the result of BLT_translate() is false. And one the checks of BLT_translate() (in blt_translation.c) is if BLI_thread_is_main(). So therefore (I think) the translation of the strings is not attempted. As far as I can tell anyway.

So, this was an an unintentional positive outcome?
But it has been and will be a handy feature for us users. It will be great for us to have it back.
Would it be possible to find it back?

And to follow up, I definitely don't get a translated font preview for the Japanese language currently:

But I do if I remove that BLI_thread_is_main().

I seem to remember a complaint that the font preview generation could error out times, so possibly this thread check was put in to fix that, but unintentionally removed this translation behavior.

Will it be possible to find a balanced way to deal with these two needs?

Yes, there definitely will. I'm just not the best person to say exactly how or when. I do see your error and I understand why it is happening. But I am not familiar with the issues around this "thread safety" issue regarding our font library.

Mostly likely someone with more knowledge of this area will chime in fairly soon with more answers. But everyone is quite busy with the current release so it might not be immediate.

Just checked this with 2.80RC3, but has the same problem, never showing translated preview font text.

Note that this issue is unrelated to the bug addressed here:

Bastien Montagne (mont29) claimed this task.
Bastien Montagne (mont29) triaged this task as Confirmed, Medium priority.

Translation was disabled from non-main threads at some point last year iirc, because on some systems (think it was mainly OSX), that could lead to crashes…

Will check the code, should be possible to refactor it to make the translations in main thread before launching preview worker ones.

Ah, that makes sense. I was unable to actually find a place outside of the thread where that would be done. LOL. I'm sure to learn something from the eventual solution.

@Bastien Montagne (mont29) Thank you. Can I test this change in today's daily build?

@zdy (NGENNGT) it's not yet committed, you'd need to apply the patch and build yourself.