All Projects → zachleat → glyphhanger

zachleat / glyphhanger

Licence: MIT license
Your web font utility belt. It can subset web fonts. It can find unicode-ranges for you automatically. It makes julienne fries.

Projects that are alternatives of or similar to glyphhanger

Glyphhanger
Your web font utility belt. It can subset web fonts. It can find unicode-ranges for you automatically. It makes julienne fries.
Stars: ✭ 1,099 (+160.43%)
Mutual labels:  unicode, font, spider, webfonts, web-fonts
beatrix
A tool to chop off useless fonts glyphs and convert TTF/OTF into WOFF & WOFF2
Stars: ✭ 22 (-94.79%)
Mutual labels:  webfonts, glyphs, subset
fontawesome-subset
Creates subsets of FontAwesome fonts for optimized use on the web.
Stars: ✭ 41 (-90.28%)
Mutual labels:  webfonts, glyphs, subset
Urbanist
Urbanist is a low-contrast, geometric sans-serif inspired by Modernist design and typography.
Stars: ✭ 374 (-11.37%)
Mutual labels:  font, webfonts, glyphs
kuu-pyaung
Laravel package to convert files and database from zawgyi to unicode.
Stars: ✭ 13 (-96.92%)
Mutual labels:  unicode, font
Typography
C# Font Reader (TrueType / OpenType / OpenFont / CFF / woff / woff2) , Glyphs Layout and Rendering
Stars: ✭ 246 (-41.71%)
Mutual labels:  font, webfonts
Last Resort Font
Last Resort Font
Stars: ✭ 462 (+9.48%)
Mutual labels:  unicode, font
Awesome Typography
✏︎ Curated list about digital typography 🔥
Stars: ✭ 947 (+124.41%)
Mutual labels:  unicode, webfonts
Font Awesome Php
A PHP library for Font Awesome 4.7.
Stars: ✭ 47 (-88.86%)
Mutual labels:  unicode, font
Open Relay
Free and open source fonts from Kreative Software
Stars: ✭ 48 (-88.63%)
Mutual labels:  unicode, font
Woffle
Drag and drop woff and woff2 web font generator for macOS
Stars: ✭ 24 (-94.31%)
Mutual labels:  webfonts, web-fonts
Hack
A typeface designed for source code
Stars: ✭ 14,543 (+3346.21%)
Mutual labels:  font, web-fonts
Operator Mono Lig
Add ligatures to Operator Mono similar to Fira Code
Stars: ✭ 2,683 (+535.78%)
Mutual labels:  font, glyphs
attic
A collection of personal tiny tools - mirror of https://gitlab.com/hydrargyrum/attic
Stars: ✭ 17 (-95.97%)
Mutual labels:  unicode, font
Powerline Web Fonts
Powerline Web Fonts for Chromebook
Stars: ✭ 178 (-57.82%)
Mutual labels:  font, web-fonts
Webfont
Awesome generator of webfont
Stars: ✭ 170 (-59.72%)
Mutual labels:  font, web-fonts
Open Arrow
Open Arrow is an open-source font that contains 112 arrow symbols from U+2190 to U+21ff
Stars: ✭ 89 (-78.91%)
Mutual labels:  unicode, font
Noto-Sans-CJK-JP.min
Subset of the Noto Sans CJK JP for the size down.
Stars: ✭ 23 (-94.55%)
Mutual labels:  font, webfonts
Fontcdn
Search tool for Google Fonts
Stars: ✭ 126 (-70.14%)
Mutual labels:  font, webfonts
Karmilla
An expanded version of the amazing Karla webfont, adding support for various languages (French, German, Norse, Hungarian, Latvian, Icelandic...)
Stars: ✭ 130 (-69.19%)
Mutual labels:  font, web-fonts

glyphhanger

Your web font utility belt. It can subset web fonts. It can show you what unicode-ranges are used on a web site (optionally per font-family). It can also subset web fonts automatically using the unicode-ranges it found. It makes julienne fries.

Installation

Available on npm.

npm install -g glyphhanger

Prerequisite: pyftsubset

See https://github.com/fonttools/fonttools.

pip install fonttools
# Additional installation for --flavor=woff2
pip install brotli

# Additional installation for --flavor=woff --with-zopfli
pip install zopfli

If you want to read an in-depth tutorial on the installation steps above, please read How I set up Glyphhanger on macOS for optimizing and converting font files for the Web by Sara Soueidan.

Usage

Related: operate on existing unicode-range values with Unicode Range Interchange (read the blog post).

Find the glyphs in a local file or url

# local file
glyphhanger ./test.html
glyphhanger ./test.txt

# output characters instead of Unicode code points
glyphhanger ./test.html --string

# remote URL
glyphhanger http://example.com

# multiple URLs, optionally using HTTPS
glyphhanger https://google.com https://www.zachleat.com

# show results for each font-family on the page
glyphhanger ./test.html --json

# show results only for one or more font-family names
glyphhanger ./test.html --family='Open Sans, Roboto'

# Show version
glyphhanger --version

# See more usage
glyphhanger --help

Debug Mode

Replaces --verbose in v3.0.0.

> DEBUG=glyphhanger* glyphhanger http://example.com

Subset font files automatically

