Scaling of width of glyphs is added om Font_FTFont class.
Font "SimSan" is specified as fallback alias for font "NSimSan" (contains Chinese hieroglyphs).
//! Auxiliary method to convert FT_Vector to gp_XY
static gp_XY readFTVec (const FT_Vector& theVec,
- const Standard_Real theScaleUnits)
+ const Standard_Real theScaleUnits,
+ const Standard_Real theWidthScaling = 1.0)
{
- return gp_XY (theScaleUnits * Standard_Real(theVec.x) / 64.0, theScaleUnits * Standard_Real(theVec.y) / 64.0);
+ return gp_XY (theScaleUnits * Standard_Real(theVec.x) * theWidthScaling / 64.0, theScaleUnits * Standard_Real(theVec.y) / 64.0);
}
}
BRepBuilderAPI_MakeWire aWireMaker;
gp_XY aPntPrev;
- gp_XY aPntCurr = readFTVec (aPntList[aPntsNb - 1], myScaleUnits);
- gp_XY aPntNext = readFTVec (aPntList[0], myScaleUnits);
+ gp_XY aPntCurr = readFTVec (aPntList[aPntsNb - 1], myScaleUnits, myWidthScaling);
+ gp_XY aPntNext = readFTVec (aPntList[0], myScaleUnits, myWidthScaling);
bool isLineSeg = !myIsSingleLine
&& FT_CURVE_TAG(aTags[aPntsNb - 1]) == FT_Curve_Tag_On;
{
aPntPrev = aPntCurr;
aPntCurr = aPntNext;
- aPntNext = readFTVec (aPntList[(aPntId + 1) % aPntsNb], myScaleUnits);
+ aPntNext = readFTVec (aPntList[(aPntId + 1) % aPntsNb], myScaleUnits, myWidthScaling);
// process tags
if (FT_CURVE_TAG(aTags[aPntId]) == FT_Curve_Tag_On)
my4Poles.SetValue (1, aPntPrev);
my4Poles.SetValue (2, aPntCurr);
my4Poles.SetValue (3, aPntNext);
- my4Poles.SetValue (4, gp_Pnt2d(readFTVec (aPntList[(aPntId + 2) % aPntsNb], myScaleUnits)));
+ my4Poles.SetValue (4, gp_Pnt2d(readFTVec (aPntList[(aPntId + 2) % aPntsNb], myScaleUnits, myWidthScaling)));
Handle(Geom2d_BezierCurve) aBezier = new Geom2d_BezierCurve (my4Poles);
if (myIsCompositeCurve)
{
//! Notice that altering this flag clears currently accumulated cache!
Standard_EXPORT void SetCompositeCurveMode (const Standard_Boolean theToConcatenate);
+ //! Setup glyph scaling along X-axis.
+ //! By default glyphs are not scaled (scaling factor = 1.0)
+ void SetWidthScaling (const float theScaleFactor)
+ {
+ myWidthScaling = theScaleFactor;
+ }
+
public:
//! @return vertical distance from the horizontal baseline to the highest character coordinate.
// purpose :
// =======================================================================
Font_FTFont::Font_FTFont (const Handle(Font_FTLibrary)& theFTLib)
-: myFTLib (theFTLib),
- myFTFace (NULL),
- myPointSize (0U),
- myLoadFlags (FT_LOAD_NO_HINTING | FT_LOAD_TARGET_NORMAL),
+: myFTLib (theFTLib),
+ myFTFace (NULL),
+ myPointSize (0U),
+ myWidthScaling(1.0),
+ myLoadFlags (FT_LOAD_NO_HINTING | FT_LOAD_TARGET_NORMAL),
myIsSingleLine(false),
- myKernAdvance(new FT_Vector()),
- myUChar (0U)
+ myKernAdvance (new FT_Vector()),
+ myUChar (0U)
{
if (myFTLib.IsNull())
{
if (FT_HAS_KERNING (myFTFace) == 0 || theUCharNext == 0
|| FT_Get_Kerning (myFTFace, myUChar, theUCharNext, FT_KERNING_UNFITTED, myKernAdvance) != 0)
{
- return fromFTPoints<float> (myFTFace->glyph->advance.x);
+ return myWidthScaling * fromFTPoints<float> (myFTFace->glyph->advance.x);
}
- return fromFTPoints<float> (myKernAdvance->x + myFTFace->glyph->advance.x);
+ return myWidthScaling * fromFTPoints<float> (myKernAdvance->x + myFTFace->glyph->advance.x);
}
// =======================================================================
return myPointSize;
}
+ //! Setup glyph scaling along X-axis.
+ //! By default glyphs are not scaled (scaling factor = 1.0)
+ void SetWidthScaling (const float theScaleFactor)
+ {
+ myWidthScaling = theScaleFactor;
+ }
+
//! Compute advance to the next character with kerning applied when applicable.
//! Assuming text rendered horizontally.
Standard_EXPORT float AdvanceX (const Standard_Utf32Char theUCharNext);
protected:
- Handle(Font_FTLibrary) myFTLib; //!< handle to the FT library object
- FT_Face myFTFace; //!< FT face object
- NCollection_String myFontPath; //!< font path
- unsigned int myPointSize; //!< point size set by FT_Set_Char_Size
- int32_t myLoadFlags; //!< default load flags
- bool myIsSingleLine;//!< single stroke font flag, FALSE by default
-
- Image_PixMap myGlyphImg; //!< cached glyph plane
- FT_Vector* myKernAdvance; //!< buffer variable
- Standard_Utf32Char myUChar; //!< currently loaded unicode character
+ Handle(Font_FTLibrary) myFTLib; //!< handle to the FT library object
+ FT_Face myFTFace; //!< FT face object
+ NCollection_String myFontPath; //!< font path
+ unsigned int myPointSize; //!< point size set by FT_Set_Char_Size
+ float myWidthScaling; //!< scale glyphs along X-axis
+ int32_t myLoadFlags; //!< default load flags
+ bool myIsSingleLine; //!< single stroke font flag, FALSE by default
+
+ Image_PixMap myGlyphImg; //!< cached glyph plane
+ FT_Vector* myKernAdvance; //!< buffer variable
+ Standard_Utf32Char myUChar; //!< currently loaded unicode character
public:
{ "Symbol" , "Symbol" , Font_FA_Regular },
{ "ZapfDingbats" , "WingDings" , Font_FA_Regular },
{ "Rock" , "Arial" , Font_FA_Regular },
- { "Iris" , "Lucida Console" , Font_FA_Regular }
+ { "Iris" , "Lucida Console" , Font_FA_Regular },
+ { "NSimSun" , "SimSun" , Font_FA_Regular }
#elif defined(__ANDROID__)