[ReOpened] Problem with Draft Text display

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
rock
Posts: 1
Joined: Sat Feb 08, 2020 1:37 pm

[ReOpened] Problem with Draft Text display

Post by rock »

Hello, Chinese Text can't be displayed correctly, can any one help me? thanks.
draft.PNG
draft.PNG (176.22 KiB) Viewed 1849 times
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19510 (Git)
Build type: Release
Branch: master
Hash: c3eb6d9001c4d60ff7f7cae89f50bd3c965a9940
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Chinese/China (zh_CN)
Last edited by Kunda1 on Fri Mar 13, 2020 11:44 am, edited 2 times in total.
Reason: ReOpened issue
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Problem with Draft Text display

Post by Kunda1 »

Moved to Draft subforum
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
paullee
Veteran
Posts: 5134
Joined: Wed May 04, 2016 3:58 pm

Re: Problem with Draft Text display

Post by paullee »

rock wrote: Sat Feb 08, 2020 1:57 pm Hello, Chinese Text can't be displayed correctly, can any one help me? thanks.

draft.PNG

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19510 (Git)
Build type: Release
Branch: master
Hash: c3eb6d9001c4d60ff7f7cae89f50bd3c965a9940
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Chinese/China (zh_CN)
Maybe you can also try asking guys in 中文论坛 / 中文論壇(简体 / 繁體) :)
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Problem with Draft Text display

Post by yorik »

This seems to be related to fonts.
Apparently very few fonts on my system are able to display all chinese characters. I found this one that does it partially:
Screenshot from 2020-02-12 13-27-31.png
Screenshot from 2020-02-12 13-27-31.png (45.52 KiB) Viewed 1767 times
Would be interesting if you can post here a font that is known to display it all?
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: Problem with Draft Text display

Post by fc_tofu »

Some DBCS-related issues, I found in FreeCAD. (0.18.4/ 0.19pre, Win10x64)
fsc_2020-02-13_014841.jpg
fsc_2020-02-13_014841.jpg (205.03 KiB) Viewed 1751 times
1. DraftWB, dAnno and dLabel print Chinese characer in UTF-16 code (not as Chinese font glyph).
2. DraftWB, Dimension>Overide, doesnot print Chinese text on viewport.
[SOLVED] 3. DraftWB, ShapeString donnot apply Chinese font filename (not font family name).
4. DraftWB, dAnno save Chinese text as messy code, and print nothing on viewport.
ps. workaround: edit dAnnot text property, and input Chineset text again. This time dAnno can save Chinese text correcty, and print UTF-16 code on viewport. While dLable has no this issue.
fsc_2020-02-13_171039.jpg
fsc_2020-02-13_171039.jpg (123.05 KiB) Viewed 1699 times
5. On Windows10x64, only Arial (arial.ttf) and Courier (cour.ttf) can be apply to DraftWB's dAnnno/dLabel/Dimension. Fallback font is FreeCAD's internal font. All these fonts (arial/courier/internal) donnot support DBCS/CJK.
https://forum.freecadweb.org/viewtopic.php?f=23&t=38305
6. Preferences> Genereral> Editor> Family, donnot save Chinese font family name in "user.cfg" file.
https://forum.freecadweb.org/viewtopic.php?f=34&t=42803

https://bbs.csdn.net/topics/390094759
Attachments
fc019pre_font-test.FCStd
(241.07 KiB) Downloaded 155 times
Last edited by fc_tofu on Fri Mar 13, 2020 10:42 am, edited 13 times in total.
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Problem with Draft Text display

Post by wandererfan »

fc_tofu wrote: Wed Feb 12, 2020 6:11 pm ShapeString donnot apply Chinese font filename (not font family name).
In the python console, can you try the following for me please?

Code: Select all

>>> import Part
>>> myCJKString = "something in CJK chars"
>>> myCJKFont   = "CJKName.ttf"        #real CJK font file please! 
>>> ws = Part.makeWireString(myCJKString, myCJK, 100.0, 0.0)
This will probably fail(???). It doesn't look like makeWireString can handle unicode file names properly and this will confirm if there are changes needed here.

