View Issue Details

IDProjectCategoryView StatusLast Update
0001404DraftPatchpublic2014-05-11 17:45
Reporterulrich1a Assigned Toyorik  
Status closedResolutionfixed 
Target Version0.14Fixed in Version0.14 
Summary0001404: Draft Dimension Override string: Non ascii-Characters are not shown in Drawings
DescriptionAs the summary says: Non ascii-characters are not shown in Drawings. This is a regression after the Pyside migration.
I made a patch, that corrects the behavior.
Steps To Reproduce- Make a dimension.
- Put any Latin1 but non ascii-Character like "Ü" into the override string.
- Put the dimension in a Drawing.
an error message appears about a non asci-character.
TagsNo tags attached.
FreeCAD Information


child of 0000853 closedyorik FreeCAD Unicode Strings in Coin3D 



2014-02-11 23:05


0001-Renables-non-asci-characters-in-the-Override-string-.patch (Attachment missing)


2014-02-12 12:24

developer   ~0004190

have you tested the patch with non latin1 characters? like €


2014-02-12 12:53

administrator   ~0004193

Thanks! I'll test and apply if all is OK.


2014-02-12 19:57

reporter   ~0004198

Yes I tested the patch with a non latin1 character. It gives an error at that line where the string is coded to latin1. This is expected and it was the same without the patch. So the non latin1 character is not shown in the 3D-view. (It is a coin-3D-defiency.) But with this patch the character is shown in a Drawing projection. Since the PySide-Migration only ascii-characters are shown in the Drawing projection. So this patch allows utf-8 in a Drawing projection.

I had a discussion with a programmer. He gave me a hint how to avoid the encoding to utf-8. I will add another version of this patch.


2014-02-12 20:13

administrator   ~0004199

shoogen and I also don't like much turning the SVG output into an unicode object... This might cause problems in other parts of FreeCAD that expect standard strings. We might need to change that.


2014-02-12 21:15


0001-Enable-unicode-in-Drawing-Dimensions.patch (Attachment missing)


2014-02-12 21:25

reporter   ~0004201

These are different things. You can leave out the "u" before the string objects. Then you have still an asci-string but with an utf-8 encoding in it. This is fully conform to SVG-standards. I did look that up.
There is still the regression, that the non asci-characters are not shown in the override string in a Drawing projection. This is solved by the patch and it should also be solved with a version without the "u"s before the string objects.

So my second version seems of no use. I did not see problems with it so far.



2014-02-12 23:43

developer   ~0004203

the problem with the "svg" string being a unicode objects, starts when is has to be processed outside of python. In this case care must be taken when writing to a file. I don't like the fact the the replacement for "$dim" happens on an already decoded string. I haven't spent much time testing. But we should surely offer a (fallback) replacement strategy when encoding to latin1 to avoid encoding errors
t.string = s.decode("utf8").encode("latin1","replace")


2014-02-15 17:34


0002-Latin1-Filter-implementation.patch (Attachment missing)


2014-02-15 17:38

reporter   ~0004224

I made a filter in order to get only latin1 characters into the 3D-presentation. It works for me. (Using the last two patches.) I tested so far with Arial in the font setting. I can save and load the SVG-drawing.
What else needs to be tested?


2014-03-29 17:32


test utf8 in draft.fcstd (Attachment missing)


2014-03-29 17:38

administrator   ~0004515

Apparently, starting from Coin3D 4.0 (libcoin80), utf characters are now fully supported. I just committed a change that fixes that, now all texts (Draft Texts and Draft Dimensions) can have utf8 characters, which display coherently in the Properties editor, the 3D view, and the SVG Drawing sheets.

I still left a fallback for people who have an older version of coin.

The annexed test_utf8_in_draft.fcstd file contains example of such texts, which should render 100% correctly with coin4, and possibly with encoding errors on older versions, but at least not crash. Please test!

I'll still leave this issue open in case there are still problems


2014-03-30 13:19

reporter   ~0004520

