Open CASCADE Technology: Font_BRepFont Class Reference

Open CASCADE Technology 6.9.1

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- Data Structures
- Data Structure Index
- Class Hierarchy
- Data Fields

Public Member Functions | Protected Member Functions
Font_BRepFont Class Reference

This tool provides basic services for rendering of vectorized text glyphs as BRep shapes. Single instance initialize single font for sequential glyphs rendering with implicit caching of already rendered glyphs. Thus position of each glyph in the text is specified by shape location. More...

`#include <Font_BRepFont.hxx>`

Inheritance diagram for Font_BRepFont:
[legend]

## Public Member Functions
| Font_BRepFont ()
| Empty constructor. More...
| Font_BRepFont (const NCollection_String &theFontPath, const Standard_Real theSize)
| Constructor with initialization. More...
| Font_BRepFont (const NCollection_String &theFontName, const Font_FontAspect theFontAspect, const Standard_Real theSize)
| Constructor with initialization. More...
virtual void | Release ()
| Release currently loaded font. More...
bool | Init (const NCollection_String &theFontPath, const Standard_Real theSize)
| Initialize the font. More...
bool | Init (const NCollection_String &theFontName, const Font_FontAspect theFontAspect, const Standard_Real theSize)
| Initialize the font. Please take into account that size is specified NOT in typography points (pt.). If you need to specify size in points, value should be converted. Formula for pt. -> m conversion: aSizeMeters = 0.0254 * theSizePt / 72.0. More...
TopoDS_Shape | RenderGlyph (const Standard_Utf32Char &theChar)
| Render single glyph as TopoDS_Shape. More...
void | SetCompositeCurveMode (const Standard_Boolean theToConcatenate)
| Setup glyph geometry construction mode. By default algorithm creates independent TopoDS_Edge for each original curve in the glyph (line segment or Bezie curve). Algorithm might optionally create composite BSpline curve for each contour which reduces memory footprint but limits curve class to C0. Notice that altering this flag clears currently accumulated cache! More...
TopoDS_Shape | RenderText (const NCollection_String &theString)
| Render text as BRep shape. More...
TopoDS_Shape | RenderText (const NCollection_String &theString, const gp_Ax3 &thePenLoc)
| Render text as BRep shape. More...
Standard_Real | Ascender () const
Standard_Real | Descender () const
Standard_Real | LineSpacing () const
Standard_Real | PointSize () const
| Configured point size. More...
Standard_Real | AdvanceX (const Standard_Utf32Char theUCharNext)
| Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally. More...
Standard_Real | AdvanceX (const Standard_Utf32Char theUChar, const Standard_Utf32Char theUCharNext)
| Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally. More...
Standard_Real | AdvanceY (const Standard_Utf32Char theUCharNext)
| Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically. More...
Standard_Real | AdvanceY (const Standard_Utf32Char theUChar, const Standard_Utf32Char theUCharNext)
| Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically. More...

## Protected Member Functions
Standard_Boolean | renderGlyph (const Standard_Utf32Char theChar, TopoDS_Shape &theShape)
| Render single glyph as TopoDS_Shape. This method does not lock the mutex. More...
Protected Member Functions inherited from Font_FTFont
template<typename theInput_t >
FT_F26Dot6 | toFTPoints (const theInput_t thePointSize) const
| Convert value to 26.6 fixed-point format for FT library API. More...
template<typename theReturn_t , typename theFTUnits_t >
theReturn_t | fromFTPoints (const theFTUnits_t theFTUnits) const
| Convert value from 26.6 fixed-point format for FT library API. More...
bool | loadGlyph (const Standard_Utf32Char theUChar)
| Load glyph without rendering it. More...
| Font_FTFont (const Handle< Font_FTLibrary > &theFTLib=NULL)
| Create uninitialized instance. More...
virtual | ~Font_FTFont ()
| Destructor. More...
bool | IsValid () const
const Image_PixMap & | GlyphImage () const
bool | Init (const NCollection_String &theFontPath, const unsigned int thePointSize, const unsigned int theResolution=72)
| Initialize the font. More...
bool | Init (const NCollection_String &theFontName, const Font_FontAspect theFontAspect, const unsigned int thePointSize, const unsigned int theResolution)
| Initialize the font. More...
bool | RenderGlyph (const Standard_Utf32Char theChar)
| Render specified glyph into internal buffer (bitmap). More...
unsigned int | GlyphMaxSizeX () const
unsigned int | GlyphMaxSizeY () const
float | Ascender () const
float | Descender () const
float | LineSpacing () const
unsigned int | PointSize () const
| Configured point size. More...
float | AdvanceX (const Standard_Utf32Char theUCharNext)
| Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally. More...
float | AdvanceX (const Standard_Utf32Char theUChar, const Standard_Utf32Char theUCharNext)
| Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally. More...
float | AdvanceY (const Standard_Utf32Char theUCharNext)
| Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically. More...
float | AdvanceY (const Standard_Utf32Char theUChar, const Standard_Utf32Char theUCharNext)
| Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically. More...
Standard_Integer | GlyphsNumber () const
void | GlyphRect (Font_FTFont::Rect &theRect) const
| Retrieve glyph bitmap rectangle. More...
Protected Member Functions inherited from Standard_Transient
| Standard_Transient ()
| Empty constructor. More...
| Standard_Transient (const Standard_Transient &)
| Copy constructor – does nothing. More...
Standard_Transient & | operator= (const Standard_Transient &)
| Assignment operator, needed to avoid copying reference counter. More...
virtual | ~Standard_Transient ()
| Destructor must be virtual. More...
virtual void | Delete () const
| Memory deallocator for transient classes. More...
virtual const Handle_Standard_Type & | DynamicType () const
| Returns a type information object about this object. More...
Standard_Boolean | IsInstance (const Handle_Standard_Type &theType) const
| Returns a true value if this is an instance of Type. More...
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const
| Returns a true value if this is an instance of TypeName. More...
Standard_Boolean | IsKind (const Handle_Standard_Type &theType) const
| Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
Standard_Boolean | IsKind (const Standard_CString theTypeName) const
| Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
virtual Handle_Standard_Transient | This () const
| Returns a Handle which references this object. Must never be called to objects created in stack. More...
Standard_Integer | GetRefCount () const
| Get the reference counter of this object. More...