Use --subset=*.ttf to select some font files for subsetting. Note that you can also subset yourself manually with pyftsubset (but glyphhanger is easier).

Note that the DEBUG output documented above will log the specific pyftsubset command that glyphhanger used. Read more about pyftsubset defaults.

Just make optimized TTF/WOFF/WOFF2 files

> glyphhanger --subset=*.ttf

Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.ttf (was 145.06 KB, now 70.25 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.zopfli.woff (was 145.06 KB, now 36.51 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff2 (was 145.06 KB, now 28.73 KB)

Subset to specific characters only (no URLs)

> glyphhanger --whitelist=ABCD --subset=*.ttf

Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.ttf (was 145.06 KB, now 4.42 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.zopfli.woff (was 145.06 KB, now 2.84 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff2 (was 145.06 KB, now 2.24 KB)

Subset to the glyphs at a URL

> glyphhanger ./test.html --subset=*.ttf

Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.ttf (was 145.06 KB, now 24 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.zopfli.woff (was 145.06 KB, now 14.34 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff2 (was 145.06 KB, now 11.37 KB)

Subset to the glyphs at a URL only using content that matches a specific font-family

> glyphhanger ./test.html --subset=*.ttf --family='Lato,sans-serif'

Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.ttf (was 145.06 KB, now 24 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.zopfli.woff (was 145.06 KB, now 14.34 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff2 (was 145.06 KB, now 11.37 KB)

Specify the formats to output

Available formats: ttf,woff,woff-zopfli,woff2.

> glyphhanger --whitelist=ABCD --formats=woff2,woff --subset=*.ttf

Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff (was 145.06 KB, now 2.88 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff2 (was 145.06 KB, now 2.24 KB)

Output a @font-face block with --css

Because we’re not parsing URLs for glyphs, we can optionally use --family='My Family Name' to set the name used in the @font-face block. Normally --family would tell GlyphHanger to only parse text data from nodes using one of the fonts listed in --family. Using --subset and --css together will write a CSS file, too.

> glyphhanger --whitelist=ABCD --formats=woff2,woff --subset=*.ttf --css

Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff (was 145.06 KB, now 2.88 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff2 (was 145.06 KB, now 2.24 KB)
Writing CSS file: LatoLatin-Regular.css

@font-face {
  font-family: LatoLatin;
  src: url(sourcesanspro-regular-subset.woff2) format("woff2"), url(sourcesanspro-regular-subset.woff) format("woff");
  unicode-range: U+41-44;
}

Specify output directory for any files created with --output

> glyphhanger --subset=*.ttf --output=some/other/path

Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff (was 145.06 KB, now 2.88 KB)
Subsetting LatoLatin-Regular.ttf to LatoLatin-Regular-subset.woff2 (was 145.06 KB, now 2.24 KB)

Whitelist Characters

# Add in a whitelist of specific characters
glyphhanger https://google.com --whitelist=abcdefgh

# Add in a whitelist as a unicode range
glyphhanger https://google.com --whitelist=U+26

# shortcut to add in a whitelist of all of US-ASCII (with an optional whitelist)
glyphhanger https://google.com --US_ASCII --whitelist=™

# shortcut to add in a whitelist of all Latin characters (with an optional whitelist)
glyphhanger https://google.com --LATIN --whitelist=™

Manual subsetting

glyphhanger --whitelist=ABCD --subset=*.ttf

Converting unicode ranges and back again

# Convert a string to a unicode-range
glyphhanger --whitelist=ABCD
glyphhanger --US_ASCII
glyphhanger --US_ASCII --whitelist=ABCD

# Convert a unicode-range to a string
glyphhanger --whitelist=U+41-44 --string

Use the spider to gather URLs from links

Finds all the <a href> elements on the page with local (not external) links and adds those to the glyphhanger URLs. If you specify --spider-limit, --spider is assumed.

glyphhanger ./test.html --spider
glyphhanger ./test.html --spider-limit
glyphhanger ./test.html --spider-limit=10

# No limit
glyphhanger ./test.html --spider-limit=0

Default --spider-limit is 10. Set to 0 for no limit. This will greatly affect how long the task takes.

Only search your page for visible text

Make your output even smaller by only subsetting characters that are visible on the page.

glyphhanger ./test.html --onlyVisible

Only search your page for text matching a CSS selector

Limit results to text inside of elements that match a CSS selector

glyphhanger ./test.html --cssSelector="pre, #header, .popUp"

If paired with --onlyVisible, it will only return elements that are both visible and match the selector

Advanced: jsdom Mode ⚠️

JSDOM mode can be useful running against static pages that don’t use a lot of JavaScript generated content. While JSDOM mode can handle some JavaScript generated content, Puppeteer mode should be the safest method for most use cases.

JSDOM mode will also be much faster when running against files on a local filesystem rather than URL targets.

Read more about the difference between JSDOM and a full headless browser (like the default mode that glyphhanger uses: Puppeteer/headless Chrome).

# use faster jsdom mode instead of headless Chrome
glyphhanger ./test.html --jsdom

# jsdom mode works with standard input too
echo "this is a test" | glyphhanger --jsdom

Troubleshooting

Testing

npm test will run the tests.

Or, alternatively npx mocha.

Enhancement Queue

Alternatives to GlyphHanger

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].