2.0.0 • Published 6 years ago

font-atlas-sdf v2.0.0

Weekly downloads
11,865
License
MIT
Repository
github
Last release
6 years ago

font-atlas-sdf unstable

Populate a <canvas> element with a font texture atlas – can be used to quickly generate SDF (Signed Distance Field) fonts. SDF is the most efficient way to draw text in WebGL, see article. For bitmap fonts see font-atlas.

Demo

Usage

npm install font-atlas-sdf

canvas = fontAtlas(options?)

Populates and returns a <canvas> element with a font texture atlas. Takes the following options:

PropertyDefaultMeaning
canvasNew canvasuse an existing <canvas> element.
font16px sans-serifthe font family to use when drawing the text. Can be a css font string or an object with font properties: size, family, style, weight, variant, stretch.
shape[512, 512]an array containing the [width, height] for the canvas in pixels.
step[32, 32]an array containing the [width, height] for each cell in pixels.
chars[32, 126]may be one of either: a string containing all of the characters to use; an array of all the characters to use; an array specifying the [start, end] character codes to use.
radiussize × 1.5affects the "slope" of distance-transform.
align'optical'align symbol vertically by bounding box rather than font baseline. Available values: 'optical' for center of mass alignment (see optical-properties), 'bounds' for bounding box alignment or false to use font alignment.
fit0.5normalize glyph sizes to cover same part of size. Can be a number or bool, eg. 0.5 covers half of size, 1 fits to the full size and false disables fit.

Related