Skip to content

Commit

Permalink
Prepare 4.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Krasnoyarov committed Sep 5, 2016
1 parent 13a7b3b commit 60e35f9
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 58 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Head
# 4.0.0

- Changed: all style templates for font now have `nunjucks` extension.
- Chore(package): remove extra `files` from `package.json`.
- Chore(package): change semver for `remark-lint-config-itgalaxy` from `~` to `^`.
- Chore(package): install all `peerDependencies` for `eslint-plugin-itgalaxy`.
- Chore(package): update a minimal version `ava` from `0.15.0` to `0.16.0`.
- Chore(package): update a minimal version `eslint-plugin-ava` from `2.5.0` to `3.0.0`.
- Chore(package): update a minimal version `npm-run-all` from `2.3.0` to `3.0.0`.
- Chore(package): update a minimal version `eslint-plugin-itgalaxy` from `8.0.0` to `11.0.0`.
- Chore(package): update a minimal version `nyc` from `7.0.0` to `8.0.0`.
- Chore(package): remove `nyc` settings, now fine works without their.
- Chore(package): use `^` instead `~` from `babel-preset-stage-0`.
- Chore(package): use `remark-preset-lint-itgalaxy` instead `remark-lint-config-itgalaxy`.
- Chore(package): use right version for `eslint-plugin-*` and `eslint`.
- Chore: improved `README.md`.
- Chore: fix glob pattern for `lint:remark` script command.

# 3.0.1
Expand Down
149 changes: 148 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# webfont

