I18n: translate new text object body #115370
No reviewers
Labels
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#115370
Loading…
Reference in New Issue
No description provided.
Delete Branch "pioverfour/blender:dp_translate_new_text_body"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
After VFont has been updated to use the BLF API in
604ee2d036
, it canuse the fallback font stack and display text in many scripts.
This change means the default text for font objects can now be
translated, instead of always being the English word 'Text'.
Translation will only occur if the user has enabled translation of new
data in the preferences.
I’m not sure the memory allocations are correct. The previous code allocated and copied arrays of length 12 for a text of length 4 ("Text"). In contrast, the code in rna_curve.cc allocates strings of size
len_bytes + sizeof(char32_t)
, while editfont.cc directly useslen_bytes + 4
. I mostly copied the implementation from rna_curve.cc.The change can be tested by creating texts for all available languages using the following script:
Change looks good, but several points to fix in memory allocation indeed.
Admittedly, that 'text Curve' memory handling is about the worst, most confusing one I have ever seen, with a mix of legacy issues, confusion between string length, utf8 strings, utf32 strings, and so on... Could use a serious cleanup.
Will also summon @Harley here, since he's been working in this area recently iirc, he might have better understanding of these things?
@ -372,0 +368,4 @@
const char *str = DATA_("Text");
size_t len_bytes;
size_t len_chars = BLI_strlen_utf8_ex(str, &len_bytes);
Would rather match the name in the
Curve
struct for that one:len_char32
(event hough it's not actually a proper name,len_utf8_charpoint
or so would be more correct).@ -372,0 +370,4 @@
size_t len_bytes;
size_t len_chars = BLI_strlen_utf8_ex(str, &len_bytes);
cu->str = static_cast<char *>(MEM_mallocN(len_bytes + sizeof(char32_t), "str"));
No reason to remove usage of the
_array
malloc here (same below btw).And no reason to add extra
char32_t
either, you only need one extra char for the NULL terminator.My understanding was that UTF-8 characters don’t necessarily have the same number of bytes, but the
_array
malloc could only allocate same-sized arrays. So for Vietnamese,len_bytes == 10
butlen_char32 == 7
.If that assumption is wrong, I don’t know how to write this allocation properly…
MEM_malloc_arrayN(len_bytes + 1, sizeof(char), "str")
should do the trick?cu->str
is nothing more than an array of chars, fact that it is utf8-encoded and that some unicode points may require more than one byte is only relevant for data usinglen_char32/strinfo/...
It does look like it does the trick, thanks for the help :)
@ -372,0 +371,4 @@
size_t len_chars = BLI_strlen_utf8_ex(str, &len_bytes);
cu->str = static_cast<char *>(MEM_mallocN(len_bytes + sizeof(char32_t), "str"));
memcpy(cu->str, str, len_bytes + 1);
Use
BLI_strncpy
@ -372,0 +377,4 @@
cu->len_char32 = cu->pos = len_chars;
cu->strinfo = static_cast<CharInfo *>(
MEM_callocN((len_chars + 4) * sizeof(CharInfo), "strinfo new"));
I do not see any reason to allocate more than
len_chars + 1
items here. That's what written at least in blendfiles (although I do not even see the need for the+ 1
, but since it's written... ;) ).LGTM now, thanks.
@blender-bot build
This is awesome. And works great!