Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
Font_FontMgr Class Reference

Collects and provides information about available fonts in system. More...

#include <Font_FontMgr.hxx>

Inheritance diagram for Font_FontMgr:
Inheritance graph
[legend]

Public Member Functions

void AvailableFonts (NCollection_List< occ::handle< Font_SystemFont > > &theList) const
 Return the list of available fonts.
 
NCollection_List< occ::handle< Font_SystemFont > > GetAvailableFonts () const
 Return the list of available fonts.
 
void GetAvailableFontsNames (NCollection_Sequence< occ::handle< TCollection_HAsciiString > > &theFontsNames) const
 Returns sequence of available fonts names.
 
occ::handle< Font_SystemFontGetFont (const occ::handle< TCollection_HAsciiString > &theFontName, const Font_FontAspect theFontAspect, const int theFontSize) const
 Returns font that match given parameters. If theFontName is empty string returned font can have any FontName. If theFontAspect is Font_FA_Undefined returned font can have any FontAspect. If theFontSize is "-1" returned font can have any FontSize.
 
occ::handle< Font_SystemFontGetFont (const TCollection_AsciiString &theFontName) const
 Returns font that match given name or NULL if such font family is NOT registered. Note that unlike FindFont(), this method ignores font aliases and does not look for fall-back.
 
occ::handle< Font_SystemFontFindFont (const TCollection_AsciiString &theFontName, Font_StrictLevel theStrictLevel, Font_FontAspect &theFontAspect, bool theDoFailMsg=true) const
 Tries to find font by given parameters. If the specified font is not found tries to use font names mapping. If the requested family name not found -> search for any font family with given aspect and height. If the font is still not found, returns any font available in the system. Returns NULL in case when the fonts are not found in the system.
 
occ::handle< Font_SystemFontFindFont (const TCollection_AsciiString &theFontName, Font_FontAspect &theFontAspect) const
 Tries to find font by given parameters.
 
occ::handle< Font_SystemFontFindFallbackFont (Font_UnicodeSubset theSubset, Font_FontAspect theFontAspect) const
 Tries to find fallback font for specified Unicode subset. Returns NULL in case when fallback font is not found in the system.
 
bool CheckFont (NCollection_Sequence< occ::handle< Font_SystemFont > > &theFonts, const TCollection_AsciiString &theFontPath) const
 Read font file and retrieve information from it (the list of font faces).
 
occ::handle< Font_SystemFontCheckFont (const char *const theFontPath) const
 Read font file and retrieve information from it.
 
bool RegisterFont (const occ::handle< Font_SystemFont > &theFont, const bool theToOverride)
 Register new font. If there is existing entity with the same name and properties but different path then font will be overridden or ignored depending on theToOverride flag.
 
bool RegisterFonts (const NCollection_Sequence< occ::handle< Font_SystemFont > > &theFonts, const bool theToOverride)
 Register new fonts.
 
bool ToTraceAliases () const
 Return flag for tracing font aliases usage via Message_Trace messages; TRUE by default.
 
void SetTraceAliases (bool theToTrace)
 Set flag for tracing font alias usage; useful to trace which fonts are actually used. Can be disabled to avoid redundant messages with Message_Trace level.
 
bool ToPrintErrors () const
 Return flag for printing error messages via Message_Fail messages; TRUE by default.
 
void SetPrintErrors (bool theToPrintErrors)
 Set flag for printing error messages. Can be disabled to avoid error messages with Message_Fail level.
 
void GetAllAliases (NCollection_Sequence< occ::handle< TCollection_HAsciiString > > &theAliases) const
 Return font names with defined aliases.
 
void GetFontAliases (NCollection_Sequence< occ::handle< TCollection_HAsciiString > > &theFontNames, const TCollection_AsciiString &theAliasName) const
 Return aliases to specified font name.
 
bool AddFontAlias (const TCollection_AsciiString &theAliasName, const TCollection_AsciiString &theFontName)
 Register font alias.
 
bool RemoveFontAlias (const TCollection_AsciiString &theAliasName, const TCollection_AsciiString &theFontName)
 Unregister font alias.
 
void InitFontDataBase ()
 Collects available fonts paths.
 
void ClearFontDataBase ()
 Clear registry. Can be used for testing purposes.
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool 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.
 