[![NPM version](https://img.shields.io/npm/v/webfont.svg)](https://www.npmjs.org/package/webfont) [![Travis Build Status](https://img.shields.io/travis/itgalaxy/webfont/master.svg?label=build)](https://travis-ci.org/itgalaxy/webfont) [![Deps](https://david-dm.org/itgalaxy/webfont/status.svg)](https://david-dm.org/itgalaxy/webfont#info=dependencies&view=table) [![Dev Deps](https://david-dm.org/itgalaxy/webfont/dev-status.svg)](https://david-dm.org/itgalaxy/webfont#info=devDependencies&view=table)
[![NPM version](https://img.shields.io/npm/v/webfont.svg)](https://www.npmjs.org/package/webfont) [![Travis Build Status](https://img.shields.io/travis/itgalaxy/webfont/master.svg?label=build)](https://travis-ci.org/itgalaxy/webfont) [![dependencies Status](https://david-dm.org/itgalaxy/webfont/status.svg)](https://david-dm.org/itgalaxy/webfont) [![devDependencies Status](https://david-dm.org/itgalaxy/webfont/dev-status.svg)](https://david-dm.org/itgalaxy/webfont?type=dev)

Generator of webfont from SVG icons.

Expand All @@ -15,3 +15,150 @@ Features:
```shell
npm install webfont
```

## Usage

```js
const webfont = require('webfont')

webfont({
files: [
'src/dropdown.svg',
'src/close.svg'
],
fontName: 'my-font-name'
})
.then((result) => {
console.log(result);
})
```

## Options

### `files`

A file glob, or array of file globs. Ultimately passed to [node-glob](https://github.com/isaacs/node-glob) to figure out what files you want to lint.

`node_modules` and `bower_components` are always ignored.

### `configFile`

A `webfont` configuration object.

### `fontName`
Type: `String`
Default: `webfont`

The font family name you want.

### `formats`
Type: `Array`
Default value: `['svg', 'ttf', 'eot', 'woff', 'woff2']`
Possible values: `svg, ttf, eot, woff, woff2`.

Font file types to generate.

### `css`
Type: `boolean`
Default: `false`

Whether to generate CSS. If not passed `srcCssTemplate`, then it takes from `template` directory.

### `cssFormat`
Type: `string`
Default: `css`
Possible values: `css`, `scss` (feel free to contribute).

### `cssTemplateClassName`
Type: `string`
Default: null

Default font class name.

### `cssTemplateFontPath`
Type: `string`
Default: `./`

Path to generated fonts in the `CSS` file.

### `cssTemplateFontName`
Type: `string`

Default value getting from `fontName` options, but you can specify any value.

### `srcCssTemplate`
Type: `string`
Default: `null`

Default CSS template path.

### Other options comming soon.

## Command Line Interface

The interface for command-line usage is fairly simplistic at this stage, as seen in the following usage section.

### Usage

`webfont --help` prints the CLI documentation.

### Options

```bash
--config Path to a specific configuration file (JSON, YAML, or CommonJS)
or the name of a module in \`node_modules\` that points to one.
If no \`--config\` argument is provided, webfont will search for
configuration files in the following places, in this order:
- a \`webfont\` property in \`package.json\`
- a \`.webfontrc\` file (with or without filename extension:
\`.json\`, \`.yaml\`, and \`.js\` are available)
- a \`webfont.config.js\` file exporting a JS object
-f, --font-name The font family name you want, default: "webfont".
-h, --help Output usage information.
-v, --version Output the version number.
-r, --formats Only this formats generate.
-d, --dest Destination for generated fonts.
-t, --src-css-template Path to custom template.
-c, --css-template-class-name Class name in css template.
-p, --css-template-font-path Font path in css template.
-n, --css-template-font-name Font name in css template.
-s, --dest-css-template Destination for generated css template.
--quite Tell me everything!.

For "svgicons2svgfont":
--font-id The font id you want, default as "--font-name".
--style The font style you want.
--weight The font weight you want.
--fixed-width Creates a monospace font of the width of the largest input icon.
--center-horizontally Calculate the bounds of a glyph and center it horizontally.
--normalize Normalize icons by scaling them to the height of the highest icon.
--height The outputted font height [MAX(icons.height)].
--round Setup the SVG path rounding [10e12].
--descent The font descent [0].
--ascent The font ascent [height - descent].
--start-unicode The start unicode codepoint for unprefixed files [0xEA01].
--prepend-unicode Prefix files with their automatically allocated unicode codepoint.
--metadata Content of the metadata tag.
```

### Exit codes

The CLI can exit the process with the following exit codes:

- 1: Something unknown went wrong.

## Related

- [svgicons2svgfont](https://github.com/nfroidure/svgicons2svgfont) - Simple tool to merge multiple icons to an SVG font.
- [svg2ttf](https://github.com/fontello/svg2ttf) - Converts SVG fonts to TTF format.
- [ttf2eot](https://github.com/fontello/ttf2eot) - Converts TTF fonts to EOT format.
- [ttf2woff](https://github.com/fontello/ttf2woff) - Converts TTF fonts to WOFF format.
- [ttf2woff2](https://github.com/nfroidure/ttf2woff2) - Converts TTF fonts to WOFF2.

## Contribution

Feel free to push your code if you agree with publishing under the MIT license.

## [Changelog](CHANGELOG.md)

## [License](LICENSE)
31 changes: 19 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webfont",
"version": "3.0.1",
"version": "4.0.0",
"description": "Generator of webfonts from svg icons, svg icons to svg font, svg font to ttf, ttf to eot, ttf to woff, ttf to woff2",
"license": "MIT",
"author": "itgalaxy <[email protected]>",
Expand Down Expand Up @@ -62,21 +62,22 @@
},
"devDependencies": {
"ava": "^0.16.0",
"ajv-cli": "~0.9.0",
"babel-cli": "^6.11.0",
"babel-core": "^6.11.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "~6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.9.0",
"coveralls": "^2.11.6",
"eslint": "^3.0.0",
"eslint": "^3.4.0",
"eslint-plugin-ava": "^3.0.0",
"eslint-plugin-import": "^1.0.0",
"eslint-plugin-itgalaxy": "^11.0.0",
"eslint-plugin-jsx-a11y": "^2.0.0",
"eslint-plugin-lodash": "^1.0.0",
"eslint-plugin-import": "^1.14.0",
"eslint-plugin-itgalaxy": "^13.0.0",
"eslint-plugin-jsx-a11y": "^2.2.0",
"eslint-plugin-lodash": "^1.10.0",
"eslint-plugin-node": "^2.0.0",
"eslint-plugin-promise": "^2.0.0",
"eslint-plugin-react": "^6.0.0",
"eslint-plugin-react": "^6.2.0",
"eslint-plugin-xo": "^0.5.0",
"is-eot": "^1.0.0",
"is-svg": "^2.0.0",
Expand All @@ -86,21 +87,27 @@
"npmpub": "^3.1.0",
"npm-run-all": "^3.0.0",
"nyc": "^8.0.0",
"remark-cli": "^1.0.0",
"remark-lint": "^4.0.0",
"remark-lint-config-itgalaxy": "^1.0.1",
"package-schema": "~1.0.0",
"remark-cli": "~2.0.0",
"remark-lint": "~5.0.0",
"remark-preset-lint-itgalaxy": "~1.0.0",
"rimraf": "^2.5.2"
},
"scripts": {
"coveralls": "nyc report --reporter=text-lcov | coveralls",

"lint:eslint": "eslint . --ignore-path .gitignore --color",
"lint:remark": "remark '{**/*,*}.md' -r ./node_modules/remark-lint-config-itgalaxy/index.js -i .gitignore -f -q",
"lint:package": "ajv -s ./node_modules/package-schema/schema.json -d package --errors=text",
"lint:remark": "remark '{**/*,*}.md' -i .gitignore -f -q",
"lint": "npm-run-all -l --parallel lint:*",

"pretest": "npm run lint",
"ava": "nyc ava --verbose \"src/**/__tests__/*.js\"",
"test": "npm run ava",

"prebuild": "rimraf dist",
"build": "babel src --out-dir dist --ignore /__tests__/",

"prepublish": "npm run build",
"release": "npmpub"
},
Expand Down
74 changes: 37 additions & 37 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,47 @@ const cli = meow(`
$ webfont [input] [options]
Input
Files(s) or glob(s).
If an input argument is wrapped in quotation marks, it will be passed to node-glob
for cross-platform glob support.
Files(s) or glob(s).
If an input argument is wrapped in quotation marks, it will be passed to node-glob
for cross-platform glob support.
Options
--config Path to a specific configuration file (JSON, YAML, or CommonJS)
or the name of a module in \`node_modules\` that points to one.
If no \`--config\` argument is provided, stylelint will search for
configuration files in the following places, in this order:
- a \`stylelint\` property in \`package.json\`
- a \`.stylelintrc\` file (with or without filename extension:
\`.json\`, \`.yaml\`, and \`.js\` are available)
- a \`stylelint.config.js\` file exporting a JS object
The search will begin in the working directory and move up the
directory tree until a configuration file is found.
-f, --font-name The font family name you want, default: "webfont".
-h, --help Output usage information.
-v, --version Output the version number.
-r, --formats Only this formats generate.
-d, --dest Destination for generated fonts.
-t, --src-css-template Path to custom template.
-c, --css-template-class-name Class name in css template.
-p, --css-template-font-path Font path in css template.
-n, --css-template-font-name Font name in css template.
-s, --dest-css-template Destination for generated css template.
--quite Tell me everything!.
--config Path to a specific configuration file (JSON, YAML, or CommonJS)
or the name of a module in \`node_modules\` that points to one.
If no \`--config\` argument is provided, webfont will search for
configuration files in the following places, in this order:
- a \`webfont\` property in \`package.json\`
- a \`.webfontrc\` file (with or without filename extension:
\`.json\`, \`.yaml\`, and \`.js\` are available)
- a \`webfont.config.js\` file exporting a JS object
The search will begin in the working directory and move up the
directory tree until a configuration file is found.
-f, --font-name The font family name you want, default: "webfont".
-h, --help Output usage information.
-v, --version Output the version number.
-r, --formats Only this formats generate.
-d, --dest Destination for generated fonts.
-t, --src-css-template Path to custom template.
-c, --css-template-class-name Class name in css template.
-p, --css-template-font-path Font path in css template.
-n, --css-template-font-name Font name in css template.
-s, --dest-css-template Destination for generated css template.
--quite Tell me everything!.
For "svgicons2svgfont":
--font-id The font id you want, default as "--font-name".
--style The font style you want.
--weight The font weight you want.
--fixed-width Creates a monospace font of the width of the largest input icon.
--center-horizontally Calculate the bounds of a glyph and center it horizontally.
--normalize Normalize icons by scaling them to the height of the highest icon.
--height The outputted font height [MAX(icons.height)].
--round Setup the SVG path rounding [10e12].
--descent The font descent [0].
--ascent The font ascent [height - descent].
--start-unicode The start unicode codepoint for unprefixed files [0xEA01].
--prepend-unicode Prefix files with their automatically allocated unicode codepoint.
--metadata Content of the metadata tag.
--font-id The font id you want, default as "--font-name".
--style The font style you want.
--weight The font weight you want.
--fixed-width Creates a monospace font of the width of the largest input icon.
--center-horizontally Calculate the bounds of a glyph and center it horizontally.
--normalize Normalize icons by scaling them to the height of the highest icon.
--height The outputted font height [MAX(icons.height)].
--round Setup the SVG path rounding [10e12].
--descent The font descent [0].
--ascent The font ascent [height - descent].
--start-unicode The start unicode codepoint for unprefixed files [0xEA01].
--prepend-unicode Prefix files with their automatically allocated unicode codepoint.
--metadata Content of the metadata tag.
`, {
alias: {
/* eslint-disable id-length */
Expand Down
12 changes: 6 additions & 6 deletions src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,8 @@ function buildConfig(options) {
return Promise.reject(new Error('No configuration found'));
}

const rootConfigDir = path.dirname(result.filepath);

return Promise.resolve({
config: result.config,
configDir: rootConfigDir
config: result.config
});
});
}
Expand All @@ -152,11 +149,11 @@ export default function ({
'woff2'
],
css = false,
srcCssTemplate = null,
cssFormat = 'css',
cssTemplateClassName = null,
cssTemplateFontPath = './',
cssTemplateFontName = null,
srcCssTemplate = null,
formatsOptions = {
ttf: {
copyright: null,
Expand Down Expand Up @@ -262,7 +259,10 @@ export default function ({
if (!options.srcCssTemplate) {
nunjucks.configure(path.join(__dirname, '../'));

options.srcCssTemplate = path.join(__dirname, `../templates/template.${options.cssFormat}`);
options.srcCssTemplate = path.join(
__dirname,
`../templates/template.${options.cssFormat}.nunjucks`
);
}

const nunjucksOptions = Object.assign(
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 60e35f9

Please sign in to comment.