View Issue Details

IDProjectCategoryView StatusLast Update
0023457CommunityOCCT:Visualizationpublic2020-09-12 10:42
ReporterPawel Assigned Tokgv  
Status closedResolutionfixed 
PlatformWindowsOSVC++ 2008 
Product Version6.5.3 
Target Version6.6.0Fixed in Version6.6.0 
Summary0023457: Slow text rendering
DescriptionThis issue was discussed in:

Here the summary:

- One more question: I have noticed that displaying lots of texts (Graphic3d_AspectText3d) slows the the view navigation a lot. I started investigating the issue and observed that is not the case for the OCCT 5.2 (haven't tried all the releases in between, only some). Would you know what the reason might be?

- We have not analyzed this point in depth yet, though we suspect FTGL of doing some non-optimal things during rendering. By the way, OCCT 5.x did not use FTGL.

Another problem that arises when the number of text labels drawn using Graphic3d_Group::Text() method becomes large is described in, note that the part related to text rendering will not be corrected in OCCT 6.5.3 release.

There is an intention to put some efforts to improve text rendering in the future OCCT releases. There is already a Mantis issue where the discussion has been started:

NOTE: As an important consequence of this issue implementation, OCCT will no longer use FTGL library.
TagsNo tags attached.
Test case numberNot needed


related to 0023049 closedbugmaster Open CASCADE Optimize packaging and dependencies of visualization libraries 
related to 0023069 closedkgv Open CASCADE OpenGL state extraction for GL_RENDER_MODE significantly impact performance 
parent of 0028915 closedkgv Open CASCADE Configuration, Font_BRepFont - do not include FreeType headers within OCCT headers 
parent of 0030970 closedVico Liang Community Visualization - Font Name don't support Unicode (such as Chinese) 
parent of 0031762 closedabv Open CASCADE Visualization, Font_TextFormatter - tabulation length is respected with one extra symbol shift 
related to 0023519 closedbugmaster Community Mixing wireframe and shaded visualization impacts performance 
related to 0023747 closedsan Open CASCADE Enabling environment mapping breaks text rendering 
related to 0023756 closedsan Community VBO rendering problem (1) 
related to 0023758 closedibs Open CASCADE Removing support of FTGL product amd FontMFT from WOK 



2013-02-04 11:00

developer   ~0023246

Dear san,
patch is ready for review in CR23457_1 branch.


2013-02-05 15:08

developer   ~0023262

Dear kgv!

I have several remarks on the solution:

First of all, there is a bug:

Trihedron text color gets lost after drawing any colored text string (drawexe).
The scenario is the following:
>> vinit
>> vdrawtext to print red text
>> vtrihedron --> trihedron's labels are red

Minor remarks:

1) OpenGl_TextFormatter::Append
    myAscender = Max (myAscender, theFont.Ascender());
    myLineSpacing = Max (myLineSpacing, theFont.LineSpacing());

    if (theString.IsEmpty())

The ascender and linespacing values shouldn't change if null string passed, so the first two lines should be located below the return statement.
* Already committed to branch.

2) OpenGl_Display.hxx

class Handle(OpenGl_PrinterContext); - unnecessary forward declaration removed
* Already committed to branch.

3) Font_FTFont.hxx/.cxx

Magic number of multiplication (division) on 64 of point size values is implemented as protected inline methods toFTPoints (fromFTPoints) to underline semantic of these operations - conversion to 26.6 fixed-point format used by parts of FT API.
* Already committed to branch.

4) Font_FTFont::Init

In case of return, the method doesn't clean-up myFontPath, myPointSize values. In contrast with the further implementation of the method it seems strange (Release() there does the stuff).

    myFontPath = theFontPath;
    myPointSize = thePointSize;
    if (!myFTLib->isValid())
      std::cerr << "FreeType library is unavailable!\n";
      return false;

    if (FT_New_Face (myFTLib->getInstance(), myFontPath.ToCString(), 0, &myFTFace) != 0)
      //std::cerr << "Font '" << myFontPath << "' fail to load!\n";
      return false;

5) OpenGl_Text::StringSize

