MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0031678Open CASCADE[OCCT] OCCT:Visualizationpublic2020-07-21 13:352020-09-21 17:42
Reporternds 
Assigned Tokgv 
PrioritynormalSeverityfeature 
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version[OCCT] 7.6.0*Fixed in Version 
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 number
Attached Filespng file icon text_on_occt730.png (7,873 bytes) 2020-07-21 13:35
png file icon text_on_occt_IR-2020-06-19.png (7,924 bytes) 2020-07-21 13:35
png file icon text_light_740.png (8,644 bytes) 2020-07-21 15:07
png file icon text_light_750dev.png (8,657 bytes) 2020-07-21 15:07
png file icon text_light_750dev_hinted.png (6,622 bytes) 2020-07-21 17:50
png file icon 31678_wi_comparing.png (76,765 bytes) 2020-07-23 11:26
png file icon krita_arrow_sRGB.png (65,753 bytes) 2020-07-23 14:08
png file icon krita_arrow_scRGB.png (65,870 bytes) 2020-07-23 14:08
png file icon freetype-27-hinting-comparison.png (28,908 bytes) 2020-07-23 19:57
png file icon a8_windows_nohint.png (26,482 bytes) 2020-07-25 20:26
png file icon a8_windows_hinted.png (23,636 bytes) 2020-07-25 20:26
png file icon a8_linux_nohint.png (26,098 bytes) 2020-07-25 20:26
png file icon a8_linux_hinted.png (25,921 bytes) 2020-07-25 20:27

- Relationships
child of 0029528verifiedapn Visualization, TKOpenGl - allow defining sRGB textures 

-  Notes
(0093225)
kgv (developer)
2020-07-21 14:14
edited on: 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).

(0093229)
kgv (developer)
2020-07-21 15:08
edited on: 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


(0093235)
kgv (developer)
2020-07-21 17:55

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.
(0093258)
nds (developer)
2020-07-23 11:35

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
(0093273)
git (administrator)
2020-07-23 23:12

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.
(0093274)
kgv (developer)
2020-07-23 23:39
edited on: 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).

(0093275)
kgv (developer)
2020-07-24 01:18

Patch is ready for review in OCCT branch CR31678.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31678-master-KGV [^]
(0093276)
git (administrator)
2020-07-24 02:28

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()

(0093365)
git (administrator)
2020-07-25 20:30

Branch CR31678 has been updated forcibly by kgv.

SHA-1: 12c2257ae5e701c66148e601dbd7325f600d33be
(0093366)
nds (developer)
2020-07-27 08:33

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

- 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 View Revisions
2020-07-21 14:15 kgv Note Edited: 0093225 View Revisions
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 View Revisions
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 View Revisions
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*


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker