jrnewell / goog-webfont-dl

A utility to download google webfonts to your local machine
MIT License
75 stars 17 forks source link

Paths in css are broken if prefix contains url #15

Open linux019 opened 6 years ago

linux019 commented 6 years ago
const fontDownloader = require('goog-webfont-dl');

fontDownloader({
    font: 'Roboto',
    formats:     ["woff", "woff2"],//fontDownloader.formats, // Font formats.
    destination: path.join(__dirname, 'public/fonts/roboto'),               // Save font here
    out:         path.join(__dirname, 'resources/assets/fonts/roboto.css'), // CSS file. Use '-' for stdout, and nothing to return the CSS code
    prefix:      `http://test.localhost/fonts/roboto`, // Prefix to use in CSS output
    subset:      null, // = none     // Subset string/array, e.g. 'latin,cyrillic'
    styles:      '400,400i,700,700i',  // Style string/array, e.g. '300,400,300italic,400italic'
})

Output:

@font-face {
  font-family: 'Roboto';
  font-style: italic;
  font-weight: 400;
  src: local('Roboto Italic'), local('Roboto-Italic'), url(http:/test.localhost/fonts/roboto/Roboto-Italic.woff2) format('woff2'), url(http:/test.localhost/fonts/roboto/Roboto-Italic.woff) format('woff');
}