View Issue Details

IDProjectCategoryView StatusLast Update
0031678Open CASCADEOCCT:Visualizationpublic2021-11-25 20:43
Reporternds Assigned Tobugmaster  
PrioritynormalSeverityfeature 
Status closedResolutionfixed 
Target Version7.6.0Fixed in Version7.6.0 
Summary0031678: Visualization - add option enabling hinting for textured fonts
DescriptionSetting color for text aspect gives different result in the viewer.

Calling the attached script on the current master and OCCT release 7.3.0 gives different result, shown on attached images.
Steps To Reproducepload ALL

vinit
vsetcolorbg 255 255 255
vlight -clear
vlight -add ambient
vtrihedron t1 -drawAxes XY -arrowColor 0 0 0 -color Whole 0 0 0 -textColor 0 0 0

vdrawtext text1 surprise -pos 100 100 0 -color 0 0 0 -height 20
vdrawtext text2 20.07.2020 -pos 100 -100 0 -color 0.1725 0.4745 0.70196 -height 20

vdrawtext text3 surprise -pos -200 100 0 -color 0 0 0 -height 20 -font "Segoe UI"
vdrawtext text4 20.07.2020 -pos -200 -100 0 -color 0.1725 0.4745 0.70196 -height 20 -font "Segoe UI"

vfit
vtop
vzoom 0.5
TagsNo tags attached.
Test case numberNot required

Attached Files

  • text_on_occt730.png (7,873 bytes)
  • text_on_occt_IR-2020-06-19.png (7,924 bytes)
  • text_light_740.png (8,644 bytes)
  • text_light_750dev.png (8,657 bytes)
  • text_light_750dev_hinted.png (6,622 bytes)
  • 31678_wi_comparing.png (76,765 bytes)
  • krita_arrow_sRGB.png (65,753 bytes)
  • krita_arrow_scRGB.png (65,870 bytes)
  • freetype-27-hinting-comparison.png (28,908 bytes)
  • a8_windows_nohint.png (26,482 bytes)
  • a8_windows_hinted.png (23,636 bytes)
  • a8_linux_nohint.png (26,098 bytes)
  • a8_linux_hinted.png (25,921 bytes)

Relationships

related to 0032268 resolvedvpozdyayev Community Configuration, CMake - a proposal for minimal build flag in CMake 
child of 0029528 closedapn Open CASCADE Visualization, TKOpenGl - allow defining sRGB textures 

Activities

nds

2020-07-21 13:35

developer  

text_on_occt730.png (7,873 bytes)

nds

2020-07-21 13:35

developer  

text_on_occt_IR-2020-06-19.png (7,924 bytes)

kgv

2020-07-21 14:14

developer   ~0093225

Last edited: 2020-07-21 14:15

This is not a bug, this is how graphics hardware performs color blending.

After 0029528, some text/background combinations become a little bit more readable and some less - no strict evidence that it become only worse has been identified on testing.

The workaround is adjusting colors / fonts / text styles for the cases, where readability looks unpleasant.

Disabling GL_FRAMEBUFFER_SRGB specifically for text elements can be considered option, but for now it does not look reasonable, as it just will make text blending worse/better for different backgrounds combinations. Better alternatives for rendering text to be investigated (no ideas so far).

kgv

2020-07-21 15:07

developer  

text_light_740.png (8,644 bytes)

kgv

2020-07-21 15:07

developer  

text_light_750dev.png (8,657 bytes)

kgv

2020-07-21 15:08

developer   ~0093229

Last edited: 2020-07-21 15:09

Test case in bug description is incorrect - it uses different text colors for OCCT 7.4.0 and for current master.

See attached screenshots for corrected test case:
pload MODELING VISUALIZATION
vinit View
vsetcolorbg 255 255 255
vlight -clear
vlight -add ambient
vtrihedron t1 -drawAxes XY -arrowColor 0 0 0 -color Whole 0 0 0 -textColor 0 0 0

vdrawtext text1 surprise -pos 100 100 0 -color BLACK  -height 20
vdrawtext text2 20.07.2020 -pos 100 -100 0 -color CORNFLOWERBLUE -height 20

vdrawtext text3 surprise -pos -200 100 0 -color BLACK -height 20 -font "Segoe UI"
vdrawtext text4 20.07.2020 -pos -200 -100 0 -color CORNFLOWERBLUE -height 20 -font "Segoe UI"

