FontWrapper module

class FontWrapper.FontWrapper

Bases: CommonWrapper, IInternalFont

Represents a wrapper for font operations in Excel.

This class provides methods and properties for manipulating font attributes in Excel worksheets, including font style, color, size, and other formatting characteristics. It implements the IInternalFont interface and extends the CommonWrapper class to provide font-specific functionality.

BeginUpdate()

Begins a batch update operation on the font properties.

This method should be called before making multiple changes to font properties to improve performance by deferring the actual updates until EndUpdate is called.

Clone(book: XlsWorkbook, parent: SpireObject, dicFontIndexes: IDictionary) FontWrapper

Creates a clone of this FontWrapper object.

Parameters:
  • book (XlsWorkbook) – The workbook for the cloned font.

  • parent (SpireObject) – The parent object for the cloned font.

  • dicFontIndexes (IDictionary) – A dictionary mapping font indexes.

Returns:

A new FontWrapper object that is a copy of this instance.

Return type:

FontWrapper

property Color: Color

Gets or sets the primary color of the font.

Returns:

A Color object representing the font color.

Return type:

Color

ColorObjectUpdate()

Updates the color object associated with this font.

This method refreshes the color properties of the font after changes.

EndUpdate()

Ends a batch update operation and applies all pending changes to font properties.

This method should be called after BeginUpdate to apply all the changes made to font properties in a single operation, improving performance.

property Font: XlsFont

Gets the internal XlsFont object.

Returns:

The internal font object.

Return type:

XlsFont

property FontIndex: int

Gets the index of the font in the fonts collection.

Returns:

The index of the font.

Return type:

int

property FontName: str

Gets or sets the name of the font.

Returns:

The name of the font.

Return type:

str

GenerateNativeFont() Font

Generates a native Font object from this FontWrapper.

Returns:

A Font object representing the font settings in this wrapper.

Return type:

Font

property Index: int

Gets the index of the font in the collection.

Returns:

The index of the font.

Return type:

int

property IsAutoColor: bool

Gets a value indicating whether the font color is set to automatic.

Returns:

True if the font color is automatic; otherwise, False.

Return type:

bool

property IsBold: bool

Gets or sets a value indicating whether the font is bold.

Returns:

True if the font is bold; otherwise, False.

Return type:

bool

property IsItalic: bool

Gets or sets a value indicating whether the font style is italic.

Returns:

True if the font is italic; otherwise, False.

Return type:

bool

property IsReadOnly: bool

Gets or sets a value indicating whether the font is read-only.

Returns:

True if the font is read-only; otherwise, False.

Return type:

bool

property IsStrikethrough: bool

Gets or sets a value indicating whether the font is struck through with a horizontal line.

Returns:

True if the font has a strikethrough; otherwise, False.

Return type:

bool

property IsSubscript: bool

Gets or sets a value indicating whether the font is formatted as subscript.

Returns:

True if the font is subscript; otherwise, False.

Return type:

bool

property IsSuperscript: bool

Gets or sets a value indicating whether the font is formatted as superscript.

Returns:

True if the font is superscript; otherwise, False.

Return type:

bool

property KnownColor: ExcelColors

Gets or sets the predefined Excel color of the font.

Returns:

An enumeration value representing the Excel color.

Return type:

ExcelColors

property MacOSOutlineFont: bool

Gets or sets a value indicating whether the font is an outline font.

Returns:

True if the font is an outline font; otherwise, False.

Return type:

bool

property MacOSShadow: bool

Gets or sets a value indicating whether the font is a shadow font or if the object has a shadow.

Returns:

True if the font is a shadow font or the object has a shadow; otherwise, False.

Return type:

bool

property Parent: SpireObject

Gets the parent object of this FontWrapper.

Returns:

The parent object that contains this font wrapper.

Return type:

SpireObject

SetThemeColor(type: ThemeColorType, tint: float)

Sets a theme color for the font.

Parameters:
  • type (ThemeColorType) – The type of theme color to set.

  • tint (float) – The tint value to apply to the theme color.

property Size: float

Gets or sets the size of the font in points.

Returns:

The font size in points.

Return type:

float

property StrikethroughType: str

Gets the type of strikethrough applied to the font.

Returns:

A string representing the type of strikethrough.

Return type:

str

property Underline: FontUnderlineType

Gets or sets the type of underline applied to the font.

Returns:

An enumeration value representing the underline type.

Return type:

FontUnderlineType

property VerticalAlignment: FontVertialAlignmentType

Gets the vertical alignment of the font.

Returns:

An enumeration value representing the vertical alignment.

Return type:

FontVertialAlignmentType

property Workbook: XlsWorkbook

Gets the workbook that contains this font.

Returns:

The parent workbook object.

Return type:

XlsWorkbook