View Issue Details

IDProjectCategoryView StatusLast Update
0022149Open CASCADEOCCT:Visualizationpublic2019-05-06 22:55
ReporterszvAssigned Tobugmaster  
Status closedResolutionfixed 
Target Version6.5.2Fixed in Version6.5.2 
Summary0022149: Strings with Japanese characters can not be displayed in 3D viewer
DescriptionIt is impossible to display 2-byte character strings (ex. in Japanese language)
in OCCT 3D viewer. For example, a call to Prs3d_Text::Draw with such a string
does not result in correct displaying (because internally it always converted to
TagsNo tags attached.
Test case numberchl 936 Z8

Attached Files

  • (84,466 bytes)
  • (86,779 bytes)
  • mona.ttf (2,828,124 bytes)
  • (175,730 bytes)
  • chl_936_Z8.tar.gz (331 bytes)


related to 0030696 closedbugmaster Draw Harness, testgrid - specify encoding in HTML header 


2010-12-22 15:18 (84,466 bytes)

2011-06-29 14:19 (86,779 bytes)

2011-07-06 11:41


mona.ttf (2,828,124 bytes)

2011-07-06 12:14 (175,730 bytes)

2011-07-22 15:13


chl_936_Z8.tar.gz (331 bytes)


2011-08-01 13:08

developer   ~0017870

Last edited: 2011-08-01 13:11

According previous discussion about 'Unicode problem' entirely we suggest that Unicode support in OCCT should be provided in another way by meaning of dedicated Utf8 string class as main storage / exchange encoding and perform necessary translations in-place where necessary (encoding-dependent WinAPI calls for example).

So I should generally reject this patch because it is in the wrong direction
(looking for ABV suggestions).

Patch involves unnecessary complication:
- new type 'unsigned short Techar' on GL level;
- wchar_t is 4 bytes UTF32 on Linux and is 2 bytes UTF16 on Windows that cause additional complications and mess up (Standard_ExtCharacter / Standard_ExtString are defined as short integer, Techar suggested to be unsigned short);

=== OpenGl_FontMgr.cxx
void OpenGl_FontMgr::render_text( const Standard_Integer id, const wchar_t* text,
                                  const Standard_Boolean is2d )
#ifdef TRACE
  cout << "TKOpenGl::render_text\n"
    << "\tfont id = " << id << endl
    << "\ttext = " << text << endl;
will cause corrupted TRACE output.

=== OpenGl_subrs.cxx, line 1634:
printf( "\t\tANNOTATION TEXT RELATIVE 3 %S\n",
I have no idea how it will work under Linux...
Is it tested on both platforms within Unicode text (not just for compilation)?

=== OpenGl_TextRender.cxx, OpenGl_TextRender::ExportText, 483-486
  //szv: workaround for gl2ps!
  const int len = wcslen(text);
  char *astr = new char[len+1];
1) Multibyte string will require more bytes for Unicode symbols. You should allocate at least twice greater buffer.
2) It seems that this wcstombs() function will convert to current locale char set, not necessary UTF-8 (especially on Windows).
3) Result not checked and broken buffer may be printed before lucky NULL-termination symbol will occur.

=== OpenGl_graduatedtrihedron.cxx, 80-83
    Standard_ExtString iname = fromData->xname.ToExtString();
    toData->xname = new wchar_t[len+1];
    len = 0; while (toData->xname[len] = (wchar_t)(iname[len])) len++;
incorrect multi-byte UTF16 -> UTF32 conversion in case when wchar_t is 4-bytes long UTF32 (Linux).

Notice that code revision is still in progress...


2011-08-01 17:19

manager   ~0017874


I disagree with your statement:
"So I should generally reject this patch because it is in the wrong direction
(looking for ABV suggestions)."

This patch brings new functionality that was designed long before our discussion with ABV concerning support of multi-byte characters. Moreover, that discussion remained just a discussion, nothing yet is implemented.

So, naturally, when the good concept will be implemented, we shall need to correct this patch, as well as many other places in OCCT. But for now, this patch cases no problems but, on contrary, allows to reach the goal it was designed for.


2011-08-02 08:08

manager   ~0017876

