Archived issue #0026298
Visualization, OpenGl_Text - make font resolution configurable
Description
On Windows the pangram "The quick brown fox ..." drawn in V3d viewer looks tiny comparing to what you can see in default font browsing utility.
This issue can be solved by setting font's resolution in OpenGl_Text to 96 dpi (see attached images). This looks to be the default resolution for Windows. It is proposed to change the OpenGl_Text's resolution accordingly and check that this solution will be also acceptable for Linux.
The OpenGl_Text's font resolution should be then made application interface dependant. It is proposed to provide API to scale the resolution against it base (96 dpi) by a coefficient passed from application level. That could be a part of #0025350.
This issue can be solved by setting font's resolution in OpenGl_Text to 96 dpi (see attached images). This looks to be the default resolution for Windows. It is proposed to change the OpenGl_Text's resolution accordingly and check that this solution will be also acceptable for Linux.
The OpenGl_Text's font resolution should be then made application interface dependant. It is proposed to provide API to scale the resolution against it base (96 dpi) by a coefficient passed from application level. That could be a part of #0025350.
Steps to reproduce
pload ALL vinit vsetcolorbg 255 255 255 vdrawtext t "The quick brown fox jumps over the lazy dog" -font Courier -height 12 -color 0 0 0
Public activity
23 archived notes
Participants are labeled by their role within this record.
As can be seen on attached screenshots, the behavior of native applications is platform dependent:
- Windows, uses 96 as default
- Linux, uses 96 as default on modern systems
- OS X, still uses 72 as default
It is unclean if we would like to:
- provide behavior consistent across systems (e.g. provide visually identical result), or
- provide platform-dependent result (e.g. vary presentation)
- Windows, uses 96 as default
- Linux, uses 96 as default on modern systems
- OS X, still uses 72 as default
It is unclean if we would like to:
- provide behavior consistent across systems (e.g. provide visually identical result), or
- provide platform-dependent result (e.g. vary presentation)
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Mon Aug 31 14:02:40 2015 +0300
0026298: Visualization, OpenGl_Text - make font resolution configurable
[revision removed]
Detailed log of new commits:
Author: isk
Date: Mon Aug 31 14:02:40 2015 +0300
0026298: Visualization, OpenGl_Text - make font resolution configurable
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Wed Sep 2 12:11:12 2015 +0300
Scale factor of font resolution is property of view.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Wed Sep 2 12:11:12 2015 +0300
Scale factor of font resolution is property of view.
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Wed Sep 2 13:31:33 2015 +0300
Use integer resolution instead of scale factor.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Wed Sep 2 13:31:33 2015 +0300
Use integer resolution instead of scale factor.
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Mon Sep 7 15:13:12 2015 +0300
0026298: Visualization, OpenGl_Text - make font resolution configurable.
Add static const variable for manage resolution of a font by default.
OpenGl_Text::FontKey contain a resolution of a font.
Add resolution of a font and corresponding setter and getter in *_View classes.
Add the new draw command 'vfontres', that sets a new resolution of fonts.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Mon Sep 7 15:13:12 2015 +0300
0026298: Visualization, OpenGl_Text - make font resolution configurable.
Add static const variable for manage resolution of a font by default.
OpenGl_Text::FontKey contain a resolution of a font.
Add resolution of a font and corresponding setter and getter in *_View classes.
Add the new draw command 'vfontres', that sets a new resolution of fonts.
Dear Kirill,
Please review the branch CR26298_1.
Please review the branch CR26298_1.
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Dear Kirill,
Please review the branch CR26298_1.
Please review the branch CR26298_1.
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Thu Sep 24 16:01:48 2015 +0300
Move variable 'resolution' from Graphic3d_CView to Graphic3d_RenderingParams.
Drop redundant variables from OpenGl_Workspace.
Drop StringSize() method from OpenGl_Text.
Update FontKey() and FindFont() methods of OpenGl_Text.
Update OpenGl_GraphicDriver::TextSize() method.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Thu Sep 24 16:01:48 2015 +0300
Move variable 'resolution' from Graphic3d_CView to Graphic3d_RenderingParams.
Drop redundant variables from OpenGl_Workspace.
Drop StringSize() method from OpenGl_Text.
Update FontKey() and FindFont() methods of OpenGl_Text.
Update OpenGl_GraphicDriver::TextSize() method.
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
--- a/src/Graphic3d/Graphic3d_RenderingParams.hxx +++ b/src/Graphic3d/Graphic3d_RenderingParams.hxx +#include <Font_FTFont.hxx>
please remove this include here and in other places.
Try to move constant THE_DEFAULT_RESOLUTION to another place.
It might be reasonable to make theResolution in Font_FTFont::Init() non-optional parameter.
- const unsigned int theResolution = 72); + const unsigned int theResolution = THE_DEFAULT_RESOLUTION);
@@ -487,6 +488,7 @@ void OpenGl_GraphicDriver::TextSize (const Standard_CString theText, + aTextParam.FontResolution = Font_FTFont::THE_DEFAULT_RESOLUTION;
this does not look like a correct fix since colorscale is expected to create the labels with view-specific resolution.
+ Handle(Font_FTFont) aFont = new Font_FTFont();
+ if (aFont->Init (aRequestedFont->FontPath()->ToCString(), aTextParam.Height, aTextParam.FontResolution))
+ {
this might be unreasonably expensive.
+protected: //! @name auxiliary methods for sharing resource. + //! Create key for shared resource + Standard_EXPORT TCollection_AsciiString FontKey (const OpenGl_AspectText& theAspect) const; + + //! Find shared resource for specified font or initialize new one + Standard_EXPORT Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx
names for protected methods should start from lower case.
+void V3d_View::SetResolution (const unsigned int theResolution) +unsigned int V3d_View::Resolution() const
redundant methods.
+ theCommands.Add("vfontres",
vresolution with better description?
- OpenGl_TextParam myParams; + mutable OpenGl_TextParam myParams; ... + myParams.FontResolution = theWorkspace->View()->RenderingParams().Resolution; ... -Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theAspect, - const Standard_Integer theHeight, - const TCollection_AsciiString theKey) +Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, + const OpenGl_AspectText& theAspect, + const TCollection_AsciiString& theKey) const
theses changes do not look very reasonable.
Passing FontResolution as argument would make more sense.
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Mon Sep 28 17:34:27 2015 +0300
Move THE_DEFAULT_RESOLUTION from Font_FTFont to Graphic3d_RenderingParams.
Add a new parameter (Resolution) to Graphic3d_GraphicDriver::TextSize() method (and to OpenGl_GraphicDrive::TextSize()).
Drop FontResolution field from OpenGl_TextParam.
Return OpenGl_Text::StringSize() method.
Add a new parameter (Resolution) to OpenGl_Text::Render() and to OpenGl_Text::render() methods.
Drop redundant methods from V3d_View.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Mon Sep 28 17:34:27 2015 +0300
Move THE_DEFAULT_RESOLUTION from Font_FTFont to Graphic3d_RenderingParams.
Add a new parameter (Resolution) to Graphic3d_GraphicDriver::TextSize() method (and to OpenGl_GraphicDrive::TextSize()).
Drop FontResolution field from OpenGl_TextParam.
Return OpenGl_Text::StringSize() method.
Add a new parameter (Resolution) to OpenGl_Text::Render() and to OpenGl_Text::render() methods.
Drop redundant methods from V3d_View.
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Mon Sep 28 17:26:10 2015 +0300
0026298: Visualization, OpenGl_Text - make font resolution configurable.
Add THE_DEFAULT_RESOLUTION static const parameter to Graphic3d_RenderingParams.
Add resolution to Graphic3d_RenderingParams.
Drop redundant variables from OpenGl_Workspace.
Add a new parameter to Graphic3d_GraphicDriver::TextSize method (and to OpenGl_GraphicDriver).
Add a new parameter to OpenGl_Text::Render() and to OpenGl_Text::render() methods.
OpenGl_Text::FontKey() considers a resolution (PPI) now.
Add the new draw command 'vresolution', that sets a pixel density.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Mon Sep 28 17:26:10 2015 +0300
0026298: Visualization, OpenGl_Text - make font resolution configurable.
Add THE_DEFAULT_RESOLUTION static const parameter to Graphic3d_RenderingParams.
Add resolution to Graphic3d_RenderingParams.
Drop redundant variables from OpenGl_Workspace.
Add a new parameter to Graphic3d_GraphicDriver::TextSize method (and to OpenGl_GraphicDriver).
Add a new parameter to OpenGl_Text::Render() and to OpenGl_Text::render() methods.
OpenGl_Text::FontKey() considers a resolution (PPI) now.
Add the new draw command 'vresolution', that sets a pixel density.
Dear Kirill,
Please review the branch CR26298_2.
Please review the branch CR26298_2.
+static Standard_Integer VResolution (Draw_Interpretor& theDI,
sorry for confusion - the command for rendering parameters already exists (vrenderparams) and should be extended instead of creating new command.
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Tue Sep 29 12:13:41 2015 +0300
Drop 'VResolution' draw-command and update 'VRenderParams' draw-command.
[revision removed]
Detailed log of new commits:
Author: isk
Date: Tue Sep 29 12:13:41 2015 +0300
Drop 'VResolution' draw-command and update 'VRenderParams' draw-command.
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Please test the patch in branch CR26298_2.
Dear Commenter 1,
Branch CR26298_2 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 13 (13 on master)
Windows: 0 (0 on master)
products component :
Linux: 39 (39 on master)
Windows: 0 (0 on master)
Regressions/Differences/Improvements:
No regressions/differences
Testing cases:
http://occt-tests/CR26298-2-master-occt-64/Debian70-64/3rdparty/fonts/C1.html
http://occt-tests/CR26298-2-master-occt-64/Windows-64-VC10/3rdparty/fonts/C1.html
3rdparty fonts C1: OK
Testing on Linux:
occt component :
Total MEMORY difference: 93320074 / 93327239 [-0.01%]
Total CPU difference: 19694.5199999993 / 19849.459999999235 [-0.78%]
products component :
Total MEMORY difference: 26237562 / 26309508 [-0.27%]
Total CPU difference: 7182.109999999996 / 7199.699999999998 [-0.24%]
Testing on Windows:
occt component :
Total MEMORY difference: 57929067 / 57932622 [-0.01%]
Total CPU difference: 17828.4494841988 / 17727.080034399078 [+0.57%]
products component :
Total MEMORY difference: 17137085 / 17140676 [-0.02%]
Total CPU difference: 5653.226638399968 / 5623.134045499962 [+0.54%]
There are no differences in images found by testdiff.
Branch CR26298_2 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 13 (13 on master)
Windows: 0 (0 on master)
products component :
Linux: 39 (39 on master)
Windows: 0 (0 on master)
Regressions/Differences/Improvements:
No regressions/differences
Testing cases:
http://occt-tests/CR26298-2-master-occt-64/Debian70-64/3rdparty/fonts/C1.html
http://occt-tests/CR26298-2-master-occt-64/Windows-64-VC10/3rdparty/fonts/C1.html
3rdparty fonts C1: OK
Testing on Linux:
occt component :
Total MEMORY difference: 93320074 / 93327239 [-0.01%]
Total CPU difference: 19694.5199999993 / 19849.459999999235 [-0.78%]
products component :
Total MEMORY difference: 26237562 / 26309508 [-0.27%]
Total CPU difference: 7182.109999999996 / 7199.699999999998 [-0.24%]
Testing on Windows:
occt component :
Total MEMORY difference: 57929067 / 57932622 [-0.01%]
Total CPU difference: 17828.4494841988 / 17727.080034399078 [+0.57%]
products component :
Total MEMORY difference: 17137085 / 17140676 [-0.02%]
Total CPU difference: 5653.226638399968 / 5623.134045499962 [+0.54%]
There are no differences in images found by testdiff.
Branch [archived branch] has been deleted by Commenter 2.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Commenter 2.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Commenter 2.
[revision removed]
[revision removed]
Related records