Font Provider
Class full path: NemAll_Python_AllplanSettings.FontProvider
Provides the methods to obtain the list of the fonts
CFontProvider is singleton so that there always exists only one instance of this class
Usage: erbatim font_names = FontProvider.Instance().GetSystemFonts() \endverbatim or erbatim font_ids = FontProvider.Instance().GetPredefinedFontIDs() \endverbatim
Functions
FontMMToPoints(mmValue)
staticmethod
Converts mm to points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mmValue
|
float
|
|
required |
FontMMToTwips(mmValue)
staticmethod
Font size conversions.
It is a font special factor (0.714) being applied in order to associate the mm unit with the real glyph size (like for vector fonts) without sub and superscripts space. So these function do not provide common standard point/twips/millimeter conversions!!! Converts mm to twips
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mmValue
|
float
|
|
required |
FontPointsToMM(twipsValue)
staticmethod
Converts points to mm
Parameters:
Name | Type | Description | Default |
---|---|---|---|
twipsValue
|
float
|
|
required |
FontTwipsToMM(twipsValue)
staticmethod
Converts twips to mm
Parameters:
Name | Type | Description | Default |
---|---|---|---|
twipsValue
|
float
|
|
required |
GetCharsetList
overload
GetCharsetList(nFontID)
Returns the list of available charsets for the given font
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nFontID
|
int
|
Font ID |
required |
Returns:
Type | Description |
---|---|
bool
|
tuple(Charsets for the given font, |
list[int]
|
Charset list) |
GetCharsetList(fontName)
Returns the list of available charsets for the given font
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fontName
|
str
|
Font name |
required |
Returns:
Type | Description |
---|---|
bool
|
tuple(Charsets for the given font, |
list[int]
|
Charsets list) |
GetFirstValidPredefinedFontID()
Returns ID of the first existing predefined TTF font
GetFontID(fontName, bCheckExistence=1)
Return ID for the given font
Return the ID for the given font name. ID is the index to the table m_PreDefinedFontNameList.
etval 0 Dialog Font ID
etval 1-20 ID of the hardcoded Allplan's fonts ( see table m_PreDefinedFontNameList )
etval 21-63 ID of the hardcoded system's fonts ( see table m_PreDefinedFontNameList )
etval >=SYSTEM_FONT_ID (1000) ID of the system TTF font ( this ID is valid only during Allplan's session )
etval >=NON_EXISTING_FONT_ID(10000) ID of the font that isn't installed nor exists in the predefined table( this ID is valid only during Allplan's session )
etval INVALID_FONT_ID(N_FONT_INTERNAL_MIN_ID - 1) Invalid ID, font with given name doesn't exist
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fontName
|
str
|
Name of the font |
required |
bCheckExistence
|
int
|
When bCheckExistence is TRUE then the font with the particular ID has to be installed.
|
1
|
Returns:
Name | Type | Description |
---|---|---|
Return |
int
|
|
GetFontName(fontID, bCheckExistence=1)
Returns the name of the font
Returns FontName corresponding to fontID If fontID is invalid then the empty string is returned
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fontID
|
int
|
ID of the font |
required |
bCheckExistence
|
int
|
When bCheckExistence is TRUE then the font with the particular ID has to be installed.
|
1
|
Returns:
Type | Description |
---|---|
str
|
Returns FontName. If fontID is invalid then the empty string is returned. |
GetNemFontIDs()
Returns the list of the IDs of all Allplan's fonts
GetNemFonts()
Returns the list of the names of all Allplan's fonts
GetPredefinedFontIDs()
Returns the list of then IDs of all installed and predefined TTF fonts
GetPredefinedFonts()
Returns the list of then names of all installed and predefined TTF fonts
GetSystemFontIDs()
Returns the list of the IDs of all installed TTF fonts
GetSystemFonts()
Returns the list of the names of all installed TTF fonts
Returns:
Type | Description |
---|---|
tuple[bool, list[str]]
|
The function returns TRUE when at least one font is installed |
GetTTFFontSubtype(fontName)
Returns type of checked TTF font
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fontName
|
str
|
|
required |
Instance()
staticmethod
Get the instance of the font provider
Returns:
Type | Description |
---|---|
FontProvider
|
Instance of the font provider |
NormalizeFontName(fontName, CharSet=1)
Removes from the fontname script suffix e.g. Arial CE -> Arial
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fontName
|
str
|
|
required |
CharSet
|
int
|
|
1
|
Refresh()
Reinitialize the fonts It'd be called when some system's font was changed ( added/removed )