I just tested without Coin3D version 4.0. The fallback solution has a problem in the 3D-View. I made an Draft-dimension and put "$dim Ü" in the override. I get "10.0 Ã" in the 3D-view. But the "Ü" is shown correct in a Drawing projection. A step forward, but a small issue is left.


2014-03-30 15:47

administrator   ~0004521

Ok so the Ü (which is unicode, therefore works ok in the interface and on the svg sheet), must be converted to latin1 when using coin < 4. This is obviously not optimal (some utf8 chars don't exist in latin1) but I suppose it's the best we can do...


2014-05-03 16:04

administrator   ~0004611

Just committed a fix (commit 32d7839) that takes the coin verison into account, and converts texts to latin1 if coin version is < 4. Please test!


2014-05-11 17:45

administrator   ~0004650

I believe this is now fixed, reopen if needed!

Related Changesets

FreeCAD: master 749a8fa1

2014-03-29 18:31:45


Details Diff
Draft - enabled utf8 in coin3d and svg - relates to issue 0001404 Affected Issues
mod - src/Mod/Draft/ Diff File

FreeCAD: master 96967a51

2014-04-19 18:26:24


Details Diff
Draft: further fix for utf8 texts - issue 0001404 Affected Issues
mod - src/Mod/Draft/ Diff File

FreeCAD: master 32d7839d

2014-05-03 18:00:44


Details Diff
Draft: use latin1 in texts if coin < 4 - issue 0001404 Affected Issues
mod - src/Mod/Draft/ Diff File

Issue History

Date Modified Username Field Change
2014-02-11 23:05 ulrich1a New Issue
2014-02-11 23:05 ulrich1a File Added: 0001-Renables-non-asci-characters-in-the-Override-string-.patch
2014-02-12 12:24 shoogen Note Added: 0004190
2014-02-12 12:25 shoogen Relationship added parent of 0000853
2014-02-12 12:52 yorik Assigned To => yorik
2014-02-12 12:52 yorik Status new => assigned
2014-02-12 12:53 yorik Note Added: 0004193
2014-02-12 19:57 ulrich1a Note Added: 0004198
2014-02-12 20:13 yorik Note Added: 0004199
2014-02-12 21:15 ulrich1a File Added: 0001-Enable-unicode-in-Drawing-Dimensions.patch
2014-02-12 21:25 ulrich1a Note Added: 0004201
2014-02-12 23:43 shoogen Note Added: 0004203
2014-02-15 17:34 ulrich1a File Added: 0002-Latin1-Filter-implementation.patch
2014-02-15 17:38 ulrich1a Note Added: 0004224
2014-03-08 20:40 yorik Severity major => minor
2014-03-29 17:32 yorik File Added: test utf8 in draft.fcstd
2014-03-29 17:38 yorik Note Added: 0004515
2014-03-29 17:38 yorik Status assigned => feedback
2014-03-29 17:59 yorik Changeset attached => FreeCAD Master master 749a8fa1
2014-03-29 19:49 yorik Project FreeCAD => Draft
2014-03-30 13:19 ulrich1a Note Added: 0004520
2014-03-30 13:19 ulrich1a Status feedback => assigned
2014-03-30 15:47 yorik Note Added: 0004521
2014-04-19 16:48 yorik Changeset attached => FreeCAD Master master 96967a51
2014-05-03 15:48 yorik Product Version trunk =>
2014-05-03 15:48 yorik Target Version => 0.14
2014-05-03 16:04 yorik Note Added: 0004611
2014-05-03 16:28 yorik Changeset attached => FreeCAD Master master 32d7839d
2014-05-11 17:45 yorik Note Added: 0004650
2014-05-11 17:45 yorik Status assigned => closed
2014-05-11 17:45 yorik Resolution open => fixed
2014-05-11 17:45 yorik Fixed in Version => 0.14
2014-05-11 17:45 yorik Relationship deleted parent of 0000853
2014-05-11 17:45 yorik Relationship added child of 0000853