## Protected Attributes
Protected fields
NCollection_DataMap< Standard_Utf32Char, TopoDS_Shape > | myCache
| glyphs cache More...
Standard_Mutex | myMutex
| lock for thread-safety More...
Handle< Geom_Surface > | mySurface
| surface to place glyphs on to More...
Standard_Real | myPrecision
| algorithm precision More...
Standard_Real | myScaleUnits
| scale font rendering units into model units More...
Standard_Boolean | myIsCompositeCurve
| flag to merge C1 curves of each contour into single C0 curve, ON by default More...
Shared temporary variables for glyph construction
Adaptor3d_CurveOnSurface | myCurvOnSurf
Handle< Geom2dAdaptor_HCurve > | myCurve2dAdaptor
Geom2dConvert_CompCurveToBSplineCurve | myConcatMaker
TColgp_Array1OfPnt2d | my3Poles
TColgp_Array1OfPnt2d | my4Poles
BRep_Builder | myBuilder
ShapeFix_Face | myFixer
Protected Attributes inherited from Font_FTFont
Handle< Font_FTLibrary > | myFTLib
| handle to the FT library object More...
FT_Face | myFTFace
| FT face object. More...
NCollection_String | myFontPath
| font path More...
unsigned int | myPointSize
| point size set by FT_Set_Char_Size More...
FT_Int32 | myLoadFlags
| default load flags More...
Image_PixMap | myGlyphImg
| cached glyph plane More...
FT_Vector | myKernAdvance
| buffer variable More...
Standard_Utf32Char | myUChar
| currently loaded unicode character More...

## Detailed Description

This tool provides basic services for rendering of vectorized text glyphs as BRep shapes. Single instance initialize single font for sequential glyphs rendering with implicit caching of already rendered glyphs. Thus position of each glyph in the text is specified by shape location.

Please notice that this implementation uses mutex for thread-safety access, thus may lead to performance penalties in case of concurrent access. Although caching should eliminate this issue after rendering of sufficient number of glyphs.

## Constructor & Destructor Documentation

Font_BRepFont::Font_BRepFont | ( |  | ) |

Empty constructor.

Font_BRepFont::Font_BRepFont | ( | const NCollection_String & | theFontPath,
|  | const Standard_Real | theSize
| ) |  |

Constructor with initialization.

Parameters

  theFontPath | FULL path to the font
  theSize | the face size in model units

Font_BRepFont::Font_BRepFont | ( | const NCollection_String & | theFontName,
|  | const Font_FontAspect | theFontAspect,
|  | const Standard_Real | theSize
| ) |  |

Constructor with initialization.

Parameters

  theFontName | the font name
  theFontAspect | the font style
  theSize | the face size in model units

## Member Function Documentation

Standard_Real Font_BRepFont::AdvanceX | ( | const Standard_Utf32Char | theUCharNext | ) |
| inline

Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally.

Standard_Real Font_BRepFont::AdvanceX | ( | const Standard_Utf32Char | theUChar,
|  | const Standard_Utf32Char | theUCharNext
| ) |  |
| inline

Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally.

Standard_Real Font_BRepFont::AdvanceY | ( | const Standard_Utf32Char | theUCharNext | ) |
| inline

Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically.

