cyrilchapon / font-stack

Font-stacks database & utils

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

font-stack

build status code style libraries status

Install

yarn add font-stack

// or

npm install --save font-stack

Usage

import { composeStack, FONT_STACKS } from 'font-stack'

const fontStack = composeStack([
  'Source Sans Pro',
  ...FONT_STACKS['Arial']
])

console.log(fontStack)

// 'Source Sans Pro', Arial, 'Helvetica Neue', Helvetica, sans-serif

API

composeStack(families)

Escapes and assemble a font-stack represented in an Array.

  • returns [string]: output escaped font stack string
  • families [array]: input font-stack families array

(see escape rules)

FONT_STACKS

Common font stacks databases

  • [key] [array]: font-stack families array

(see src/font-stack-database.js)

_escapeFamily(family)

Escapes a single family

  • returns [string]: output escaped family string
  • family [string]: input family string

_isUnsafe(family)

Tests if a single family should be escaped

  • returns [bool]: wether the family should be escaped (contains ' ')
  • family [string]: input family string

About

Font-stacks database & utils


Languages

Language:JavaScript 100.0%