Skip to content

Generate a css string with font-face declaration from JS data

Notifications You must be signed in to change notification settings

joakin/css-face-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

css-face-string

Generate a css string with font-face declaration from JS data.

Useful for generating font faces programatically. Works in node.js and the browser.

Useful with browserify and insert-css

Use

var cfs = require('css-face-string')

cfs.file({
  name: 'Inconsolata',
  files: [{ url: './inconsolata.ttf', format: 'truetype' }
        ,{ url: './inconsolata.woff', format: 'woff' }]
})
//> @font-face {font-family: "Inconsolata";src: url("./inconsolata.ttf") format("truetype"), url("./inconsolata.woff") format("woff");

cfs.url("http://fonts.googleapis.com/css?family=Averia+Sans+Libre:400,300italic,700")
//> @import url(http://fonts.googleapis.com/css?family=Averia+Sans+Libre:400,300italic,700);

// No sugar:
cfs(cfs.types.FILE, {
  name: 'Inconsolata',
  files: [{ url: './inconsolata.ttf', format: 'truetype' }]
})

cfs(cfs.types.URL,
    "http://fonts.googleapis.com/css?family=Averia+Sans+Libre:400,300italic,700")
npm install --save css-face-string

About

Generate a css string with font-face declaration from JS data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published