The logic of this method is not purely used anywhere in OCC, but:
This method introduces its own size calculation logic that differs from the one implemented in Render method (Render method delegates this function to OpenGl_TextFormatter instance). Moreover, it is uses hard-coded 8 pixel offset to represent tabulation (assuming that it is the default value of OpenGl_TextFormatter class).

    else if (aCharThis == '\t')
      aWidth += aFont->AdvanceX (' ', aCharNext) * 8.0f;

6) OpenGl_Context::ReleaseDelayed

The code of resource delay cleanup implementation is confusing. ++anIter.ChangeValue() <= 2 increases cleanup request iteration counter and checks for hard-coded value of 2 (two iterations). There are no comments that give straight definitions of what is done there. I think the delayed clean-up code could be refactored for better readability.

  NCollection_Vector<TCollection_AsciiString> aDeadList;
  for (NCollection_DataMap<TCollection_AsciiString, Standard_Integer>::Iterator anIter (*myDelayed);
       anIter.More(); anIter.Next())
    if (++anIter.ChangeValue() <= 2)
      continue; // postpone release one more frame to ensure noone use it periodically

7) Font_FTLibrary.hxx

Lowercase naming of public methods: isValid(), getInstance().

8) All found remarks on comments and misprints are already commited into branch.


2013-02-06 12:47

developer   ~0023270

Branch CR23457_2 reviewed without remarks, ready for testing.


2013-02-07 11:56

developer   ~0023274

Dear Bugmaster,

a hot fix for regression was pushed into CR23457_2 branch.
Wrong depth-value computed for printed text.

Dear apl, thanks for your remarks.
> Trihedron text color gets lost after drawing any colored text string.
> The scenario is the following:
>> vdrawtext "My Red Text" 0 0 0 255 0 0 0 0 0 0 12 0
>> vtrihedron t
this is not a regression. Please consider registering of new bug if needed.


2013-02-07 14:40

developer   ~0023276

Dear kgv,

Separate bug record 0023745 added for the thrihedron label colors.


2013-02-08 13:02

tester   ~0023289

Dear BugMaster,

Branch CR234457_2 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
SHA-1: b2bfb5e0224111b4a0672724ceb3f3f0bcf41423

Number of compiler warnings:

occt component :
Linux: 3 (3 on master)
Windows: 39 (39 on master)

products component :
Linux: 9 (9 on master)
Windows: 50 (50 on master)

No regressions

No improvements

Testing cases:
Not needed

Tests chl/941/A3,B2,B3,B5 was correted afther pushing this fix to master (length of exported files).

Testing on Linux:
Total MEMORY difference: 237292236 / 238777776
Total CPU difference: 8703.330000000147 / 10074.61999999991

Testing on Windows:
Total MEMORY difference: 338989052 / 339706676
Total CPU difference: 12605.15625 / 12682.375

There are not serious differences in images found by testdiff.


2013-02-08 13:53

developer   ~0023290

Just for information. New test cases were added to 3rdparty/fonts grid: A3 and A4 intended to estimate font rendering performance.

Tests were performed on following configuration:
Windows 7 SP1 x86_64 / 8 GiB RAM / Radeon HD 6450

Test case 3rdparty/fonts/A3 performs rendering of one huge static text label.
FPS: 18.93 / 206.13 (before the patch / after the patch)
CPU: 53.04 / 4.21 msec

Test case 3rdparty/fonts/A4 displays a lot of small static text labels.
FPS: 11.16 / 40.99 (before the patch / after the patch)
CPU: 90.01 / 24.33 msec

So text presentation caching may benefit up to 10x boost in some cases based on lower CPU load.


2013-02-11 20:53

developer   ~0023303

Thank you for solving this issue!

At the moment I can say navigation (rotation/panning etc.) in a view with a lot of texts got faster.

Unfortunately, I can observe crashes in the graphics driver. As it looks reproducible, I will provide more details as soon as possible.


Related Changesets

occt: master a174a3c5

2013-02-08 11:05:16


Details Diff
0023457: Slow text rendering

Added class Font_FTFont wrapper over FreeType face

