Interface IFont

interface IFont {
    extend: boolean;
    family: string;
    familyFallbacks: string[];
    fill: AdjustedColor;
    isIFont: true;
    letterSpacing: number;
    outline: boolean;
    scheme: FontScheme;
    shadow: boolean;
    size: number;
    strike: boolean;
    style: FontStyle;
    underline: UnderlineStyle;
    verticalAlign: VerticalTextAlignment;
    weight: number;
    isEqualMeasure(other): boolean;
    toJSON(): Partial<{
        extend: string | Partial<boolean>;
        family: string;
        familyFallbacks: string | string[];
        fill: string | AdjustedColor | Partial<{
            val: string;
            adjustments: any;
            asCSS: any;
            isEqual: any;
            isImmutable: any;
            toHSLA: any;
            toHex: any;
            toJSON: any;
            toRGBA: any;
            toString: any;
        }>;
        letterSpacing: string | number;
        outline: string | Partial<boolean>;
        scheme: string;
        shadow: string | Partial<boolean>;
        size: string | number;
        strike: string | Partial<boolean>;
        style: string;
        underline: string | boolean;
        verticalAlign: string;
        weight: string | number;
    }>;
}

Hierarchy

Properties

extend: boolean

The effect extends or stretches out the text.

Remarks

Not rendered by Excel or SheetXL.

family: string

This can be set as a string using html values such as 'Arial 11pt' but will be resolved to a single font. Fallbacks and fontSize will be marshalled into their correct property.

familyFallbacks: string[]

A list of fonts and their fallbacks. These can also be provided in the fontFamily attribute but will be normalized to here.

The text color.

Remarks

Currently only solid fill is supported but this will be expanded to allow all fill types similar to DrawML. TODO - allow this to be any fill style like DrawML

isIFont: true
letterSpacing: number

Adds or removes additional spacing between the characters.

outline: boolean

The effect draws the text as an outline.

Remarks

Not rendered by Excel or SheetXL.

scheme: FontScheme

Defines the font scheme to use.

Default

FontScheme.Minor
shadow: boolean

The effect draws a shadow around the text.

Remarks

Not rendered by Excel or SheetXL.

size: number

Font size is either a number in points or a string that can be converted such as '14px', '1.5em'.

strike: boolean

The effect draws the text with a line through it.

style: FontStyle

Default Value

normal
underline: UnderlineStyle
verticalAlign: VerticalTextAlignment

Remarks

If the VerticalTextAlign is superscript or subscript then the font size should also render smaller.

weight: number

The weight of the characters.

Remarks

700 or above is considered bold.

Methods

  • Compare against another font to see if they will have the same font measure This is used to optimize updates by not re-calcing the width/height

    Parameters

    Returns boolean

  • Returns Partial<{
        extend: string | Partial<boolean>;
        family: string;
        familyFallbacks: string | string[];
        fill: string | AdjustedColor | Partial<{
            val: string;
            adjustments: any;
            asCSS: any;
            isEqual: any;
            isImmutable: any;
            toHSLA: any;
            toHex: any;
            toJSON: any;
            toRGBA: any;
            toString: any;
        }>;
        letterSpacing: string | number;
        outline: string | Partial<boolean>;
        scheme: string;
        shadow: string | Partial<boolean>;
        size: string | number;
        strike: string | Partial<boolean>;
        style: string;
        underline: string | boolean;
        verticalAlign: string;
        weight: string | number;
    }>