Unicode Block Not Working on Windows #71273

Closed
opened 2019-11-01 19:44:01 +01:00 by Mehmet Oguz Derin · 13 comments

System Information
Operating system: Windows 10

Blender Version
Broken: 2.80 Release
Worked: Never

Short description of error
Text objects do not display Old Turkic Unicode block (Old Turkic, U+10C00 - U+10C4F) when using Segoe UI Historic or Google Noto Sans Old Turkic.

Exact steps for others to reproduce the error

Open:
font.blend

Or follow the steps:

  1. Create a text object and name it "Text"
  2. Load either ttf or otf version of either Segoe UI Historic or Google Noto Sans Old Turkic
  1. Run the following code
import bpy
bpy.data.objects["Text"].data.body = u'\U00010c45'
  1. The result is a box instead of the desired ? character

Expected result (obtained on Linux):
image.png

Developer Notes
The code assumes wchar_t is 32 bit, which is not the case on Windows. See comments for more investigation details.

**System Information** Operating system: Windows 10 **Blender Version** Broken: 2.80 Release Worked: Never **Short description of error** Text objects do not display Old Turkic Unicode block (Old Turkic, U+10C00 - U+10C4F) when using Segoe UI Historic or Google Noto Sans Old Turkic. **Exact steps for others to reproduce the error** Open: [font.blend](https://archive.blender.org/developer/F7952320/font.blend) Or follow the steps: 1. Create a text object and name it "Text" 2. Load either `ttf` or `otf` version of either Segoe UI Historic or Google Noto Sans Old Turkic - You can obtain second font from https://www.google.com/get/noto/#sans-orkh 3. Run the following code ``` import bpy bpy.data.objects["Text"].data.body = u'\U00010c45' ``` 4. The result is a box instead of the desired ? character Expected result (obtained on Linux): ![image.png](https://archive.blender.org/developer/F7952329/image.png) **Developer Notes** The code assumes `wchar_t` is 32 bit, which is not the case on Windows. See comments for more investigation details.

Added subscriber: @mehmetoguzderin

Added subscriber: @mehmetoguzderin

Added subscribers: @mont29, @mano-wii

Added subscribers: @mont29, @mano-wii

Analyzing the code I realize that, at least in windows, the supported character encoding is utf-16.
u'\U00010c45' is from a 32-bit hex value that is only supported by utf-32.
A possible solution would be to change the value of the built-in type wchar_t to 4-byte.

If I'm not mistaken this is the size of wchar_t in linux.

I think this is a known limitation.
@mont29, what do you think?

Analyzing the code I realize that, at least in windows, the supported character encoding is utf-16. `u'\U00010c45'` is from a 32-bit hex value that is only supported by utf-32. A possible solution would be to change the value of the built-in type `wchar_t` to 4-byte. If I'm not mistaken this is the size of `wchar_t` in linux. I think this is a known limitation. @mont29, what do you think?
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Member

sizeof(wchar_t) is implementation dependent and cannot be changed for some implementations, C11 added char16_t and char32_t types for if you have size requirements.

`sizeof(wchar_t)` is implementation dependent and cannot be changed for some implementations, C11 added `char16_t` and `char32_t` types for if you have size requirements.
Member

Yeahhh this is a mess....

Debugged a little into this, the input to vfont_to_curve is correctly UTF8, however, it then feeds this to BLI_strncpy_wchar_from_utf8 which internally assumes wchar_t is 32 bits which is decisively not the case on windows (16 bits there, cannot be changed. specs say implementation is free to do whatever with wchar_t) so the upper 16 bits get lost and you and up with the wrong codepoint.

Only way to fix this is to replace the parts of the codebase where the assumption is made that wchar_t is 32 bit to use uint32_t instead (I really would have preferred char32_t but msvc does not support this type in c mode)

Yeahhh this is a mess.... Debugged a little into this, the input to `vfont_to_curve` is correctly UTF8, however, it then feeds this to `BLI_strncpy_wchar_from_utf8` which internally assumes wchar_t is 32 bits which is decisively not the case on windows (16 bits there, cannot be changed. specs say implementation is free to do whatever with wchar_t) so the upper 16 bits get lost and you and up with the wrong codepoint. Only way to fix this is to replace the parts of the codebase where the assumption is made that `wchar_t` is 32 bit to use `uint32_t` instead (I really would have preferred `char32_t` but msvc does not support this type in c mode)

Added subscriber: @dfelinto

Added subscriber: @dfelinto

Here (Ubuntu Linux, official Blender 2.80) it works fine:
font.blend

image.png

Here (Ubuntu Linux, official Blender 2.80) it works fine: [font.blend](https://archive.blender.org/developer/F7952320/font.blend) ![image.png](https://archive.blender.org/developer/F7952329/image.png)
Member

wchar_t is 32 bit on gcc, so yeah you wouldn't see the issue there.

wchar_t is 32 bit on gcc, so yeah you wouldn't see the issue there.
Dalai Felinto changed title from Unicode Block Not Working to Unicode Block Not Working on Windows 2019-11-05 22:31:08 +01:00

This issue was referenced by 177dfc6384

This issue was referenced by 177dfc6384b926dd19e3b7e98a995ccb4da9167c

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Germano Cavalcante self-assigned this 2019-11-22 16:28:05 +01:00

Added subscriber: @MilanJaros

Added subscriber: @MilanJaros

I have problem with building of this patch on Linux (CentOS) with GCC/4.9 or GCC/7.1 with blender_lite.cmake. I have got the error message: "uchar.h: No such file or directory" in BLI_sys_types.h and in wcwidth.h. After fix it I have got the next error message: "unknown type name size_t" in wcwidth.h and wcwidth.c. After changes on my site in BLI_sys_types.h (uchar.h -> add typedef like for macos), wcwidth.h (size_t -> unsigned long long int) and wcwidth.c (size_t -> unsigned long long int) it works fine.

I have problem with building of this patch on Linux (CentOS) with GCC/4.9 or GCC/7.1 with blender_lite.cmake. I have got the error message: "uchar.h: No such file or directory" in BLI_sys_types.h and in wcwidth.h. After fix it I have got the next error message: "unknown type name size_t" in wcwidth.h and wcwidth.c. After changes on my site in BLI_sys_types.h (uchar.h -> add typedef like for macos), wcwidth.h (size_t -> unsigned long long int) and wcwidth.c (size_t -> unsigned long long int) it works fine.
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
6 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#71273
No description provided.