vfit
vtop
vzoom 0.5


kgv

2020-07-21 17:50

developer  

text_light_750dev_hinted.png (6,622 bytes)

kgv

2020-07-21 17:55

developer   ~0093235

One more option is conditionally enabling hinting for such thin fonts.

Currently, hinting is disabled by FT_LOAD_NO_HINTING flag in Font_FTFont constructor, which according to documentation produces blurrier result.
This will not produce exactly the same result, but as it makes thin fonts less blurry, the blending with background has smaller effect.

nds

2020-07-23 11:26

developer  

31678_wi_comparing.png (76,765 bytes)

nds

2020-07-23 11:35

developer   ~0093258

Dear Kirill

commented flag FT_LOAD_NO_HINTING in Font_FTFont constructor gives better result (see 31678_wi_comparing.png).

It would be great if we may set it using some new additional method in OCCT for such parameter.

Thank you in advance, Natalia

kgv

2020-07-23 14:08

developer  

krita_arrow_sRGB.png (65,753 bytes)

kgv

2020-07-23 14:08

developer  

krita_arrow_scRGB.png (65,870 bytes)

kgv

2020-07-23 19:57

developer  

freetype-27-hinting-comparison.png (28,908 bytes)

git

2020-07-23 23:12

administrator   ~0093273

Branch CR31678 has been created by kgv.

SHA-1: cb8a329e48d8ec80a141edbee70ac8fa9cb9196b


Detailed log of new commits:

Author: kgv
Date: Thu Jul 23 22:39:27 2020 +0300

    0031678: Visualization - add option enabling hinting for textured fonts
    
    Added new rendering parameter Graphic3d_RenderingParams::ToEnableFontHinting
    allowing to enable/disable hinting (default is no hinting preserving old behavior).
    
    SelectMgr_ViewerSelector3d::ClearSensitive() - fixed crash on removing presentations.
    
    Command vrenderparams has been extended with arguments -fontHinting.
    In addition, added new parameters -sync and -reset for synchronizing parameters across Views;
    parameters -raster and -rayTrace now accept optional on|off values.

kgv

2020-07-23 23:39

developer   ~0093274

Last edited: 2020-07-23 23:41

Here is an elaboration about font rendering from FreeType developers:
https://www.freetype.org/freetype2/docs/text-rendering-general.html

> The correct way of rendering a glyph image on a surface
> is to alpha blend it onto the surface in linear space
> and then apply gamma correction to translate the linear coverage map
> to something that is correct for our screens

So that current OCCT behavior more or less follows this guidance.

