Canvas Toolkit
← Class index

CFont

GUI and styling

Describes a font independently of a paint device. The object can be converted to the CSS font shorthand accepted by CanvasRenderingContext2D.font.

import { CFont } from "canvas-toolkit-lib";

Declared members

constructor();
constructor(other: CFont);
constructor(family: string, pixelSize?: number, weight?: number, italic?: boolean);
family(): string;
setFamily(family: string): void;
pixelSize(): number;
setPixelSize(pixelSize: number): void;
weight(): number;
setWeight(weight: number): void;
isBold(): boolean;
setBold(bold: boolean): void;
style(): CFontStyle;
setStyle(style: CFontStyle): void;
isItalic(): boolean;
setItalic(italic: boolean): void;
stretch(): CFontStretch;
setStretch(stretch: CFontStretch): void;
capitalization(): CFontCapitalization;
setCapitalization(capitalization: CFontCapitalization): void;
isEqual(other: CFont): boolean;
toCss(): string;

Returns a CSS font shorthand suitable for a canvas 2D context.

static fromCss(css: string): CFont;

Creates a font from the common CSS shorthand returned by a canvas.