Git Product home page Git Product logo

gulp-simplefont64's Introduction

gulp-simplefont64

Build Status NPM version

Encode base64 data from font-files and store the resulting fonts grouped according to font-family in a css file.

Encoding fonts in base64 is great but often you just end up with a list of font-families like: PlayfairDisplay-Black, PlayfairDisplay-Regular, PlayfairDisplay-Italic, instead of just grouping them all under the same font-family and giving the font faces the appropriate rule declarations.

For gulp-simplefont64, just name your fonts in the following format:

FontFamily-Style1-Style2...

For example:

PlayfairDisplay-Black-Italic.otf

And gulp-simplefont64 will give it the appropriate rulesets underneath the PlayfairDisplay font family (font-weight: 800; and font-style: italic;).

Example

gulpfile.js

var gulp = require('gulp');
var font64 = require('gulp-simplefont64');

gulp.task('fonts', function() {
    return gulp.src(['src/fonts/**/*.otf', 'src/fonts/**/*.ttf'])
        .pipe(font64())
        .pipe(gulp.dest('dist/stylesheets/'));
});

Contents of "src/fonts":

    +-- src
    |   +--fonts
    |      +-- PlayfairDisplay-Black-Italic.otf

Result of plugin:

@font-face {
  font-family: PlayfairDisplay;
  font-weight: 800;
  font-style: italic;
  src: url("playfair-display/data: font/opentype; base64,T1RUTwAMAIAAAwBAQ0ZGICNw7jIAABE8AAFw1UdERUYSkBS7AAGPSAAAAERHUE9TXJ5OgwABqaAAAJDYR1NVQmMeE9EAAY+MAAAaFE9TLzJuRIYyAAABMAAAAGBjbWFw5kH1tQAACbgAAAdkaGVhZANwzXwAAADMAAAANmhoZWERJQwdAAABBAAAACRobXR4PCvh+gABghQAAA00bWF4cANNUAAAAAEoAAAABm5hbWUD6eGxAAABkAAACCdwb3N0/zwAKQAAERwAAAAgAAEAAAABAQbN9rJqXw889QADCAAAAAAAzmtAdgAAAADOa0B2/Qr9/ 
};

gulp-simplefont64's People

Watchers

James Cloos avatar Benjamin Bolland avatar Florian Brick avatar Karl Fischer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.