]> OCCT Git - occt-copy.git/commitdiff
0029117: Adding translation of Multileader entity CR29117_v720
authoranv <anv@opencascade.com>
Wed, 8 Nov 2017 15:10:34 +0000 (18:10 +0300)
committeranv <anv@opencascade.com>
Wed, 8 Nov 2017 15:10:34 +0000 (18:10 +0300)
Scaling of width of glyphs is added om Font_FTFont class.
Font "SimSan" is specified as fallback alias for font "NSimSan" (contains Chinese hieroglyphs).

src/Font/Font_BRepFont.cxx
src/Font/Font_BRepFont.hxx
src/Font/Font_FTFont.cxx
src/Font/Font_FTFont.hxx
src/Font/Font_FontMgr.cxx

index ff3e47e62d2e175dd118ccacea6824008822b657..ebd2d4a1ea0c6a07c2b652ad870b9ab33ec75389 100755 (executable)
@@ -66,9 +66,10 @@ namespace
 
   //! 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);
   }
 
 }
@@ -286,8 +287,8 @@ Standard_Boolean Font_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
     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);
 
     Standard_Integer aLinePnts = (FT_CURVE_TAG(aTags[aPntsNb - 1]) == FT_Curve_Tag_On) ? 1 : 0;
     gp_XY aPntLine1 = aPntCurr;
@@ -298,7 +299,7 @@ Standard_Boolean Font_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
     {
       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)
@@ -382,7 +383,7 @@ Standard_Boolean Font_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
         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)
         {
index dbbf7d0c0d7501bb08c96a55d240d31d188cd5bf..51dec3d0d6c0cf0bfb5c0ff19ce58caab230f4e0 100755 (executable)
@@ -96,6 +96,13 @@ public:
   //! 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.
index b51cac3f8c87111b4235437be37b073c9a2390a5..007e2181e6267e6450e989ea5c7b754c2d9b9505 100755 (executable)
@@ -29,12 +29,14 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FTFont,Standard_Transient)
 // 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),
-  myKernAdvance(new FT_Vector()),
-  myUChar      (0U)
+: 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)
 {
   if (myFTLib.IsNull())
   {
@@ -266,9 +268,9 @@ float Font_FTFont::AdvanceX (const Standard_Utf32Char theUCharNext)
   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);
 }
 
 // =======================================================================
index 4d500fe0b0017b933ab2d50e3418e426c6bbfd29..297ab4f357072576c988c10130b62922fbf4e51e 100755 (executable)
@@ -100,6 +100,13 @@ public:
     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);
@@ -154,15 +161,17 @@ protected:
 
 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
-
-  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:
 
index 65f24d94c6327f756ebbf3f1633aadc71933a802..ff09fa57dcb8fb9d3bbec0db7b3ecc3c0c74313f 100644 (file)
@@ -49,7 +49,8 @@ static const Font_FontMgr_FontAliasMapNode Font_FontMgr_MapOfFontsAliases[] =
   { "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__)