From 6293bb1169f253e8a593c45ddd59f86c060729e0 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 4 Mar 2019 15:13:56 +0300 Subject: [PATCH] Wrapping functionality in Font_TextFormatter - an interface to obtain width of a line --- src/Font/Font_TextFormatter.cxx | 10 +++++----- src/Font/Font_TextFormatter.hxx | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Font/Font_TextFormatter.cxx b/src/Font/Font_TextFormatter.cxx index 1474a46c46..5db02b09ea 100644 --- a/src/Font/Font_TextFormatter.cxx +++ b/src/Font/Font_TextFormatter.cxx @@ -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; } diff --git a/src/Font/Font_TextFormatter.hxx b/src/Font/Font_TextFormatter.hxx index 79958ca8ef..4044407868 100755 --- a/src/Font/Font_TextFormatter.hxx +++ b/src/Font/Font_TextFormatter.hxx @@ -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 -- 2.39.5