Open CASCADE Technology 7.8.0
|
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 <StdPrs_BRepFont.hxx>
Public Member Functions | |
StdPrs_BRepFont () | |
Empty constructor. | |
StdPrs_BRepFont (const NCollection_String &theFontPath, const Standard_Real theSize, const Standard_Integer theFaceId=0) | |
Constructor with initialization. | |
StdPrs_BRepFont (const NCollection_String &theFontName, const Font_FontAspect theFontAspect, const Standard_Real theSize, const Font_StrictLevel theStrictLevel=Font_StrictLevel_Any) | |
Constructor with initialization. | |
virtual void | Release () |
Release currently loaded font. | |
bool | Init (const NCollection_String &theFontPath, const Standard_Real theSize, const Standard_Integer theFaceId) |
Initialize the font. | |
bool | FindAndInit (const TCollection_AsciiString &theFontName, const Font_FontAspect theFontAspect, const Standard_Real theSize, const Font_StrictLevel theStrictLevel=Font_StrictLevel_Any) |
Find (using Font_FontMgr) and initialize the font from the given name. 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. | |
const Handle< Font_FTFont > & | FTFont () const |
Return wrapper over FreeType font. | |
TopoDS_Shape | RenderGlyph (const Standard_Utf32Char &theChar) |
Render single glyph as TopoDS_Shape. | |
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! | |
void | SetWidthScaling (const float theScaleFactor) |
Setup glyph scaling along X-axis. By default glyphs are not scaled (scaling factor = 1.0) | |
Standard_Real | Ascender () const |
Standard_Real | Descender () const |
Standard_Real | LineSpacing () const |
Standard_Real | PointSize () const |
Configured point size. | |
Standard_Real | AdvanceX (const Standard_Utf32Char theUCharNext) |
Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally. | |
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. | |
Standard_Real | AdvanceY (const Standard_Utf32Char theUCharNext) |
Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically. | |
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. | |
Standard_Real | Scale () const |
Returns scaling factor for current font size. | |
Standard_Mutex & | Mutex () |
Returns mutex. | |
bool | Init (const NCollection_String &theFontName, const Font_FontAspect theFontAspect, const Standard_Real theSize) |
Find (using Font_FontMgr) and initialize the font from the given name. Alias for FindAndInit() for backward compatibility. | |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. | |
virtual | ~Standard_Transient () |
Destructor must be virtual. | |
virtual const opencascade::handle< Standard_Type > & | DynamicType () const |
Returns a type descriptor about this object. | |
Standard_Boolean | IsInstance (const opencascade::handle< Standard_Type > &theType) const |
Returns a true value if this is an instance of Type. | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. | |
Standard_Boolean | IsKind (const opencascade::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. | |
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. | |
Standard_Transient * | This () const |
Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. | |
Standard_Integer | GetRefCount () const noexcept |
Get the reference counter of this object. | |
void | IncrementRefCounter () noexcept |
Increments the reference counter of this object. | |
Standard_Integer | DecrementRefCounter () noexcept |
Decrements the reference counter of this object; returns the decremented value. | |
virtual void | Delete () const |
Memory deallocator for transient classes. | |
Static Public Member Functions | |
static Handle< StdPrs_BRepFont > | FindAndCreate (const TCollection_AsciiString &theFontName, const Font_FontAspect theFontAspect, const Standard_Real theSize, const Font_StrictLevel theStrictLevel=Font_StrictLevel_Any) |
Find the font Initialize the font. | |
Static Public Member Functions inherited from Standard_Transient | |
static constexpr const char * | get_type_name () |
Returns a type descriptor about this object. | |
static const opencascade::handle< Standard_Type > & | get_type_descriptor () |
Returns type descriptor of Standard_Transient class. | |
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. | |
Protected Attributes | |
Protected fields | |
Handle< Font_FTFont > | myFTFont |
wrapper over FreeType font | |
NCollection_DataMap< Standard_Utf32Char, TopoDS_Shape > | myCache |
glyphs cache | |
Standard_Mutex | myMutex |
lock for thread-safety | |
Handle< Geom_Surface > | mySurface |
surface to place glyphs on to | |
Standard_Real | myPrecision |
algorithm precision | |
Standard_Real | myScaleUnits |
scale font rendering units into model units | |
Standard_Boolean | myIsCompositeCurve |
flag to merge C1 curves of each contour into single C0 curve, OFF by default | |
Shared temporary variables for glyph construction | |
Adaptor3d_CurveOnSurface | myCurvOnSurf |
Handle< Geom2dAdaptor_Curve > | myCurve2dAdaptor |
Geom2dConvert_CompCurveToBSplineCurve | myConcatMaker |
TColgp_Array1OfPnt2d | my3Poles |
TColgp_Array1OfPnt2d | my4Poles |
BRep_Builder | myBuilder |
Additional Inherited Members | |
Public Types inherited from Standard_Transient | |
typedef void | base_type |
Returns a type descriptor about this object. | |
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.
StdPrs_BRepFont::StdPrs_BRepFont | ( | ) |
Empty constructor.
StdPrs_BRepFont::StdPrs_BRepFont | ( | const NCollection_String & | theFontPath, |
const Standard_Real | theSize, | ||
const Standard_Integer | theFaceId = 0 |
||
) |
Constructor with initialization.
theFontPath | FULL path to the font |
theSize | the face size in model units |
theFaceId | face id within the file (0 by default) |
StdPrs_BRepFont::StdPrs_BRepFont | ( | const NCollection_String & | theFontName, |
const Font_FontAspect | theFontAspect, | ||
const Standard_Real | theSize, | ||
const Font_StrictLevel | theStrictLevel = Font_StrictLevel_Any |
||
) |
Constructor with initialization.
theFontName | the font name |
theFontAspect | the font style |
theSize | the face size in model units |
theStrictLevel | search strict level for using aliases and fallback |
|
inline |
Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally.
|
inline |
Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally.
|
inline |
Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically.
|
inline |
Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically.
|
inline |
|
inline |
|
static |
Find the font Initialize the font.
theFontName | the font name |
theFontAspect | the font style |
theSize | the face size in model units |
theStrictLevel | search strict level for using aliases and fallback |
bool StdPrs_BRepFont::FindAndInit | ( | const TCollection_AsciiString & | theFontName, |
const Font_FontAspect | theFontAspect, | ||
const Standard_Real | theSize, | ||
const Font_StrictLevel | theStrictLevel = Font_StrictLevel_Any |
||
) |
Find (using Font_FontMgr) and initialize the font from the given name. 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.
theFontName | the font name |
theFontAspect | the font style |
theSize | the face size in model units |
theStrictLevel | search strict level for using aliases and fallback |
|
inline |
Return wrapper over FreeType font.
|
inline |
Find (using Font_FontMgr) and initialize the font from the given name. Alias for FindAndInit() for backward compatibility.
bool StdPrs_BRepFont::Init | ( | const NCollection_String & | theFontPath, |
const Standard_Real | theSize, | ||
const Standard_Integer | theFaceId | ||
) |
Initialize the font.
theFontPath | FULL path to the font |
theSize | the face size in model units |
theFaceId | face id within the file (0 by default) |
|
inline |
|
inline |
Returns mutex.
|
inline |
Configured point size.
|
virtual |
Release currently loaded font.
TopoDS_Shape StdPrs_BRepFont::RenderGlyph | ( | const Standard_Utf32Char & | theChar | ) |
Render single glyph as TopoDS_Shape.
theChar | glyph identifier |
|
protected |
Render single glyph as TopoDS_Shape. This method does not lock the mutex.
theChar | glyph identifier |
theShape | rendered glyph within cache, might be NULL shape |
|
inline |
Returns scaling factor for current font size.
void StdPrs_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!
Setup glyph scaling along X-axis. By default glyphs are not scaled (scaling factor = 1.0)
|
protected |
|
protected |
|
protected |
|
protected |
glyphs cache
|
protected |
|
protected |
|
protected |
|
protected |
wrapper over FreeType font
|
protected |
flag to merge C1 curves of each contour into single C0 curve, OFF by default
|
protected |
lock for thread-safety
|
protected |
algorithm precision
|
protected |
scale font rendering units into model units
|
protected |
surface to place glyphs on to