Kirill, we cannot just block this patch because we think of better solution, rather let's:
a) check that it is reasonably safe (as far as I understood, couple of code pieces require correction for that)
b) consider improvement of interface if necessary to facilitate future porting (here I believe having dedicated type Techar can be useful to find all relevant places)
c) make sure test scripts created by QA team are adequate (in my view, the test commands given above might be too simple, as they test single Unicode character -- let's better take 10000-symbol string to provoke overflows)


2011-08-03 10:11

developer   ~0017880

Recommended remarks:

>> ViewerTest_ViewerCommands.cxx, 1752
>> ViewerTest_ViewerCommands.cxx, 1682
>> di<<"Error: "<<argv[0]<<" - invalid number of arguments\n";
Please try to follow punctuation rules from English and do not compress listings without any space (OCR1062).

>> Graphic3d_CGraduatedTrihedron.hxx
>> /* Size of names of axes: 8, 10, 12, 14, ... */
>> Standard_Integer sizeOfNames;
Please prefer C++ style for comments rather than C-style (OCR1047).

>> OpenGl_text.cxx, 152, 161, 451
>> i = 0; while (str[i++]);
>> while (*ptr1++ = (Techar)(*ptr2++));
Please avoid assignment within conditional expression (warning C4706).
And prefer for() cycle constructions in that cases.

>> OpenGl_text.cxx, 154-156
>> wchar_t *wstr = new wchar_t[i];
>> if( !wstr )
>> return TFailure;
It seems to be from C-code.
This NULL check will not work because new should throw exception in case of low memory. But validating the input parameters will be a good idea.

>> OpenGl_text.cxx, 58
>>struct TEL_TEXT_DATA
>> TEL_POINT attach_pt;
>> Tint length;
>> const wchar_t *sdata;
Is there any good reason using muddy names like 'sdata'?
Following naming conception from C past of OpenGl package?


2011-08-03 17:24

manager   ~0017898

As agreed, the remarks related to code style and possible issues with conversion of types are too difficult to be addressed now, and the code will have to be revised anyway later when we implement better support of Unicode.

Thus the fix is ready for testing.

During testing, please ensure that:
a) it does not produce (new) compiler warnings
b) test case employs sufficiently long Unicode string


2011-08-12 11:36

tester   ~0017979

