Skip to content

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

Examples:

>>> font_names = FontProvider.Instance().GetSystemFonts()
or
>>> font_ids = FontProvider.Instance().GetPredefinedFontIDs()

Functions

FontMMToPoints(mmValue) staticmethod

Converts mm to points

Parameters:

Name Type Description Default
mmValue float

Value to convert in milimeters

required

Returns:

Type Description
float

value in points

FontMMToTwips(mmValue) staticmethod

Converts mm to twips.

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!!!

Parameters:

Name Type Description Default
mmValue float

Value to convert in milimeters

required

Returns:

Type Description
float

Value in twips

FontPointsToMM(pointsValue) staticmethod

Converts points to mm

Parameters:

Name Type Description Default
pointsValue float

Value in points

required

Returns:

Type Description
float

Value in mm

FontTwipsToMM(twipsValue) staticmethod

Converts twips to mm

Parameters:

Name Type Description Default
twipsValue float

Value in twips

required

Returns:

Type Description
float

Value in mm

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

True if at least one Charset for the given font ID exists

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

True if at least one Charset for the given font name exists

List[int]

Charset list

GetFirstValidPredefinedFontID()

Get ID of the first existing predefined TTF font

Returns:

Type Description
int

font ID

GetFontID(fontName, bCheckExistence=1)

Get font ID for the given font name. ID is the index to the table m_PreDefinedFontNameList.

  • 0: Dialog Font ID
  • 1-20: ID of the hardcoded Allplan's fonts ( see table m_PreDefinedFontNameList )
  • 21-63: ID of the hardcoded system's fonts ( see table m_PreDefinedFontNameList )
  • =SYSTEM_FONT_ID (1000): ID of the system TTF font ( this ID is valid only during Allplan's session )

  • =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 )

  • 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. In case, that this font is not installed, the function returns the empty string. When bCheckExistence is FALSE then the function returns the name of the font regardless of it is installed or not.

1

Returns:

Type Description
int

font ID

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. In case, that this font is not installed, the function returns the empty string. When bCheckExistence is FALSE then the function returns the name of the font regardless of it is installed or not.

1

Returns:

Type Description
str

Font name. If fontID is invalid then the empty string is returned.

GetNemFontIDs()

Get the list of the IDs of all Allplan's fonts

Returns:

Type Description
bool

TRUE when at least one font is installed

List[int]

List with font IDs

GetNemFonts()

Get the list of the names of all Allplan's fonts

Returns:

Type Description
bool

TRUE when at least one font is installed

List[str]

List with the font names

GetPredefinedFontIDs()

Get the list of IDs of all installed and predefined TTF fonts

Returns:

Type Description
bool

TRUE when at least one font is installed

List[int]

List with the font IDs

GetPredefinedFonts()

Get the list of names of all installed and predefined TTF fonts

Returns:

Type Description
bool

TRUE when at least one font is installed

List[str]

List with the font names

GetSystemFontIDs()

Get the list of the IDs of all installed TTF fonts

Returns:

Type Description
bool

TRUE when at least one font is installed

List[int]

List with the font IDs

GetSystemFonts()

Returns the list of the names of all installed TTF fonts

Returns:

Type Description
bool

TRUE when at least one font is installed

List[str]

List with the font names

GetTTFFontSubtype(fontName)

Returns type of checked TTF font

Parameters:

Name Type Description Default
fontName str

name of the TTF font

required

Returns:

Type Description
int

type od TTF font

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

Parameters:

Name Type Description Default
fontName str

font name

required
CharSet int

Charset

1

Returns:

Type Description
str

Font name without suffix

Examples:

>>> NormalizeFontName("Arial CE")
Arial

Refresh()

Reinitialize the fonts It'd be called when some system's font was changed ( added/removed )