npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-google-webfonts

v4.1.0

Published

A gulp plugin to download Google webfonts and generate a stylesheet for them.

Downloads

2,062

Readme

gulp-google-webfonts

A gulp plugin to download Google webfonts and generate a stylesheet for them.

Note: The examples seem to have issues with Gulp v4.

Example #1

Input

fonts.list

# Tab-delimeted format
Oswald	400,700	latin,latin-ext

# Google format
Roboto:500,500italic&subset=greek

gulpfile.js

var gulp = require('gulp');
var googleWebFonts = require('../');

var options = { };

gulp.task('fonts', function () {
	return gulp.src('./fonts.list')
		.pipe(googleWebFonts(options))
		.pipe(gulp.dest('out/fonts'))
		;
	});

gulp.task('default', ['fonts']);

Output

gulp fonts

out/fonts/

fonts.css
Oswald-normal-400.woff
Oswald-normal-700.woff
Roboto-italic-500.woff
Roboto-normal-500.woff

out/fonts/fonts.css

@font-face {
	font-family: 'Oswald';
	font-style: normal;
	font-weight: 400;
	src: url(Oswald-normal-400.woff) format('woff');
	unicode-range: U+0-10FFFF;
}

@font-face {
	font-family: 'Oswald';
	font-style: normal;
	font-weight: 700;
	src: url(Oswald-normal-700.woff) format('woff');
	unicode-range: U+0-10FFFF;
}

@font-face {
	font-family: 'Roboto';
	font-style: italic;
	font-weight: 500;
	src: url(Roboto-italic-500.woff) format('woff');
	unicode-range: U+0-10FFFF;
}

@font-face {
	font-family: 'Roboto';
	font-style: normal;
	font-weight: 500;
	src: url(Roboto-normal-500.woff) format('woff');
	unicode-range: U+0-10FFFF;
}

Options

The googleWebFonts object can take the following options:

  • fontsDir - The path the output fonts should be under. (Note: the path is relative to gulp.dest)
  • cssDir - The path the output css should be under. (Note: the path is relative to gulp.dest)
  • cssFilename - The filename of the output css file.
  • fontDisplayType - The css font display type (Default: auto)

Example #2

Input (other inputs same as example #1)

gulpfile.js

var gulp = require('gulp');
var googleWebFonts = require('../');

var options = {
	fontsDir: 'googlefonts/',
	cssDir: 'googlecss/',
	cssFilename: 'myGoogleFonts.css'
};

gulp.task('fonts', function () {
	return gulp.src('./fonts.list')
		.pipe(googleWebFonts(options))
		.pipe(gulp.dest('out/fonts'))
		;
	});

gulp.task('default', ['fonts']);

Output

gulp fonts

out/

./fonts/googlefonts/Oswald-normal-400.woff
./fonts/googlefonts/Oswald-normal-700.woff
./fonts/googlefonts/Roboto-normal-500.woff
./fonts/googlefonts/Roboto-italic-500.woff
./fonts/googlecss/myGoogleFonts.css

Example #3

Input (other inputs same as example #1)

gulpfile.js

var gulp = require('gulp');
var googleWebFonts = require('../');

var options = {
	fontsDir: 'googlefonts/',
	cssDir: 'googlecss/',
	cssFilename: 'myGoogleFonts.css',
  relativePaths: true
};

gulp.task('fonts', function () {
	return gulp.src('./fonts.list')
		.pipe(googleWebFonts(options))
		.pipe(gulp.dest('out/fonts'))
		;
	});

gulp.task('default', ['fonts']);

Output

gulp fonts

out/

./css/fonts.css
./fonts/Lato-normal-300.woff
./fonts/googlefonts/Oswald-normal-400.woff
./fonts/googlefonts/Oswald-normal-700.woff
./fonts/googlefonts/Roboto-normal-500.woff
./fonts/googlefonts/Roboto-italic-500.woff
./fonts/Roboto-normal-400.woff
./fonts/Lato-normal-400.woff
./fonts/googlecss/myGoogleFonts.css
./fonts/Lato-italic-400.woff

Example #4

Command-line usage

Input

Makefile

PATH := ./node_modules/.bin:$(PATH)

out := out

fonts_list := fonts.list
fonts_dir := fonts
css_dir := css
css_filename := fonts.css

.PHONY: default fonts clean

default: fonts

clean:
	rm -rf -- $(out)

fonts:
	google-webfonts < $(fonts_list) --out-base-dir $(out) --fonts-dir $(fonts_dir) --css-dir $(css_dir) --css-filename $(css_filename)

fonts.list

Lato	300,400,400italic	latin,greek
Roboto	400					latin,latin-ext

Output

make

out/

./css/fonts.css
./fonts/Lato-normal-300.woff
./fonts/Roboto-normal-400.woff
./fonts/Lato-normal-400.woff
./fonts/Lato-italic-400.woff

out/css/fonts.css

@font-face {
	font-family: 'Lato';
	font-style: italic;
	font-weight: 400;
	src: url(fonts/fonts/Lato-italic-400.woff) format('woff');
	unicode-range: U+0-10FFFF;
}

@font-face {
	font-family: 'Lato';
	font-style: normal;
	font-weight: 300;
	src: url(fonts/fonts/Lato-normal-300.woff) format('woff');
	unicode-range: U+0-10FFFF;
}

@font-face {
	font-family: 'Lato';
	font-style: normal;
	font-weight: 400;
	src: url(fonts/fonts/Lato-normal-400.woff) format('woff');
	unicode-range: U+0-10FFFF;
}

@font-face {
	font-family: 'Roboto';
	font-style: normal;
	font-weight: 400;
	src: url(fonts/fonts/Roboto-normal-400.woff) format('woff');
	unicode-range: U+0-10FFFF;
}