Dear BugMaster,
SVN branch ( http://svn/svn/occt/branches/OCC22149 ) was
testing, test results were compared with KAS:dev:products-651-opt

chl 941 A3 B1 B2 B3 B5 B6
xstp 206 H4

See results in /dn45/occttests/results/KAS/dev/ycy-products-3_10082011/lin/
See reference results in
See test cases in /dn45/occttests/tests/ED
N.B. In order to launch testing case you can make use the following instructions


2011-08-23 15:32

manager   ~0018018

The source file OpenGl_TextRender.cxx is corrected upon results of first tests (there was a problem in export to various formats).
Please test the branch again.


2011-08-25 19:07

tester   ~0018025

Dear BugMaster,
Workbench KAS:dev:mkv-products-4 has been created from SVN branch http://svn/svn/occt/branches/OCC22149
and compiled on Linux platform.

There are not regressions in mkv-products-4 regarding to KAS:dev:products-651-opt

See results in /dn45/occttests/results/KAS/dev/mkv-products-4_24082011/lin
See reference results in /dn45/occttests/results/KAS/dev/products-651-opt_01062011/lin
See test cases in /dn45/occttests/tests/ED
N.B. In order to launch testing case you can make use the following instructions


2011-08-30 12:44

administrator   ~0018037

Fix has been integrated to occt repository

Date: 2011-08-30 12:42:34 +0400 (Tue, 30 Aug 2011)
New Revision: 8915


Related Changesets

occt: master 13a22457

2011-08-30 08:42:34


Committer: bugmaster Details Diff
0022149: Strings with Japanese characters can not be displayed in 3D viewer Affected Issues
mod - src/Graphic3d/Graphic3d_CGraduatedTrihedron.cxx Diff File
mod - src/Graphic3d/Graphic3d_CGraduatedTrihedron.hxx Diff File
mod - src/Graphic3d/Graphic3d_GraphicDriver.cdl Diff File
mod - src/Graphic3d/Graphic3d_GraphicDriver_9.cxx Diff File
mod - src/Graphic3d/Graphic3d_Group_10.cxx Diff File
mod - src/InterfaceGraphic/InterfaceGraphic_Cextern.hxx Diff File
mod - src/InterfaceGraphic/InterfaceGraphic_Graphic3d.hxx Diff File
mod - src/InterfaceGraphic/InterfaceGraphic_telem.hxx Diff File
mod - src/InterfaceGraphic/InterfaceGraphic_tgl_all.hxx Diff File
mod - src/InterfaceGraphic/InterfaceGraphic_Visual3d.hxx Diff File
mod - src/OpenGl/OpenGl_FontMgr.cxx Diff File
mod - src/OpenGl/OpenGl_FontMgr.hxx Diff File
mod - src/OpenGl/OpenGl_funcs.cxx Diff File
mod - src/OpenGl/OpenGl_graduatedtrihedron.cxx Diff File
mod - src/OpenGl/OpenGl_graduatedtrihedron.hxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver.cdl Diff File
mod - src/OpenGl/OpenGl_GraphicDriver_710.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver_713.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver_9.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver_Layer.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver_print.cxx Diff File
mod - src/OpenGl/OpenGl_subrs.cxx Diff File
mod - src/OpenGl/OpenGl_telem_inquire.hxx Diff File
mod - src/OpenGl/OpenGl_text.cxx Diff File
mod - src/OpenGl/OpenGl_TextRender.cxx Diff File
mod - src/OpenGl/OpenGl_TextRender.hxx Diff File
mod - src/OpenGl/OpenGl_tgl_funcs.hxx Diff File
mod - src/OpenGl/OpenGl_togl_begin_layer_mode.cxx Diff File
mod - src/OpenGl/OpenGl_togl_graduatedtrihedron.cxx Diff File
mod - src/OpenGl/OpenGl_togl_text.cxx Diff File
mod - src/OpenGl/OpenGl_triedron.cxx Diff File
mod - src/V3d/V3d_View.cdl Diff File
mod - src/V3d/V3d_View_4.cxx Diff File
mod - src/ViewerTest/ViewerTest_ObjectCommands.cxx Diff File
mod - src/ViewerTest/ViewerTest_ViewerCommands.cxx Diff File
mod - src/Visual3d/Visual3d_View.cdl Diff File
mod - src/Visual3d/Visual3d_View.cxx Diff File

Issue History

Date Modified Username Field Change
2010-12-14 16:32 abv CC => pdn, nkv
2010-12-22 17:54 bugmaster Assigned To bugmaster => szv
2010-12-22 17:54 bugmaster Status new => assigned
2010-12-22 18:06 szv Status assigned => resolved
2011-06-29 16:20 szv CC => mkv
2011-06-29 17:43 bugmaster Status resolved => assigned
2011-07-06 14:15 szv Status assigned => resolved
2011-07-22 17:13 mkv Status resolved => tested
2011-07-26 20:24 bugmaster Assigned To szv => kgv
2011-07-26 20:24 bugmaster Status tested => assigned
2011-08-01 13:08 kgv Note Added: 0017870
2011-08-01 13:10 kgv Note Edited: 0017870
2011-08-01 13:11 kgv Note Edited: 0017870
2011-08-01 17:19 szv Note Added: 0017874
2011-08-02 08:08 abv Note Added: 0017876
2011-08-02 11:24 bugmaster Category OCCT:VIZ => OCCT:Visualization
2011-08-03 10:11 kgv Note Added: 0017880
2011-08-03 12:18 bugmaster Fixed in Version EMPTY =>
2011-08-03 12:18 bugmaster Target Version => 6.5.2
2011-08-03 12:18 bugmaster Description Updated
2011-08-03 14:41 miv Test case number => chl 936 Z8
2011-08-03 17:24 abv Note Added: 0017898
2011-08-03 17:24 abv Status assigned => reviewed
2011-08-12 11:36 ycy Note Added: 0017979
2011-08-23 15:32 szv Note Added: 0018018
2011-08-25 19:07 mkv Note Added: 0018025
2011-08-25 19:08 mkv Status reviewed => tested
2011-08-30 12:44 bugmaster Note Added: 0018037
2011-08-30 12:44 bugmaster Status tested => verified
2011-08-30 12:44 bugmaster Resolution open => fixed
2012-03-29 17:26 bugmaster Changeset attached => occt master 13a22457
2019-05-06 22:55 kgv Relationship added related to 0030696