1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

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.
This commit is contained in:
kgv
2021-04-14 14:10:40 +03:00
committed by bugmaster
parent 75e1b51170
commit d37aef5ccf
13 changed files with 282 additions and 47 deletions

View File

@@ -96,6 +96,26 @@ bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData,
myBuffer = theData;
myFontPath = theFileName;
myFontParams = theParams;
// manage hinting style
if ((theParams.FontHinting & Font_Hinting_Light) != 0
&& (theParams.FontHinting & Font_Hinting_Normal) != 0)
{
throw Standard_ProgramError ("Font_FTFont, Light and Normal hinting styles are mutually exclusive");
}
setLoadFlag (FT_LOAD_TARGET_LIGHT, (theParams.FontHinting & Font_Hinting_Light) != 0);
setLoadFlag (FT_LOAD_NO_HINTING, (theParams.FontHinting & Font_Hinting_Normal) == 0
&& (theParams.FontHinting & Font_Hinting_Light) == 0);
// manage native / autohinting
if ((theParams.FontHinting & Font_Hinting_ForceAutohint) != 0
&& (theParams.FontHinting & Font_Hinting_NoAutohint) != 0)
{
throw Standard_ProgramError ("Font_FTFont, ForceAutohint and NoAutohint are mutually exclusive");
}
setLoadFlag (FT_LOAD_FORCE_AUTOHINT, (theParams.FontHinting & Font_Hinting_ForceAutohint) != 0);
setLoadFlag (FT_LOAD_NO_AUTOHINT, (theParams.FontHinting & Font_Hinting_NoAutohint) != 0);
if (!myFTLib->IsValid())
{
Message::SendTrace ("FreeType library is unavailable");
@@ -597,7 +617,8 @@ float Font_FTFont::AdvanceX (Standard_Utf32Char theUCharNext) const
#ifdef HAVE_FREETYPE
FT_Vector aKern;
getKerning (aKern, myUChar, theUCharNext);
return myWidthScaling * fromFTPoints<float> (myActiveFTFace->glyph->advance.x + aKern.x);
return myWidthScaling * fromFTPoints<float> (myActiveFTFace->glyph->advance.x + aKern.x
+ myActiveFTFace->glyph->lsb_delta - myActiveFTFace->glyph->rsb_delta);
#else
(void )theUCharNext;
return 0.0f;