Font preview malfuction in Blender 2.8 #67620

Closed
opened 2019-07-24 22:35:32 +02:00 by zdy · 16 comments
Member

As show below, in Blender 2.79b or previous versions, we can use translated and compiled zh_CN.mo to preview Chinese fonts with Chinese charactor in file browser.
图片.png
2.79.png
But this doesn't work work for Blender 2.80.
2.80.png
I think it's an common issue for non-english users, and hope this to be fixed.

As show below, in Blender 2.79b or previous versions, we can use translated and compiled `zh_CN.mo` to preview Chinese fonts with Chinese charactor in file browser. ![图片.png](https://archive.blender.org/developer/F7627075/图片.png) ![2.79.png](https://archive.blender.org/developer/F7627066/2.79.png) But this doesn't work work for Blender 2.80. ![2.80.png](https://archive.blender.org/developer/F7627068/2.80.png) I think it's an common issue for non-english users, and hope this to be fixed.
Author
Member

Added subscriber: @nge

Added subscriber: @nge
Author
Member

Added subscriber: @xuekepei

Added subscriber: @xuekepei
Member

Added subscriber: @Harley

Added subscriber: @Harley
Member

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

static const char *thumb_str[] = {
    N_("ZZZZZ"),
    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.

Those strings are all meant to be translated. I see them marked as such: ``` static const char *thumb_str[] = { N_("ZZZZZ"), 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 "c**alled 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.
Author
Member

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?

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?
Member

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

NoJapaneseFont.png

But I do if I remove that BLI_thread_is_main().

JapaneseFont.png

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.

And to follow up, I definitely don't get a translated font preview for the Japanese language currently: ![NoJapaneseFont.png](https://archive.blender.org/developer/F7627250/NoJapaneseFont.png) But I **do** if I remove that BLI_thread_is_main(). ![JapaneseFont.png](https://archive.blender.org/developer/F7627244/JapaneseFont.png) 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.
Author
Member

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

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

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.

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.
Member

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: https://developer.blender.org/rB52fb8b1e80ec1e76e0e3b82329042cd37be29d1e

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: https://developer.blender.org/rB52fb8b1e80ec1e76e0e3b82329042cd37be29d1e

Added subscriber: @mont29

Added subscriber: @mont29
Bastien Montagne self-assigned this 2019-07-25 08:06:47 +02:00

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.

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.
Member

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.

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.
Author
Member

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

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

@nge it's not yet committed, you'd need to apply the patch and build yourself.

@nge it's not yet committed, you'd need to apply the patch and build yourself.

This issue was referenced by 3b6c75dc31

This issue was referenced by 3b6c75dc318223a7e559805ed9802c46c73f2f28

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#67620
No description provided.