Thanks,
wf
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: Problem with Draft Text display

Post by fc_tofu »

@yorik, some Chinese fonts download.

1. Google DroidSansFallback (developed for Android, opensource)
https://packages.debian.org/sid/all/fon ... k/download

2. Google Noto Sans/Serif CJK (successor of DroidSansFallback, opensource)
https://www.google.com/get/noto/

3. HYSWLongFangSong (suitable for Chinese CAD drawing, unkown copyright)
http://gd.ddooo.com:8081/uuauth/hycfst_ ... df9717.rar
Last edited by fc_tofu on Thu Feb 13, 2020 1:52 pm, edited 2 times in total.
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: Problem with Draft Text display

Post by fc_tofu »

wandererfan wrote: Thu Feb 13, 2020 12:34 am In the python console, can you try the following for me please?

Code: Select all

>>> import Part
>>> myCJKString = "something in CJK chars"
>>> myCJKFont   = "CJKName.ttf"        #real CJK font file please! 
>>> ws = Part.makeWireString(myCJKString, myCJK, 100.0, 0.0)
Thank you, wandererfan.

There is a typo in your code, in line 3, "myCJK" should be "myCJKFont". I fixed it and made 3 test.

Test 1, English font with English filename
(before test, get fontfile full path "C:\Windows\Fonts\cour.ttf")

Code: Select all

import Part
myCJKString = "ShapeString test on English font filename."
myCJKFont   = "C:\Windows\Fonts\cour.ttf"
ws = Part.makeWireString(myCJKString, myCJKFont, 100.0, 0.0)
result: nothing happend to console and viewport

Test 2, Chinese font with Chinese filename
(before test, get fontfile full path "C:\Windows\Fonts\汉仪长仿宋体.ttf")

Code: Select all

import Part
myCJKString = "ShapeString的测试:字体文件的中文名。"
myCJKFont   = "C:\Windows\Fonts\汉仪长仿宋体.ttf"
ws = Part.makeWireString(myCJKString, myCJKFont, 100.0, 10.0)
result: nothing happend to viewport, but error msg in console

Code: Select all

Traceback (most recent call last):
  File "<input>", line 1, in <module>
Part.OCCError: Font file not found: C:\Windows\Fonts\汉仪长仿宋体.ttf
Test 3, Chinese font with English filename
(before test, rename "C:\Windows\Fonts\汉仪长仿宋体.ttf" to "C:\Windows\Fonts\HYSWLongFangSong.ttf")

Code: Select all

import Part
myCJKString = "ShapeString的测试:字体文件的中文名。"
myCJKFont   = "C:\Windows\Fonts\HYSWLongFangSong.ttf"
ws = Part.makeWireString(myCJKString, myCJKFont, 100.0, 10.0)
result: nothing happend to console and viewport

ps.
Chinese font file, named "汉仪长仿宋体.ttf" (same as my above post to @yorik).
http://gd.ddooo.com:8081/uuauth/hycfst_ ... df9717.rar
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Problem with Draft Text display

Post by wandererfan »

fc_tofu wrote: Thu Feb 13, 2020 11:25 am result: nothing happend to viewport, but error msg in console

Code: Select all

Traceback (most recent call last):
  File "<input>", line 1, in <module>
Part.OCCError: Font file not found: C:\Windows\Fonts\汉仪长仿宋体.ttf
Great, thanks. This means we need some changes to makeWireString and the C++ routines that support it.

To see the result of ws = Part.makeWireString, add "Part.show(ws)" .
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Problem with Draft Text display

Post by wandererfan »

fc_tofu wrote: Thu Feb 13, 2020 11:25 am
Is everybody experiencing this problem running Windows and version18?

I thought I'd just run some checks before making code changes, and on freecad-daily CJK in the filename doesn't seem to be an issue for ShapeString or makeWireString.

OS: Linux Mint 19 (X-Cinnamon/cinnamon)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Canada (en_CA)
CJKFileAndString.png
CJKFileAndString.png (72.6 KiB) Viewed 1655 times
CJKFileAndString_WireString.png
CJKFileAndString_WireString.png (28.62 KiB) Viewed 1655 times
Post Reply