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

node-source-han-sans

v1.1.0-2.001R

Published

An npm package to facilitate use of web fonts and CSS @font-faces for adobe-fonts/source-han-sans.

Downloads

741

Readme

node-source-han-sans

An npm package to facilitate use of web fonts and CSS @font-faces for adobe-fonts/source-han-sans.

Usage

Quick Start

This package is to self-host web fonts for client-side usage instead of using a solution such as Adobe TypeKit. If your project is able to load fonts, then this package should be able to plug-and-play.

Simply include in your JS/TS file:

// Japanese seems to be the default language for the font because the font family name for "Regular" does not have language identifier in it.
require('node-source-han-sans/SourceHanSans-Regular-all.css');
// Or
import 'node-source-han-sans/SourceHanSans-Regular-all.css';

and you are ready to use the Source Han Sans for font-family in your CSS code.

Advanced Options

The SourceHanSans-Regular-all.css here includes all font formats for SourceHanSans-Regular. There are other options to choose what to include. Replace "all" with "local", "otf", "local-otf"... to use just local source, just otf, local source followed by otf source, etc. Likewise, if you need different/additional font weights, you need to change the SourceHanSans-Regular part. Look in the folder for what's available.

If you switch between languages/locales, consider switching to a different subset because certain characters do differ. Note that the font family name will also change. For example, for Simplified Chinese, the font family name becomes "Source Han Sans SC". Refer to SourceHanSansDesignGuide.pdf and SourceHanSansReadMe.pdf for more information.

HW refers to "Half-Width".

Repo Structure

This package is merely a wrapper around adobe-fonts/source-han-sans to distribute the fonts on npm. However, this is an early start of making the most optimized wrapper. As a result, this repo uses several branches, each branch corresponding to a release of "Font Files" on adobe-fonts/source-han-sans (e.g. Branch 1.001R is based on the release in tag 1.001R of adobe-fonts/source-han-sans). The release version will have dist-tags corresponding to the font version (e.g. for branch 1.001R the npm version could be v1.0.0-1.001R, v1.0.1-1.001R, v1.1.0-1.001R and so on). The wrapper branch contains the documentation and the code that are maintained by myself. Changes will be made on the wrapper branch first, and then merged onto each branch, and a release will be made from each branch with a "patch" version bump.

The src folder is a git submodule reflecting the adobe-fonts/source-han-sans repo at the release tag. It is used for building and to include the LICENSE of the font which, has to be the license under which this package and its source code is released, as far as I understand. If that's not the case, please inform me by opening an Issue.

How to Help

If this project is in the right direction, but it's "not there" yet, please open an Issue to discuss it.

Supporting Different Formats

Currently, I'm looking for a reliable way to convert the font source files into various formats. Several tools, including css3-font-converter (Docker Hub) and others fell short because they do not have proper support for Unicode beyond a certain range, which, as far as I understand, does not include CJK (Chinese, Japanese, Korean) unicode characters.

Instead, I was able to find ttf2woff2 (Docker Hub) to convert .otf files (somehow .otf seems to work interoperably with .ttf files, I don't know why) to .woff2 files and that's what's currently being supported. If there are ways to convert to other formats that has decent support, I'd like to add them.

Furthermore, if less/sass/scss/etc formats are needed, please let me know or open pull requests to add them.

Build

I use the following command to build and publish the package:

node src/build.js

However, you might not want to execute all steps (especially npm publish). For control of that, please refer to settings.js and comment out (or set to desired values) specific fields.

The script uses ttf2woff2 to convert the .otf files (again ttf can be used on otf here) to convert each file to .woff2. This project needs Docker to run ttf2woff2, and if your docker needs to run with sudo, consider running the above command with sudo or modify the build script.