Unify collections methods NCollection_Array1, NCollection_Sequence, NCollection_Vector:
declare Upper, Lower, First, Last, ChangeFirst, ChangeLast methods for all these collections.

Added method NCollection_DataMap::Find() with check key is bound + retrieve value within single call interface.

OpenGl_Context::ReleaseResource() method now supports lazy release of shared resources.

Added class OpenGl_Font which implements textured fonts support.
Added class OpenGl_TextFormatter for text formatting using OpenGl_Font.

OpenGl_Text was redesigned to use OpenGl_FontFormatter.

OpenGl_FontMgr class was removed.
All methods related to text rendered removed from OpenGl_Display class.

OpenGl_Trihedron and OpenGl_GraduatedTrihedron classes were redesigned
to use OpenGl_Text.

OpenGl_PrinterContext instance was moved to OpenGl_GraphicDriver fields
(eliminated usage of global instance).

Added test cases into 3rdparty/fonts grid to check different font styles
and perform FPS tests (no automated results - requires manual analysis
or snapshots comparisons).

Removed unused CSF_FTGL dependency.
OpenGl_Text::setupMatrix - do not apply floor for myWinZ
Affected Issues
mod - src/Font/FILES Diff File
mod - src/Font/Font.cdl Diff File
add - src/Font/Font_FTFont.cxx Diff File
add - src/Font/Font_FTFont.hxx Diff File
add - src/Font/Font_FTLibrary.hxx Diff File
mod - src/Font/Font_SystemFont.cxx Diff File
mod - src/NCollection/FILES Diff File
mod - src/NCollection/NCollection_Array1.hxx Diff File
mod - src/NCollection/NCollection_DataMap.hxx Diff File
mod - src/NCollection/NCollection_Sequence.hxx Diff File
add - src/NCollection/NCollection_UtfIterator.hxx Diff File
add - src/NCollection/NCollection_UtfIterator.lxx Diff File
add - src/NCollection/NCollection_UtfString.hxx Diff File
add - src/NCollection/NCollection_UtfString.lxx Diff File
mod - src/NCollection/NCollection_Vector.hxx Diff File
mod - src/NIS/NIS_TriangulatedDrawer.cxx Diff File
mod - src/OpenGl/EXTERNLIB Diff File
mod - src/OpenGl/FILES Diff File
mod - src/OpenGl/OpenGl_AspectText.cxx Diff File
mod - src/OpenGl/OpenGl_AspectText.hxx Diff File
mod - src/OpenGl/OpenGl_Context.cxx Diff File
mod - src/OpenGl/OpenGl_Context.hxx Diff File
mod - src/OpenGl/OpenGl_Display.cxx Diff File
mod - src/OpenGl/OpenGl_Display.hxx Diff File
rm - src/OpenGl/OpenGl_Display_1.cxx Diff File
mod - src/OpenGl/OpenGl_Element.hxx Diff File
add - src/OpenGl/OpenGl_Font.cxx Diff File
add - src/OpenGl/OpenGl_Font.hxx Diff File
rm - src/OpenGl/OpenGl_FontMgr.cxx Diff File
rm - src/OpenGl/OpenGl_FontMgr.hxx Diff File
mod - src/OpenGl/OpenGl_FrameBuffer.cxx Diff File
mod - src/OpenGl/OpenGl_GraduatedTrihedron.cxx Diff File
mod - src/OpenGl/OpenGl_GraduatedTrihedron.hxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver.hxx Diff File
rm - src/OpenGl/OpenGl_GraphicDriver_705.cxx Diff File
rm - src/OpenGl/OpenGl_GraphicDriver_710.cxx Diff File
rm - src/OpenGl/OpenGl_GraphicDriver_9.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver_Layer.cxx Diff File
mod - src/OpenGl/OpenGl_PrinterContext.cxx Diff File
mod - src/OpenGl/OpenGl_PrinterContext.hxx Diff File
mod - src/OpenGl/OpenGl_Text.cxx Diff File
mod - src/OpenGl/OpenGl_Text.hxx Diff File
add - src/OpenGl/OpenGl_TextFormatter.cxx Diff File
add - src/OpenGl/OpenGl_TextFormatter.hxx Diff File
mod - src/OpenGl/OpenGl_Texture.cxx Diff File
mod - src/OpenGl/OpenGl_Texture.hxx Diff File
mod - src/OpenGl/OpenGl_Trihedron.cxx Diff File
mod - src/OpenGl/OpenGl_Trihedron.hxx Diff File
mod - src/OpenGl/OpenGl_VertexBufferEditor.hxx Diff File
mod - src/OpenGl/OpenGl_View.cxx Diff File
mod - src/OpenGl/OpenGl_View.hxx Diff File
mod - src/OpenGl/OpenGl_View_2.cxx Diff File
mod - src/OpenGl/OpenGl_Workspace.cxx Diff File
mod - src/OpenGl/OpenGl_Workspace.hxx Diff File
mod - src/OpenGl/OpenGl_Workspace_2.cxx Diff File
rm - src/OpenGl/OpenGl_Workspace_4.cxx Diff File
mod - src/OpenGl/OpenGl_Workspace_5.cxx Diff File
mod - src/Standard/Standard.cdl Diff File
mod - src/Standard/Standard_Integer.hxx Diff File
mod - src/Standard/Standard_TypeDef.hxx Diff File
mod - src/TKOpenGl/EXTERNLIB Diff File
mod - src/ViewerTest/ViewerTest_OpenGlCommands.cxx Diff File
add - tests/3rdparty/fonts/A3 Diff File
add - tests/3rdparty/fonts/A4 Diff File
add - tests/3rdparty/fonts/A5 Diff File
add - tests/3rdparty/fonts/A6 Diff File
add - tests/3rdparty/fonts/A7 Diff File

