Skip to content

FontFace

Image processingclassOpenCV 5.0.0
import { FontFace } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSFontFace
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods.

Wrapper on top of a truetype/opentype/etc font, i.e. Freetype's FT_Face.

The class is used to store the loaded fonts; the font can then be passed to the functions putText and getTextSize.

Constructors and members

static new

loads font at the specified path or with specified name.

new(fontPathOrName: EmbindString): FontFace;
2 available overloads
new(): FontFace;
new(fontPathOrName: EmbindString): FontFace;
fontPathOrName

either path to the custom font or the name of embedded font: "sans", "italic" or "uni". Empty fontPathOrName means the default embedded font.

Returns

The FontFace result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

set

loads new font face

set(fontPathOrName: EmbindString): boolean;
fontPathOrName

font path or name argument (EmbindString).

Returns

The boolean result.

getName

Return the name configured on this FontFace object.

getName(): string;
Returns

The string result.

setInstance

sets the current variable font instance.

setInstance(params: IntVector): boolean;
params

The list of pairs key1, value1, key2, value2, ..., e.g. myfont.setInstance({CV_FOURCC('w','g','h','t'), 400<<16, CV_FOURCC('s','l','n','t'), -(15<<16)}); Note that the parameter values are specified in 16.16 fixed-point format, that is, integer values need to be shifted by 16 (or multiplied by 65536).

Returns

The boolean result.

getInstance

Read the instance.

sets the current variable font instance.

getInstance(params: IntVector): boolean;
params

Output destination, filled by the native operation. params argument (IntVector).

Returns

The boolean result.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.