mapbox-to-css-font
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

Mapbox/MapLibre to CSS Font

Utility to convert Mapbox/MapLibre GL Style fontstacks or fonts names to CSS compatible font definitions.

For fontstacks, the style and weight of the primary font (first font in the fontstack) will also be used for the fallback fonts.

Fonts commonly found in Mapbox/MapLibre styles, which are not available as systm fonts or free fonts on Fontsource or Google Fonts, will be replaced with a close match:

Mapbox/MapLibre Font Name Replacement Font Name
Arial Unicode MS Arial
DIN Pro Barlow
Klokantech Noto Sans Noto Sans

Usage

import parseFont from 'mapbox-to-css-font';

parseFont('Open Sans Regular', 16, 1.2);
// returns 'normal 400 16px/1.2 "Open Sans"'

API

Parameters

  • fonts string|Array<string> Mapbox GL Style fontstack or single font, e.g. ['Open Sans Regular', 'Arial Unicode MS Regular'] or 'Open Sans Regular'.

  • size number Font size in pixels.

  • lineHeight string|number Line height as css line-height. Optional.

Returns string CSS font definition, e.g. 'normal 400 16px/1.2 "Open Sans"'.

Readme

Keywords

Package Sidebar

Install

npm i mapbox-to-css-font

Weekly Downloads

243,987

Version

3.2.0

License

BSD-2-Clause

Unpacked Size

7.93 kB

Total Files

6

Last publish

Collaborators

  • ahocevar