mapbox-to-css-font is a focused JavaScript/TypeScript utility designed to convert Mapbox GL Style font definitions, whether single font names or complex fontstacks, into a CSS-compatible `font` shorthand string. The package is currently at version 3.2.0 and is actively maintained, with recent minor releases addressing bug fixes and dependency updates. Its primary function involves parsing Mapbox-specific font declarations and generating a standard CSS font property string, handling details like font size and line height. A key differentiating feature is its intelligent font replacement mechanism, which substitutes common Mapbox/MapLibre fonts (e.g., "Arial Unicode MS", "DIN Pro") with widely available system fonts or open-source alternatives like Arial or Barlow, ensuring visual consistency when the original fonts are not present. It also correctly extracts style and weight from the primary font within a fontstack and applies it consistently.
npm install mapbox-to-css-fontVerified import paths — ran on the pinned version, not inferred.
Demonstrates converting single Mapbox font names and fontstacks into CSS `font` properties, including how the utility handles font replacement and style extraction.
Update your project to use ES module `import` syntax. If you are using Node.js, ensure your package.json has `"type": "module"` or use `.mjs` file extensions.
Review any code that explicitly checks for 'normal' font weight; consider adjusting expectations to '400' or handling both if backward compatibility is needed.
Upgrade to version 3.0.3 or later to ensure correct module resolution.
Change `const parseFont = require('mapbox-to-css-font');` to `import parseFont from 'mapbox-to-css-font';`. Ensure your project is configured for ES modules (e.g., `"type": "module"` in package.json for Node.js).Use a default import: `import parseFont from 'mapbox-to-css-font';` instead of `import { parseFont } from 'mapbox-to-css-font';`.No dependency data recorded yet.