Hinting algorithms are expected to improve text readability in general on low-resolution screens (hopefully they will die some time).
However, there are a plenty of tricks around hinting (starting from patents, which have been expired circa '2011 according to FreeType).
Consider enabling this feature only on non-HiDPI screens at application level.

Note that OCCT does not support LCD-antialiasing of fonts (also useful only for low-resolution screens).

kgv

2020-07-24 01:18

developer   ~0093275

Patch is ready for review in OCCT branch CR31678.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31678-master-KGV

git

2020-07-24 02:28

administrator   ~0093276

Branch CR31678 has been updated by kgv.

SHA-1: b0435d5aca1bacd41d22eea0c8d109053becc858


Detailed log of new commits:

Author: kgv
Date: Fri Jul 24 02:30:05 2020 +0300

    # update Font_FTFont::AdvanceX()

kgv

2020-07-25 20:26

developer  

a8_windows_nohint.png (26,482 bytes)

kgv

2020-07-25 20:26

developer  

a8_windows_hinted.png (23,636 bytes)

kgv

2020-07-25 20:26

developer  

a8_linux_nohint.png (26,098 bytes)

kgv

2020-07-25 20:27

developer  

a8_linux_hinted.png (25,921 bytes)

git

2020-07-25 20:30

administrator   ~0093365

Branch CR31678 has been updated forcibly by kgv.

SHA-1: 12c2257ae5e701c66148e601dbd7325f600d33be

nds

2020-07-27 08:33

developer   ~0093366

Dear Kirill,

it would be also useful, if you provide your images with additional information:
- Font type,
- Font size,
- Free Type version.

Is it possible to have the same images on light(preferable white) background?

Thank you for investigations,
Natalia

nds

2021-04-14 12:21

developer   ~0100294

Dear Kirill,

could you please raise this patch.
Setting 'ToEnableFontHinting' to 'True' in Graphic3d_RenderingParams of the view provides with expected result.

Thank you for help

git

2021-04-14 16:37

administrator   ~0100295

Branch CR31678_1 has been created by kgv.

SHA-1: 5fc06feb965854bb17b312479d75cf0a8c16041c


Detailed log of new commits:

Author: kgv
Date: Wed Apr 14 14:10:40 2021 +0300

    0031678: Visualization - add option enabling hinting for textured fonts
    
    Added new rendering parameter Graphic3d_RenderingParams::ToEnableFontHinting
    allowing to enable/disable hinting (default is no hinting preserving old behavior).
    
    Command vrenderparams has been extended with arguments -fontHinting.

git

2021-04-14 16:41

administrator   ~0100296

Branch CR31678_1 has been updated forcibly by kgv.

SHA-1: 75d86f032b45890e19eb219a3638f3d9f39d144a

kgv

2021-04-14 17:46

developer   ~0100297

Patch is ready for review
- OCCT: branch CR31678_1.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31678_1-master-KGV/

osa

2021-04-15 10:06

developer   ~0100302

The patch is reviewed

bugmaster

2021-04-17 13:08

administrator   ~0100387

Combination -
OCCT branch : IR-2021-04-16
master SHA - 1294d5e39ed35dc97b2241956855fe794a03b0d8
a87b7ddc8cb44606b91e3f37113847c3f5f50fdc
Products branch : IR-2021-04-16 SHA - 03c3cb382950144b11c09108f24673216c4e5922
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 17987.850000000446 / 18020.24000000038 [-0.18%]
Products
Total CPU difference: 11564.760000000093 / 11543.43000000007 [+0.18%]
Windows-64-VC14:
OCCT
Total CPU difference: 19496.34375 / 19510.890625 [-0.07%]
Products
Total CPU difference: 12932.890625 / 12891.265625 [+0.32%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2021-04-17 14:02

administrator   ~0100404

Branch CR31678_1 has been deleted by inv.

SHA-1: 75d86f032b45890e19eb219a3638f3d9f39d144a

git

2021-04-17 14:02

administrator   ~0100420

Branch CR31678 has been deleted by inv.

SHA-1: 12c2257ae5e701c66148e601dbd7325f600d33be

Related Changesets

occt: master d37aef5c

2021-04-14 11:10:40

kgv


Committer: bugmaster Details Diff
0031678: Visualization - add option enabling hinting for textured fonts

Added new rendering parameter Graphic3d_RenderingParams::FontHinting
allowing to enable/disable hinting (default is no hinting preserving old behavior).

Command vrenderparams has been extended with arguments -fontHinting.
Affected Issues
0031678
mod - src/AIS/AIS_TextLabel.cxx Diff File
mod - src/Font/FILES Diff File
mod - src/Font/Font_FTFont.cxx Diff File
mod - src/Font/Font_FTFont.hxx Diff File
add - src/Font/Font_Hinting.hxx Diff File
mod - src/Graphic3d/Graphic3d_RenderingParams.hxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver.cxx Diff File
mod - src/OpenGl/OpenGl_Text.cxx Diff File
mod - src/OpenGl/OpenGl_Text.hxx Diff File
mod - src/PrsDim/PrsDim_Dimension.cxx Diff File
mod - src/ViewerTest/ViewerTest_ViewerCommands.cxx Diff File
mod - tests/opengl/data/text/A2 Diff File
mod - tests/opengl/data/text/A8 Diff File

Issue History

Date Modified Username Field Change
2020-07-21 13:35 nds New Issue
2020-07-21 13:35 nds Assigned To => kgv
2020-07-21 13:35 nds File Added: text_on_occt730.png
2020-07-21 13:35 nds File Added: text_on_occt_IR-2020-06-19.png
2020-07-21 14:03 kgv Relationship added child of 0029528
2020-07-21 14:14 kgv Note Added: 0093225
2020-07-21 14:15 kgv Note Edited: 0093225
2020-07-21 14:15 kgv Note Edited: 0093225
2020-07-21 15:07 kgv File Added: text_light_740.png
2020-07-21 15:07 kgv File Added: text_light_750dev.png
2020-07-21 15:08 kgv Note Added: 0093229
2020-07-21 15:08 kgv Assigned To kgv => nds
2020-07-21 15:08 kgv Status new => feedback
2020-07-21 15:09 kgv Note Edited: 0093229
2020-07-21 17:50 kgv File Added: text_light_750dev_hinted.png
2020-07-21 17:55 kgv Note Added: 0093235
2020-07-23 11:26 nds File Added: 31678_wi_comparing.png
2020-07-23 11:35 nds Note Added: 0093258
2020-07-23 11:35 nds Assigned To nds => kgv
2020-07-23 11:35 nds Status feedback => assigned
2020-07-23 14:08 kgv File Added: krita_arrow_sRGB.png
2020-07-23 14:08 kgv File Added: krita_arrow_scRGB.png
2020-07-23 19:56 kgv Severity major => feature
2020-07-23 19:56 kgv Summary Visualization - text color becomes lighter than in 7.3.0 => Visualization - add option enabling hinting for textured fonts
2020-07-23 19:57 kgv File Added: freetype-27-hinting-comparison.png
2020-07-23 23:12 git Note Added: 0093273
2020-07-23 23:39 kgv Note Added: 0093274
2020-07-23 23:41 kgv Note Edited: 0093274
2020-07-24 01:18 kgv Note Added: 0093275
2020-07-24 01:18 kgv Assigned To kgv => nds
2020-07-24 01:18 kgv Status assigned => resolved
2020-07-24 01:48 kgv Assigned To nds => kgv
2020-07-24 01:48 kgv Status resolved => assigned
2020-07-24 02:28 git Note Added: 0093276
2020-07-25 20:22 kgv File Added: a8_windows_nohint.png
2020-07-25 20:22 kgv File Added: a8_windows_hinted.png
2020-07-25 20:22 kgv File Added: a8_linux_nohint.png
2020-07-25 20:22 kgv File Added: a8_linux_hinted.png
2020-07-25 20:26 kgv File Deleted: a8_linux_hinted.png
2020-07-25 20:26 kgv File Deleted: a8_linux_nohint.png
2020-07-25 20:26 kgv File Deleted: a8_windows_nohint.png
2020-07-25 20:26 kgv File Deleted: a8_windows_hinted.png
2020-07-25 20:26 kgv File Added: a8_windows_nohint.png
2020-07-25 20:26 kgv File Added: a8_windows_hinted.png
2020-07-25 20:26 kgv File Added: a8_linux_nohint.png
2020-07-25 20:27 kgv File Added: a8_linux_hinted.png
2020-07-25 20:30 git Note Added: 0093365
2020-07-27 08:33 nds Note Added: 0093366
2020-09-21 17:42 kgv Target Version 7.5.0 => 7.6.0
2021-04-14 12:21 nds Note Added: 0100294
2021-04-14 12:30 kgv Status assigned => feedback
2021-04-14 16:37 git Note Added: 0100295
2021-04-14 16:41 git Note Added: 0100296
2021-04-14 17:46 kgv Note Added: 0100297
2021-04-14 17:46 kgv Assigned To kgv => osa
2021-04-14 17:46 kgv Status feedback => reviewed
2021-04-15 09:28 kgv Status reviewed => assigned
2021-04-15 09:28 kgv Status assigned => resolved
2021-04-15 10:06 osa Note Added: 0100302
2021-04-15 10:06 osa Assigned To osa => bugmaster
2021-04-15 10:06 osa Status resolved => reviewed
2021-04-17 13:08 bugmaster Note Added: 0100387
2021-04-17 13:08 bugmaster Status reviewed => tested
2021-04-17 13:13 bugmaster Test case number => Not required
2021-04-17 13:41 bugmaster Changeset attached => occt master d37aef5c
2021-04-17 13:41 bugmaster Status tested => verified
2021-04-17 13:41 bugmaster Resolution open => fixed
2021-04-17 14:02 git Note Added: 0100404
2021-04-17 14:02 git Note Added: 0100420
2021-11-25 20:43 kgv Relationship added parent of 0032268
2021-11-25 20:43 kgv Relationship replaced related to 0032268