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

@considonet/g-fontasticbundler

v1.2.1

Published

G-Build Fontastic webfont bundler

Downloads

6

Readme

g-fontasticbundler

Licence: MIT

Copyright (C) 2018-2019 ConsidoNet Solutions

www.considonet.com

What is Fontastic?

Fontastic is an online icon font generator tool, free even for commercial use. It offers a vast choice of free icons and also allows to import and convert your own SVG file. I've found it extremely useful in our projects and decided to integrate it into G-Build -based building process. This package is a core dependency for G-Build and its internal module.

Fontastic allows you to download the fonts and use the icons locally but also offers excellent cloud-based hosting service (paid for commercial projects, free for personal use). To use the bundler just publish the font to the cloud (it's not against the licence) and provide proper parameters. This tool will download the assets each time you run it but your final project will not be relying on Fontastic Cloud - the files will be stored locally.

The configuration is integrated with G-Build. However if you would like to use this bundler in a separate project without G-Build, below you can find the short API doc.

How does the bundler work?

The bundler downloads the font files and parses the CSS style. On output you'll get a SCSS file with all the icon definitions + references to included webfont files according to your setup.

API

The API is exposed as a class. As for now there is no CLI interface (it's available in G-Build).

Usage:

const FontasticBundler = require("@considonet/g-fontasticbundler");
const bundler = new FontasticBundler();

bundler.bundle(
  "aaAAaaAAAaaaaa",       // The Fontastic package ID
  "./css",                // Path to your CSS directory root     
  "./css/fonts",          // Path to your font directory root
  "./css/fontastic.scss"  // Path to generated SCSS file with icon definitions
); 

Output directory structure for such a config:

css
│   fontastic.scss 
│
└───fonts
│   │   myfont.eot
│   │   myfont.svg
│   │   myfont.ttf
│   │   myfont.woff

Icon usage

HTML:

<!-- no additional CSS/SCSS markup required (compatible with default Fontastic usage) -->
<div class="icon-myicon1"></div>
<div data-icon="myicon1"></div>

<!-- see the examples below: simple one-time usage -->
<div class="myicon"></div>

<!-- see the examples below: extended usage -->
<div class="el__icon el__icon--myicon"></div>

SCSS (superpowers added by this bundler):

// Loading the file generated by the bundler
@import "./fontastic.scss";

// Simple one-time usage
.myicon::before {
    @include icon(myicon1, true); // where 'true' indicates if the mixin should load all the styles or just set content attribute
}

// Extended usage (BEM used there)
.el__icon {

    // General
    &::before {
        @include fIcon(); // loads the styles but doesn't set the content attribute    
    }
    
    // Icons
    // We don't set true for the second parameter because the styles are already set by the .el__icon class
    &--myicon1::before {
        @include icon(myicon1);
    }
    
    &--myicon2::before {
        @include icon(myicon2);
    }
    
}

FAQ

Where to get the Fontastic ID from?

After publishing the font into Fontastic Icon Font Cloud you'll get a similar code: <link href="https://file.myfontastic.com/xyZrJ9fqwKbjbLoy8TUiWh/icons.css" rel="stylesheet">

xyZrJ9fqwKbjbLoy8TUiWh is the code you are looking for.