]> OCCT Git - occt-copy.git/commitdiff
Wrapping functionality in Font_TextFormatter - an interface to obtain width of a...
authornds <nds@opencascade.com>
Mon, 4 Mar 2019 12:13:56 +0000 (15:13 +0300)
committernds <nds@opencascade.com>
Mon, 4 Mar 2019 12:13:56 +0000 (15:13 +0300)
src/Font/Font_TextFormatter.cxx
src/Font/Font_TextFormatter.hxx

index 1474a46c4650c27a8b5a9fbb0f441c30892c306c..5db02b09ea2bd4e8fe0898bde38b4372f614bc44 100644 (file)
@@ -238,7 +238,7 @@ void Font_TextFormatter::Format()
     else
     {
       for (int aLineIt = 0; aLineIt < myLinesNb; aLineIt++)
-        aMaxLineWidth = Max (aMaxLineWidth, getLineWidth (aLineIt));
+        aMaxLineWidth = Max (aMaxLineWidth, LineWidth (aLineIt));
     }
   }
 
@@ -319,7 +319,7 @@ Standard_Boolean Font_TextFormatter::BndBox (const Standard_Integer theIndex, Fo
     else
     {
       // the next symbol is on the next row either by '\n' or by wrapping
-      Standard_ShortReal aLineWidth = getLineWidth (LineIndex (theIndex));
+      Standard_ShortReal aLineWidth = LineWidth (LineIndex (theIndex));
       theBndBox.Left = aLeftCorner.x();
       switch (myAlignX)
       {
@@ -415,10 +415,10 @@ Standard_Boolean Font_TextFormatter::IsCommandSymbol (const Standard_Utf32Char&
 }
 
 // =======================================================================
-// function : getLineWidth
+// function : LineWidth
 // purpose  :
 // =======================================================================
-Standard_ShortReal Font_TextFormatter::getLineWidth (const Standard_Integer theIndex) const
+Standard_ShortReal Font_TextFormatter::LineWidth (const Standard_Integer theIndex) const
 {
   if (theIndex < 0)
     return 0;
@@ -427,7 +427,7 @@ Standard_ShortReal Font_TextFormatter::getLineWidth (const Standard_Integer theI
     return theIndex == 0 ? myNewLines[0] : myNewLines[theIndex] - myNewLines[theIndex -1];
 
   if (theIndex == myNewLines.Length()) // the last line
-    return myPen.x() - getLineWidth (theIndex - 1);
+    return myPen.x() - LineWidth (theIndex - 1);
 
   return 0;
 }
index 79958ca8ef3209ef3735d144e55a6735b02cec36..40444078682148737323260cd434e02ccdda82f8 100755 (executable)
@@ -163,6 +163,9 @@ public:
   Standard_ShortReal LineHeight (const Standard_Integer theIndex) const
   { return theIndex == 0 ? myAscender : myLineSpacing; }
 
+  //!< Returns width of a line
+  Standard_EXPORT Standard_ShortReal LineWidth (const Standard_Integer theIndex) const;
+
   //! Returns true if the symbol by the index is '\n'. The width of the symbol is zero.
   Standard_EXPORT Standard_Boolean IsLFSymbol (const Standard_Integer theIndex) const;
 
@@ -246,10 +249,6 @@ public:
   //!< Returns true if the symbol is CR, BEL, FF, NP, BS or VT
   Standard_EXPORT static Standard_Boolean IsCommandSymbol (const Standard_Utf32Char& theSymbol);
 
-protected:
-  //!< Returns width of a line
-  Standard_ShortReal getLineWidth (const Standard_Integer theIndex) const;
-
   DEFINE_STANDARD_RTTIEXT (Font_TextFormatter, Standard_Transient)
 
 protected: //! @name class auxiliary methods