Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Add --suffix command-line option #85

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
17 changes: 17 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Auto PR

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: zk-phi/auto-pr@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
base: 'master'
head: 'zachleat:master'

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
test/fonts/ignored
test/fonts/ignored
package-lock.json
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
v4.0.0

* Requires Node 10+ (Node 8 is EOL)
* A bunch of major release bumps of dependencies
* Fixes the `(node:1077) Warning` console output documented at the end of https://www.sarasoueidan.com/blog/glyphhanger/
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ git submodule update --init --recursive
python setup.py install
```

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](https://www.sarasoueidan.com/blog/glyphhanger/) by Sara Soueidan.

## Usage

_Related: operate on existing `unicode-range` values with [Unicode Range Interchange](https://www.zachleat.com/unicode-range-interchange/) ([read the blog post](https://www.zachleat.com/web/unicode-range-interchange/))._

### Find the glyphs in a local file or url

```sh
Expand All @@ -47,7 +51,7 @@ glyphhanger ./test.html --string
glyphhanger http://example.com

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

# show results for each font-family on the page
glyphhanger ./test.html --json
Expand Down Expand Up @@ -233,15 +237,14 @@ echo "this is a test" | glyphhanger --jsdom

## Testing

* Build Status: [![Build Status](https://travis-ci.org/filamentgroup/glyphhanger.svg?branch=master)](https://travis-ci.org/filamentgroup/glyphhanger)

`npm test` will run the tests.

Or, alternatively `npx mocha`.

## Enhancement Queue

* [Top Voted Issues 👍](https://github.com/filamentgroup/glyphhanger/issues?q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc)
* [Top Voted Issues 👍](https://github.com/zachleat/glyphhanger/issues?q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc)
* Archived: [Voted Issues from `filamentgroup/glyphhanger`](https://github.com/filamentgroup/glyphhanger/issues?q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc)

## Alternatives to GlyphHanger

Expand Down
1 change: 1 addition & 0 deletions cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if( argv.jsdom ) {

var subset = new GlyphHangerSubset();
subset.setOutputDirectory(argv.output);
subset.setOutputSuffix(argv.suffix);

if( argv.formats ) {
subset.setFormats( argv.formats );
Expand Down
39 changes: 19 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
{
"name": "glyphhanger",
"version": "3.2.0",
"version": "4.0.1",
"description": "A tool to ease webfont subsetting.",
"main": "src/GlyphHanger.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/filamentgroup/glyphhanger.git"
"url": "git+https://github.com/zachleat/glyphhanger.git"
},
"author": {
"name": "Zach Leatherman",
"email": "zach@filamentgroup.com",
"url": "https://filamentgroup.com"
"email": "zachleatherman@gmail.com",
"url": "https://zachleat.com/"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/filamentgroup/glyphhanger/issues"
"url": "https://github.com/zachleat/glyphhanger/issues"
},
"homepage": "https://github.com/filamentgroup/glyphhanger#readme",
"homepage": "https://github.com/zachleat/glyphhanger#readme",
"bin": {
"glyphhanger": "./cmd.js"
},
"dependencies": {
"@zachleat/spider-pig": "^1.0.3",
"chalk": "^2.3.0",
"@zachleat/spider-pig": "zk-phi/spider-pig",
"chalk": "^4.1.0",
"characterset": "^1.3.0",
"connect": "^3.6.6",
"debug": "^3.1.0",
"filesize": "^3.5.11",
"fs-extra": "^5.0.0",
"get-stdin": "^6.0.0",
"glob": "^7.1.2",
"jsdom": "^13.0.0",
"minimist": "^1.2.0",
"connect": "^3.7.0",
"debug": "^4.3.1",
"filesize": "^6.1.0",
"fs-extra": "^9.1.0",
"get-stdin": "^8.0.0",
"glob": "^7.1.6",
"jsdom": "^15.2.1",
"minimist": "^1.2.5",
"parse-filepath": "^1.0.2",
"rsvp": "^4.7.0",
"serve-static": "^1.13.2",
"shelljs": "^0.7.8"
"serve-static": "^1.14.1",
"shelljs": "^0.8.4"
},
"devDependencies": {
"mocha": "^4.0.1"
"mocha": "^8.3.1"
}
}
13 changes: 12 additions & 1 deletion src/GlyphHangerSubset.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ class GlyphHangerSubset {
return this.outputDirectory;
}

setOutputSuffix( suffix ) {
if( suffix != null ) {
this.outputSuffix = suffix;
}
}

getOutputSuffix() {
return this.outputSuffix;
}

setFontFilesGlob( ttfFilesGlob ) {
this.fontPaths = glob.sync( ttfFilesGlob );
}
Expand Down Expand Up @@ -84,7 +94,8 @@ class GlyphHangerSubset {

getFilenameFromTTFPath( ttfPath, format, useZopfli ) {
var fontPath = parsePath( ttfPath );
var outputFilename = fontPath.name + "-subset" + ( useZopfli ? ".zopfli" : "" ) + ( format ? "." + format : fontPath.ext );
var suffix = this.getOutputSuffix();;
var outputFilename = fontPath.name + (suffix == null ? "-subset" : suffix) + ( useZopfli ? ".zopfli" : "" ) + ( format ? "." + format : fontPath.ext );
return outputFilename;
}

Expand Down
2 changes: 1 addition & 1 deletion src/GlyphHangerWhitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GlyphHangerWhitelist {
}

if( presets.LATIN ) {
cs = cs.union( CharacterSet.parseUnicodeRange("U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD" ));
cs = cs.union( CharacterSet.parseUnicodeRange("U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD" ));
}

if( typeof chars === "string" ) {
Expand Down