Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FontSettings<TProps>

Style class for describing a font.

Instances of FontSettings, like all LCJS style classes, are immutable, meaning that its setters don't modify the actual object, but instead return a completely new modified object.

Properties of FontSettings:

FontSettings usage:

Use FontSettings with:

 // Example 1, set chart title font with explicit font.
 ChartXY.setTitleFont(new FontSettings({
     size: 20,
     family: 'Arial, Helvetica, sans-serif',
     weight: 'bold',
     style: 'italic'
 }))

 // Example 2, override chart title font, specifying only a sub-set of properties.
 ChartXY.setTitleFont((font) => font
     .setSize(20)
 )

Index

Constructors

constructor

  • Construct a FontSettings object, specifying any amount of its properties.

     // Example,
     const font = new FontSettings({
         size: 20,
         family: 'Arial, Helvetica, sans-serif',
         weight: 'bold',
         style: 'italic',
     })

    Parameters

    • props: Partial<FontProperties>

      Object containing any amount of SolidFill properties.

    Returns FontSettings

Methods

getFamily

  • getFamily(): string
  • Get font family.

    CSS font family, or list of font families.

    For example, 'Arial, Helvetica, sans-serif'.

    Returns string

    Font family.

getSize

  • getSize(): number
  • Get font size.

    CSS font size.

    For example, 16.

    Returns number

    Font size.

getStyle

getVariant

  • getVariant(): boolean
  • Get font variant.

    CSS font variant.

    true = 'small-caps', false = 'normal'.

    Returns boolean

    Font variant.

getWeight

setFamily

  • setFamily(family: string): this
  • Create new FontSettings object with different family.

    CSS font family, or list of font families.

    For example, 'Arial, Helvetica, sans-serif'.

    Parameters

    • family: string

      Font family or list of families.

    Returns this

    New FontSettings object.

setSize

  • setSize(size: number): this
  • Create new FontSettings object with different size.

    CSS font size.

    For example, 16.

    Parameters

    • size: number

      Font size.

    Returns this

    New FontSettings object.

setStyle

  • Create new FontSettings object with different style.

    CSS font style.

    For example, 'italic'

    Parameters

    Returns this

    New FontSettings object.

setVariant

  • setVariant(smallCaps: boolean): this
  • Create new FontSettings object with different variant.

    CSS font variant.

    true = 'small-caps', false = 'normal'

    Parameters

    • smallCaps: boolean

    Returns this

    New FontSettings object.

setWeight

  • Create new FontSettings object with different weight.

    CSS font weight.

    For example, 'bold'.

    Parameters

    Returns this

    New FontSettings object.

Static Factory

  • Factory(values?: Partial<TProps> | Iterable<[string, any]>): Record<TProps> & Readonly<TProps>
  • Type parameters

    • TProps: Object

    Parameters

    • values: Partial<TProps> | Iterable<[string, any]>

    Returns Record<TProps> & Readonly<TProps>

Static Record

  • Record(defaultValues: TProps, name?: undefined | string): Factory<TProps>
  • Unlike other types in Immutable.js, the Record() function creates a new Record Factory, which is a function that creates Record instances.

    See above for examples of using Record().

    Note: Record is a factory function and not a class, and does not use the new keyword during construction.

    Type parameters

    • TProps

    Parameters

    • defaultValues: TProps
    • name: undefined | string

    Returns Factory<TProps>

Static getDescriptiveName

  • getDescriptiveName(record: Record<any>): string
  • Records allow passing a second parameter to supply a descriptive name that appears when converting a Record to a string or in any error messages. A descriptive name for any record can be accessed by using this method. If one was not provided, the string "Record" is returned.

    const { Record } = require('immutable')
    const Person = Record({
      name: null
    }, 'Person')
    
    var me = Person({ name: 'My Name' })
    me.toString() // "Person { "name": "My Name" }"
    Record.getDescriptiveName(me) // "Person"

    Parameters

    Returns string

Static isRecord

  • isRecord(maybeRecord: any): maybeRecord
  • True if maybeRecord is an instance of a Record.

    Parameters

    • maybeRecord: any

    Returns maybeRecord