0026361: Visualization - move OpenGl_TextFormatter to Font_TextFormatter
[occt.git] / src / Font / Font_FTFont.cxx
index 1e6403e..d05739e 100755 (executable)
@@ -15,6 +15,8 @@
 
 #include <Font_FTFont.hxx>
 #include <Font_FontMgr.hxx>
+#include <Font_TextFormatter.hxx>
+
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_HAsciiString.hxx>
 
@@ -255,3 +257,25 @@ float Font_FTFont::AdvanceY (const Standard_Utf32Char theUCharNext)
   }
   return fromFTPoints<float> (myKernAdvance.y + myFTFace->glyph->advance.y);
 }
+
+// =======================================================================
+// function : BoundingBox
+// purpose  :
+// =======================================================================
+Font_FTFont::Rect Font_FTFont::BoundingBox (const NCollection_String&               theString,
+                                            const Graphic3d_HorizontalTextAlignment theAlignX,
+                                            const Graphic3d_VerticalTextAlignment   theAlignY)
+{
+  Font_TextFormatter aFormatter;
+  aFormatter.SetupAlignment (theAlignX, theAlignY);
+  aFormatter.Reset();
+
+  aFormatter.Append (theString, *this);
+  aFormatter.Format();
+
+  Rect aBndBox;
+
+  aFormatter.BndBox (aBndBox);
+
+  return aBndBox;
+}