bool IsKind (const char *const 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_TransientThis () 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.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Static Public Member Functions

static occ::handle< Font_FontMgrGetInstance ()
 Return global instance of font manager.
 
static const charFontAspectToString (Font_FontAspect theAspect)
 Return font aspect as string.
 
static boolToUseUnicodeSubsetFallback ()
 Return flag to use fallback fonts in case if used font does not include symbols from specific Unicode subset; TRUE by default.
 
static occ::handle< NCollection_BufferEmbedFallbackFont ()
 Return DejaVu font as embed a single fallback font. It can be used in cases when there is no own font file. Note: result buffer is readonly and should not be changed, any data modification can lead to unpredictable consequences.
 
- Static Public Member Functions inherited from Standard_Transient
static constexpr const charget_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.
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object.
 

Detailed Description

Collects and provides information about available fonts in system.

Member Function Documentation

◆ AddFontAlias()

bool Font_FontMgr::AddFontAlias ( const TCollection_AsciiString & theAliasName,
const TCollection_AsciiString & theFontName )

Register font alias.

Font alias allows using predefined short-cuts like Font_NOF_MONOSPACE or Font_NOF_SANS_SERIF, and defining several fallback fonts like Font_NOF_CJK ("cjk") or "courier" for fonts, which availability depends on system.

By default, Font_FontMgr registers standard aliases, which could be extended or replaced by application basing on better knowledge of the system or basing on additional fonts packaged with application itself. Aliases are defined "in advance", so that they could point to non-existing fonts, and they are resolved dynamically on request - first existing font is returned in case of multiple aliases to the same name.

Parameters
[in]theAliasNamealias name or name of another font to be used as alias
[in]theFontNamefont to be used as substitution for alias
Returns
FALSE if alias has been already registered

◆ AvailableFonts()

void Font_FontMgr::AvailableFonts ( NCollection_List< occ::handle< Font_SystemFont > > & theList) const
inline

Return the list of available fonts.

◆ CheckFont() [1/2]

occ::handle< Font_SystemFont > Font_FontMgr::CheckFont ( const char *const theFontPath) const

Read font file and retrieve information from it.

◆ CheckFont() [2/2]

bool Font_FontMgr::CheckFont ( NCollection_Sequence< occ::handle< Font_SystemFont > > & theFonts,
const TCollection_AsciiString & theFontPath ) const

Read font file and retrieve information from it (the list of font faces).

◆ ClearFontDataBase()

void Font_FontMgr::ClearFontDataBase ( )

Clear registry. Can be used for testing purposes.

◆ EmbedFallbackFont()

static occ::handle< NCollection_Buffer > Font_FontMgr::EmbedFallbackFont ( )
static

Return DejaVu font as embed a single fallback font. It can be used in cases when there is no own font file. Note: result buffer is readonly and should not be changed, any data modification can lead to unpredictable consequences.

◆ FindFallbackFont()

occ::handle< Font_SystemFont > Font_FontMgr::FindFallbackFont ( Font_UnicodeSubset theSubset,
Font_FontAspect theFontAspect ) const

Tries to find fallback font for specified Unicode subset. Returns NULL in case when fallback font is not found in the system.

Parameters
[in]theSubsetUnicode subset
[in]theFontAspectfont aspect to find

◆ FindFont() [1/2]

occ::handle< Font_SystemFont > Font_FontMgr::FindFont ( const TCollection_AsciiString & theFontName,
Font_FontAspect & theFontAspect ) const
inline

Tries to find font by given parameters.

◆ FindFont() [2/2]

occ::handle< Font_SystemFont > Font_FontMgr::FindFont ( const TCollection_AsciiString & theFontName,
Font_StrictLevel theStrictLevel,
Font_FontAspect & theFontAspect,
bool theDoFailMsg = true ) const

Tries to find font by given parameters. If the specified font is not found tries to use font names mapping. If the requested family name not found -> search for any font family with given aspect and height. If the font is still not found, returns any font available in the system. Returns NULL in case when the fonts are not found in the system.

Parameters
[in]theFontNamefont family to find or alias name
[in]theStrictLevelsearch strict level for using aliases and fallback
[in]

out] theFontAspect font aspect to find (considered only if family name is not found); can be modified if specified font alias refers to another style (compatibility with obsolete aliases)