Standard_Real Font_BRepFont::AdvanceY | ( | const Standard_Utf32Char | theUChar,
|  | const Standard_Utf32Char | theUCharNext
| ) |  |
| inline

Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically.

Standard_Real Font_BRepFont::Ascender | ( |  | ) | const
| inline

Returns
  vertical distance from the horizontal baseline to the highest character coordinate.

Standard_Real Font_BRepFont::Descender | ( |  | ) | const
| inline

Returns
  vertical distance from the horizontal baseline to the lowest character coordinate.

bool Font_BRepFont::Init | ( | const NCollection_String & | theFontPath,
|  | const Standard_Real | theSize
| ) |  |

Initialize the font.

Parameters

  theFontPath | FULL path to the font
  theSize | the face size in model units

Returns
  true on success

bool Font_BRepFont::Init | ( | const NCollection_String & | theFontName,
|  | const Font_FontAspect | theFontAspect,
|  | const Standard_Real | theSize
| ) |  |

Initialize the font. Please take into account that size is specified NOT in typography points (pt.). If you need to specify size in points, value should be converted. Formula for pt. -> m conversion: aSizeMeters = 0.0254 * theSizePt / 72.0.

Parameters

  theFontName | the font name
  theFontAspect | the font style
  theSize | the face size in model units

Returns
  true on success

Standard_Real Font_BRepFont::LineSpacing | ( |  | ) | const
| inline

Returns
  default line spacing (the baseline-to-baseline distance).

Standard_Real Font_BRepFont::PointSize | ( |  | ) | const
| inline

Configured point size.

virtual void Font_BRepFont::Release | ( |  | ) |
| virtual

Release currently loaded font.

Reimplemented from Font_FTFont.

TopoDS_Shape Font_BRepFont::RenderGlyph | ( | const Standard_Utf32Char & | theChar | ) |

Render single glyph as TopoDS_Shape.

Parameters

  theChar | glyph identifier

Returns
  rendered glyph within cache, might be NULL shape

Standard_Boolean Font_BRepFont::renderGlyph | ( | const Standard_Utf32Char | theChar,
|  | TopoDS_Shape & | theShape
| ) |  |
| protected

Render single glyph as TopoDS_Shape. This method does not lock the mutex.

Parameters

  theChar | glyph identifier
  theShape | rendered glyph within cache, might be NULL shape

Returns
  true if glyph's geometry is available

TopoDS_Shape Font_BRepFont::RenderText | ( | const NCollection_String & | theString | ) |

Render text as BRep shape.

Parameters

  theString | text in UTF-8 encoding

Returns
  result shape within XOY plane and start position (0,0,0) on the baseline

TopoDS_Shape Font_BRepFont::RenderText | ( | const NCollection_String & | theString,
|  | const gp_Ax3 & | thePenLoc
| ) |  |
| inline

Render text as BRep shape.

Parameters

  theString | text in UTF-8 encoding
  thePenLoc | start position and orientation on the baseline

Returns
  result shape with pen transformation applied as shape location

void Font_BRepFont::SetCompositeCurveMode | ( | const Standard_Boolean | theToConcatenate | ) |

Setup glyph geometry construction mode. By default algorithm creates independent TopoDS_Edge for each original curve in the glyph (line segment or Bezie curve). Algorithm might optionally create composite BSpline curve for each contour which reduces memory footprint but limits curve class to C0. Notice that altering this flag clears currently accumulated cache!

## Field Documentation

TColgp_Array1OfPnt2d Font_BRepFont::my3Poles
| protected

TColgp_Array1OfPnt2d Font_BRepFont::my4Poles
| protected

BRep_Builder Font_BRepFont::myBuilder
| protected

NCollection_DataMap<Standard_Utf32Char, TopoDS_Shape> Font_BRepFont::myCache
| protected

glyphs cache

Geom2dConvert_CompCurveToBSplineCurve Font_BRepFont::myConcatMaker
| protected

Handle< Geom2dAdaptor_HCurve > Font_BRepFont::myCurve2dAdaptor
| protected

Adaptor3d_CurveOnSurface Font_BRepFont::myCurvOnSurf
| protected

ShapeFix_Face Font_BRepFont::myFixer
| protected

Standard_Boolean Font_BRepFont::myIsCompositeCurve
| protected

flag to merge C1 curves of each contour into single C0 curve, ON by default

Standard_Mutex Font_BRepFont::myMutex
| protected

lock for thread-safety

Standard_Real Font_BRepFont::myPrecision
| protected

algorithm precision

Standard_Real Font_BRepFont::myScaleUnits
| protected

scale font rendering units into model units

Handle< Geom_Surface > Font_BRepFont::mySurface
| protected

surface to place glyphs on to

The documentation for this class was generated from the following file:

- Font_BRepFont.hxx