JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 214237
  • Score
    100M100P100Q175777F
  • License BSD-2-Clause

Utility to convert Mapbox GL Style font names to CSS font definitions

Package Exports

  • mapbox-to-css-font
  • mapbox-to-css-font/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mapbox-to-css-font) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 free fonts on Fontsource or Google Fonts, will be replaced with a close match:

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

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"'.