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

@fylgja/fontface

v2.1.1

Published

Generate a full fledged css @font-face using only the name and suffix

Downloads

111

Readme

Fylgja - FontFace

NPM version

The Fylgja font-face mixin makes it super easy to load fonts.

It will set all required settings for a good font-face automatically. Which are still configurable if needed.

Installation

npm i -D @fylgja/fontface

How to use

Include the font-face package in to your code via;

Include the utilkit package in to your code via;

@import "@fylgja/fontface"; // (DartSass, LibSass 3.6)
@import "@fylgja/fontface/index"; // old way

To load a font. Call the font-face mixin. Add your font name + suffix of the font.

All the other steps will be created by the mixin automatically, (See config).

Input:

@include font-face("Roboto", "Bold Italic");

Output:

@font-face {
  font-family: "Roboto";
  src:
    local("Roboto Bold Italic"),
    local("Roboto-BoldItalic"),
    url("../fonts/Roboto-BoldItalic.woff2") format("woff2"),
    url("../fonts/Roboto-BoldItalic.woff") format("woff");
  unicode-range: "U+0000—00FF";
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

Config

There is no real config except the mixin options that you can pass per font.

Most options are filled in. if left to its default value.

For this reason it is better to call a specific option. Instead changing the complete mixin options. Until you've reached the option you need to change.

Examples;

Bad way:

@include font-face("Roboto", "Regular", 400, "U+0-10FFFF", "../assets");

Good way:

@include font-face("Roboto", "Regular", $path: "../assets");

| Options | Default value | Description | | ------------ | ------------------ | ----------------------------------- | | $name | | Name of the font family | | $suffix | null | Suffix (e.g. Regular or Bold) | | $styles | $suffix | Styles (e.g. 700i or 700 italic) | | $unicode | $u-latin | Unicode range of the the font face. | | $path | '../fonts' | Path to the font file | | $file-name | null | File name of the font | | $formats | local, woff2, woff | The file formats of the font-face. | | $load | swap | Loading option of the font |

If an option is NULL it will be filled in by the font-face defaults

If an option is missing. Plz leave a feature request.

Tips

Loop

You can load the entire Roboto font stack via a foreach loop.

$fonts-roboto: (
    "Light",
    "Light Italic",
    "Regular",
    "Italic",
    "Bold"
);

@each $styles in $fonts-roboto {
    @include font-face("Roboto", $styles);
}

Icons

You can use this mixin to also load font icon libraries. Simply call the mixin as describe above. But leave the suffix field to its default value of null.

@include font-face("FontAwesome", $unicode: "U+0-10FFFF");

Or use the suffix value of 'Regular'

@include font-face("Material Icons", "Regular", $unicode: "U+0-10FFFF");

This will set by default the:

  • font-weight to 400
  • font-style to normal

You must still set the $unicode, since icon libraries have a diffrent one than just Latin. The default for the unicode is U+0-10FFFF which is all unicodes.

FAQ

This is a little thing that came with the first publish. Sadly this is stuck to the repo.

But I am not planing to change this Since then I have to deprecate this one and republish a new font-face repo.

If you are planing to use variable fonts you don't need this.

This makes loading font-families easier and is over kill for just one font-face.