Font module

class Font.Font

Bases: SpireObject

Represents a font for text display in Excel.

This class encapsulates the properties and behavior of a font used in Excel documents, including attributes like name, size, style, and other formatting characteristics. It provides methods to manipulate font appearance and convert between different font representations.

property Bold: bool

Gets a value indicating whether this font has the bold style applied.

Returns:

True if this font is bold; otherwise, False.

Return type:

bool

Clone() SpireObject

Creates an exact copy of this Font object.

Returns:

A new Font object that is an exact copy of this Font.

Return type:

SpireObject

Equals(obj: SpireObject) bool

Determines whether the specified object is equal to this Font object.

Parameters:

obj (SpireObject) – The object to compare with the current Font.

Returns:

True if the specified object is equal to the current Font; otherwise, False.

Return type:

bool

FromLogFont

A function that is part of a class.

This wrapper provides a mechanism that allows the function to be constructed with a reference to the class that it owns. The construction is deferred until __set_name__ is called.

Parameters:
  • class_name (str) – Name of the class that owns the function.

  • construct_function (function) – Constructor for the function: takes in a reference to the class that owns the function and gives back the function.

property GdiCharSet: int

Gets the GDI character set of this font.

Returns:

An integer value representing the GDI character set.

Return type:

int

property GdiVerticalFont: bool

Gets a value indicating whether this font is a GDI vertical font.

Returns:

True if this is a GDI vertical font; otherwise, False.

Return type:

bool

GetHashCode() int

Returns a hash code for this Font object.

Returns:

An integer value that represents the hash code for this Font.

Return type:

int

GetHeight

Gets the height of this font.

Returns:

The height of this font.

Return type:

float

property IsSystemFont: bool

Gets a value indicating whether this font is a system font.

Returns:

True if this font is a system font; otherwise, False.

Return type:

bool

property Italic: bool

Gets a value indicating whether this font has the italic style applied.

Returns:

True if this font is italic; otherwise, False.

Return type:

bool

property Name: str

Gets the face name of this font.

Returns:

A string that represents the face name of this font.

Return type:

str

property Size: float

Gets the em-size of this font measured in the current unit.

Returns:

The em-size of this font.

Return type:

float

property SizeInPoints: float

Gets the em-size of this font measured in points.

Returns:

The em-size of this font, in points.

Return type:

float

property Strikeout: bool

Gets a value indicating whether this font has the strikeout style applied.

Returns:

True if this font has the strikeout style applied; otherwise, False.

Return type:

bool

property Style: FontStyle

Gets the style information for this font.

Returns:

A FontStyle enumeration value representing the style of this font.

Return type:

FontStyle

property SystemFontName: str

Gets the name of the system font that this font is based on.

Returns:

The name of the system font if this font is a system font; otherwise, an empty string.

Return type:

str

ToLogFont

Fills a LOGFONT structure with the font’s data.

Parameters:

logFont (SpireObject) – The LOGFONT structure to fill with this font’s data.

ToString() str

Returns a string representation of this Font object.

Returns:

A string that represents this Font object.

Return type:

str

property Underline: bool

Gets a value indicating whether this font has the underline style applied.

Returns:

True if this font is underlined; otherwise, False.

Return type:

bool