Parameters
[in]theDoFailMsgput error message on failure into default messenger

◆ FontAspectToString()

static const char * Font_FontMgr::FontAspectToString ( Font_FontAspect theAspect)
inlinestatic

Return font aspect as string.

◆ GetAllAliases()

void Font_FontMgr::GetAllAliases ( NCollection_Sequence< occ::handle< TCollection_HAsciiString > > & theAliases) const

Return font names with defined aliases.

Parameters
[out]theAliasesalias names

◆ GetAvailableFonts()

NCollection_List< occ::handle< Font_SystemFont > > Font_FontMgr::GetAvailableFonts ( ) const
inline

Return the list of available fonts.

◆ GetAvailableFontsNames()

void Font_FontMgr::GetAvailableFontsNames ( NCollection_Sequence< occ::handle< TCollection_HAsciiString > > & theFontsNames) const

Returns sequence of available fonts names.

◆ GetFont() [1/2]

occ::handle< Font_SystemFont > Font_FontMgr::GetFont ( const occ::handle< TCollection_HAsciiString > & theFontName,
const Font_FontAspect theFontAspect,
const int theFontSize ) const

Returns font that match given parameters. If theFontName is empty string returned font can have any FontName. If theFontAspect is Font_FA_Undefined returned font can have any FontAspect. If theFontSize is "-1" returned font can have any FontSize.

◆ GetFont() [2/2]

occ::handle< Font_SystemFont > Font_FontMgr::GetFont ( const TCollection_AsciiString & theFontName) const

Returns font that match given name or NULL if such font family is NOT registered. Note that unlike FindFont(), this method ignores font aliases and does not look for fall-back.

◆ GetFontAliases()

void Font_FontMgr::GetFontAliases ( NCollection_Sequence< occ::handle< TCollection_HAsciiString > > & theFontNames,
const TCollection_AsciiString & theAliasName ) const

Return aliases to specified font name.

Parameters
[out]theFontNamesfont names associated with alias name
[in]theAliasNamealias name

◆ GetInstance()

static occ::handle< Font_FontMgr > Font_FontMgr::GetInstance ( )
static

Return global instance of font manager.

◆ InitFontDataBase()

void Font_FontMgr::InitFontDataBase ( )

Collects available fonts paths.

◆ RegisterFont()

bool Font_FontMgr::RegisterFont ( const occ::handle< Font_SystemFont > & theFont,
const bool theToOverride )

Register new font. If there is existing entity with the same name and properties but different path then font will be overridden or ignored depending on theToOverride flag.

◆ RegisterFonts()

bool Font_FontMgr::RegisterFonts ( const NCollection_Sequence< occ::handle< Font_SystemFont > > & theFonts,
const bool theToOverride )
inline

Register new fonts.

◆ RemoveFontAlias()

bool Font_FontMgr::RemoveFontAlias ( const TCollection_AsciiString & theAliasName,
const TCollection_AsciiString & theFontName )

Unregister font alias.

Parameters
[in]theAliasNamealias name or name of another font to be used as alias; all aliases will be removed in case of empty name
[in]theFontNamefont to be used as substitution for alias; all fonts will be removed in case of empty name
Returns
TRUE if alias has been removed

◆ SetPrintErrors()

void Font_FontMgr::SetPrintErrors ( bool theToPrintErrors)
inline

Set flag for printing error messages. Can be disabled to avoid error messages with Message_Fail level.

◆ SetTraceAliases()

void Font_FontMgr::SetTraceAliases ( bool theToTrace)
inline

Set flag for tracing font alias usage; useful to trace which fonts are actually used. Can be disabled to avoid redundant messages with Message_Trace level.

◆ ToPrintErrors()

bool Font_FontMgr::ToPrintErrors ( ) const
inline

Return flag for printing error messages via Message_Fail messages; TRUE by default.

◆ ToTraceAliases()

bool Font_FontMgr::ToTraceAliases ( ) const
inline

Return flag for tracing font aliases usage via Message_Trace messages; TRUE by default.

◆ ToUseUnicodeSubsetFallback()

static bool & Font_FontMgr::ToUseUnicodeSubsetFallback ( )
static

Return flag to use fallback fonts in case if used font does not include symbols from specific Unicode subset; TRUE by default.


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