myBuilder.MakeCompound (aResult);
Standard_Real aScaleUnits = theFont.Scale();
- for (Font_TextFormatter::Iterator aFormatterIt (theFormatter, Font_TextFormatter::IterationFilter_ExcludeInvisible);
+ for (Font_TextFormatter::Iterator aFormatterIt (*theFormatter, Font_TextFormatter::IterationFilter_ExcludeInvisible);
aFormatterIt .More(); aFormatterIt .Next())
{
const NCollection_Vec2<Standard_ShortReal>& aCorner = theFormatter->BottomLeft (aFormatterIt.SymbolPosition());
const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY)
{
- Handle(Font_TextFormatter) aFormatter = new Font_TextFormatter();
- aFormatter->SetupAlignment (theAlignX, theAlignY);
- aFormatter->Reset();
+ Font_TextFormatter aFormatter;
+ aFormatter.SetupAlignment (theAlignX, theAlignY);
+ aFormatter.Reset();
- aFormatter->Append (theString, *this);
- aFormatter->Format();
+ aFormatter.Append (theString, *this);
+ aFormatter.Format();
Font_Rect aBndBox;
- aFormatter->BndBox (aBndBox);
+ aFormatter.BndBox (aBndBox);
return aBndBox;
}
int aSymbolsCounter = 0; // special counter to process tabulation symbols
// first pass - render all symbols using associated font on single ZERO baseline
- Handle(Font_TextFormatter) aFormatter (this);
Standard_Utf32Char aCharThis;
- for (Font_TextFormatter::Iterator aFormatterIt (aFormatter); aFormatterIt .More(); aFormatterIt .Next())
+ for (Font_TextFormatter::Iterator aFormatterIt (*this); aFormatterIt .More(); aFormatterIt .Next())
{
aCharThis = aFormatterIt.Symbol();
const Standard_Utf32Char aCharNext = aFormatterIt.SymbolNext();
Standard_ShortReal anAdvanceX = 0;
- if (Font_TextFormatter::IsCommandSymbol (aCharThis))
+ if (IsCommandSymbol (aCharThis))
{
continue; // skip unsupported carriage control codes
}
Standard_Integer aFirstCornerId = myRectLineStart;
Standard_Integer aLastCornerId = theLastRect;
- if (aFirstCornerId >= getRectsNb())
+ if (aFirstCornerId >= myCorners.Length())
{
++myLinesNb;
myPenCurrLine -= myLineSpacing;
// =======================================================================
void Font_TextFormatter::Format()
{
- if (getRectsNb() == 0 || myIsFormatted)
+ if (myCorners.Length() == 0 || myIsFormatted)
{
return;
}
}
}
- Handle(Font_TextFormatter) aFormatter (this);
- for (Font_TextFormatter::Iterator aFormatterIt (aFormatter);
+ for (Font_TextFormatter::Iterator aFormatterIt (*this);
aFormatterIt .More(); aFormatterIt .Next())
{
const Standard_Utf32Char aCharThis = aFormatterIt.Symbol();
myBndWidth = aMaxLineWidth;
// move last line
- newLine (getRectsNb() - 1, aMaxLineWidth);
+ newLine (myCorners.Length() - 1, aMaxLineWidth);
// apply vertical alignment style
if (myAlignY == Graphic3d_VTA_BOTTOM)
if (myAlignY != Graphic3d_VTA_TOP)
{
- moveY (myCorners, myBndTop, 0, getRectsNb() - 1);
+ moveY (myCorners, myBndTop, 0, myCorners.Length() - 1);
}
}
// =======================================================================
Standard_Boolean Font_TextFormatter::BndBox (const Standard_Integer theIndex, Font_Rect& theBndBox) const
{
- if (theIndex < 0 || theIndex >= GetCorners().Size())
+ if (theIndex < 0 || theIndex >= Corners().Size())
return Standard_False;
const NCollection_Vec2<Standard_ShortReal>& aLeftCorner = BottomLeft (theIndex);
}
// =======================================================================
-// function : GetFirstPosition
+// function : FirstPosition
// purpose :
// =======================================================================
-Standard_ShortReal Font_TextFormatter::GetFirstPosition() const
+Standard_ShortReal Font_TextFormatter::FirstPosition() const
{
switch (myAlignX)
{
return (Standard_Integer)Abs((BottomLeft (theIndex).y() + myAscender) / myLineSpacing);
}
-// =======================================================================
-// function : IsCommandSymbol
-// purpose :
-// =======================================================================
-Standard_Boolean Font_TextFormatter::IsCommandSymbol (const Standard_Utf32Char& theSymbol)
-{
- if (theSymbol == '\x0D' // CR (carriage return)
- || theSymbol == '\a' // BEL (alarm)
- || theSymbol == '\f' // FF (form feed) NP (new page)
- || theSymbol == '\b' // BS (backspace)
- || theSymbol == '\v') // VT (vertical tab)
- return Standard_True;
-
- return Standard_False;
-}
-
// =======================================================================
// function : LineWidth
// purpose :
{
public:
//! Constructor with initialization.
- Iterator (const Handle(Font_TextFormatter)& theFormatter,
+ Iterator (const Font_TextFormatter& theFormatter,
IterationFilter theFilter = IterationFilter_None)
- : myFormatter (theFormatter), myFilter (theFilter), myIter (theFormatter->myString.Iterator())
+ : myFilter (theFilter), myIter (theFormatter.myString.Iterator())
{
mySymbolPosition = readNextSymbol (-1, mySymbolChar);
mySymbolNext = readNextSymbol (mySymbolPosition, mySymbolCharNext);
Standard_Boolean HasNext() const { return mySymbolNext >= 0; }
//! Returns current symbol.
- const Standard_Utf32Char& Symbol() const { return mySymbolChar; }
+ Standard_Utf32Char Symbol() const { return mySymbolChar; }
//! Returns the next symbol if exists.
- const Standard_Utf32Char& SymbolNext() const { return mySymbolCharNext; }
+ Standard_Utf32Char SymbolNext() const { return mySymbolCharNext; }
//! Returns current symbol position.
- const Standard_Integer& SymbolPosition() const { return mySymbolPosition; }
+ Standard_Integer SymbolPosition() const { return mySymbolPosition; }
//! Returns the next symbol position.
- const Standard_Integer& SymbolPositionNext() const { return mySymbolNext; }
+ Standard_Integer SymbolPositionNext() const { return mySymbolNext; }
//! Moves to the next item.
void Next()
}
protected:
- Handle(Font_TextFormatter) myFormatter; //!< source class for iterating
IterationFilter myFilter; //!< possibility to filter not-necessary symbols
NCollection_Utf8Iter myIter; //!< the next symbol iterator value over the text formatter string
Standard_EXPORT Standard_Boolean IsLFSymbol (const Standard_Integer theIndex) const;
//! Returns position of the first symbol in a line using alignment
- Standard_EXPORT Standard_ShortReal GetFirstPosition() const;
+ Standard_EXPORT Standard_ShortReal FirstPosition() const;
//! Returns column index of the corner index in the current line
Standard_EXPORT Standard_Integer LinePositionIndex (const Standard_Integer theIndex) const;
//! Returns row index of the corner index among text lines
Standard_EXPORT Standard_Integer LineIndex (const Standard_Integer theIndex) const;
- //! Returns current rendering string.
- //! Obsolete method, please use Iterator to get the string characters
- //inline const NCollection_String& String() const
- //{
- // return myString;
- //}
-
//! Returns tab size.
inline Standard_Integer TabSize() const
{
}
//!< Returns internal container of the top left corners of a formatted rectangles.
- const NCollection_Vector < NCollection_Vec2<Standard_ShortReal> >& GetCorners() const { return myCorners; }
+ const NCollection_Vector < NCollection_Vec2<Standard_ShortReal> >& Corners() const { return myCorners; }
- const NCollection_Vector<Standard_ShortReal>& GetNewLines() const { return myNewLines; }
+ const NCollection_Vector<Standard_ShortReal>& NewLines() const { return myNewLines; }
//!< Returns true if the symbol is CR, BEL, FF, NP, BS or VT
- Standard_EXPORT static Standard_Boolean IsCommandSymbol (const Standard_Utf32Char& theSymbol);
+ static inline Standard_Boolean IsCommandSymbol (const Standard_Utf32Char& theSymbol)
+ {
+ if (theSymbol == '\x0D' // CR (carriage return)
+ || theSymbol == '\a' // BEL (alarm)
+ || theSymbol == '\f' // FF (form feed) NP (new page)
+ || theSymbol == '\b' // BS (backspace)
+ || theSymbol == '\v') // VT (vertical tab)
+ return Standard_True;
+
+ return Standard_False;
+ }
DEFINE_STANDARD_RTTIEXT (Font_TextFormatter, Standard_Transient)
Standard_EXPORT void newLine (const Standard_Integer theLastRect,
const Standard_ShortReal theMaxLineWidth);
- //!< Returns rectangle number
- Standard_Integer getRectsNb() { return myCorners.Length(); }
-
protected: //! @name configuration
Graphic3d_HorizontalTextAlignment myAlignX; //!< horizontal alignment style
#include <Graphic3d_TransformUtils.hxx>
#include <Graphic3d_RenderingParams.hxx>
+#include <Font_TextFormatter.hxx>
+
#include <Message_Messenger.hxx>
#include <NCollection_Vector.hxx>
memset (myFuncs.operator->(), 0, sizeof(OpenGl_GlFunctions));
myShaderManager = new OpenGl_ShaderManager (this);
+
+ myDefaultFormatter = new Font_TextFormatter();
}
// =======================================================================
typedef OpenGl_TmplCore45<OpenGl_GlCore44Back> OpenGl_GlCore45Back;
typedef OpenGl_TmplCore45<OpenGl_GlCore44> OpenGl_GlCore45;
+class Font_TextFormatter;
class Graphic3d_PresentationAttributes;
class OpenGl_Aspects;
class OpenGl_FrameBuffer;
//! @return tool for management of shader programs within this context.
inline const Handle(OpenGl_ShaderManager)& ShaderManager() const { return myShaderManager; }
+ //! @return default formatter of text withing this context
+ inline const Handle(Font_TextFormatter)& DefaultTextFormatter() const { return myDefaultFormatter; }
+
public:
//! Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1).
Standard_Boolean myHasRayTracingAdaptiveSamplingAtomic; //! indicates whether atomic adaptive screen sampling in ray tracing mode is supported
Handle(OpenGl_ShaderManager) myShaderManager; //! support object for managing shader programs
+ Handle(Font_TextFormatter) myDefaultFormatter;//!< default text formatter, an alternative to text params
private: //! @name fields tracking current state
Handle(Font_TextFormatter) aFormatter = myFormatter;
if (myFormatter.IsNull())
{
- aFormatter = new Font_TextFormatter();
+ aFormatter = theCtx->DefaultTextFormatter();
aFormatter->SetupAlignment (myParams.HAlign, myParams.VAlign);
aFormatter->Reset();
theTCrdsPerTexture.Clear();
OpenGl_Font::Tile aTile = {Font_Rect(), Font_Rect(), 0u};
- for (Font_TextFormatter::Iterator aFormatterIt (theFormatter, Font_TextFormatter::IterationFilter_ExcludeInvisible);
+ for (Font_TextFormatter::Iterator aFormatterIt (*theFormatter, Font_TextFormatter::IterationFilter_ExcludeInvisible);
aFormatterIt .More(); aFormatterIt .Next())
{
theFont.RenderGlyph (theCtx, aFormatterIt.Symbol(), aTile);