Issue History

Date Modified Username Field Change
2012-10-02 14:48 Pawel New Issue
2012-10-02 14:48 Pawel Assigned To => bugmaster
2012-10-02 14:49 Pawel Relationship added related to 0023049
2012-10-02 14:58 Pawel Relationship added related to 0023069
2012-10-02 15:12 kgv Assigned To bugmaster => kgv
2012-10-02 15:12 kgv Target Version => 6.6.0
2012-11-07 15:38 Pawel Relationship added related to 0023519
2013-02-04 11:00 kgv Note Added: 0023246
2013-02-04 11:00 kgv Assigned To kgv => san
2013-02-04 11:00 kgv Status new => resolved
2013-02-05 15:08 apl Note Added: 0023262
2013-02-06 12:47 san Note Added: 0023270
2013-02-06 12:47 san Assigned To san => bugmaster
2013-02-06 12:47 san Status resolved => reviewed
2013-02-07 11:56 kgv Note Added: 0023274
2013-02-07 14:40 apl Note Added: 0023276
2013-02-08 13:02 mkv Note Added: 0023289
2013-02-08 13:03 mkv Test case number => Not needed
2013-02-08 13:03 mkv Status reviewed => tested
2013-02-08 13:53 kgv Note Added: 0023290
2013-02-08 15:01 san Relationship added related to 0023747
2013-02-08 15:06 san Description Updated
2013-02-11 17:42 kgv Changeset attached => occt master a174a3c5
2013-02-11 17:42 kgv Assigned To bugmaster => kgv
2013-02-11 17:42 kgv Status tested => verified
2013-02-11 17:42 kgv Resolution open => fixed
2013-02-11 20:53 Pawel Note Added: 0023303
2013-02-12 20:28 Pawel Relationship added related to 0023756
2013-02-15 00:16 kgv Relationship added related to 0023758
2013-03-20 12:38 abv Relationship added parent of 0023842
2013-03-21 08:29 kgv Relationship deleted parent of 0023842
2013-04-23 13:35 aiv Status verified => closed
2013-04-29 15:24 aiv Fixed in Version => 6.6.0
2013-06-09 20:54 san Relationship added related to 0022484
2013-06-09 20:59 san Relationship deleted related to 0022484
2017-07-17 11:30 kgv Relationship added parent of 0028915
2019-09-17 15:25 kgv Relationship added parent of 0030970
2020-09-12 10:42 kgv Relationship added parent of 0031762