mapbox-to-css-font

    2.4.2 • Public • Published

    Mapbox to CSS Font

    Utility to convert Mapbox 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.

    The "Klokantech Noto Sans" font is recognized and returned as "Noto Sans", so it can be loaded as web font from Google fonts.

    Usage

    var parseFont = require('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"'.

    Keywords

    Install

    npm i mapbox-to-css-font

    DownloadsWeekly Downloads

    144,400

    Version

    2.4.2

    License

    BSD-2-Clause

    Unpacked Size

    6.11 kB

    Total Files

    4

    Last publish

    Collaborators

    • ahocevar