包详细信息

postcss-font-weights

jonathantneal37.8kCC0-1.0不推荐使用5.0.0

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

Use common font weights in CSS

postcss, css, postcss-plugin, fonts

自述文件

PostCSS Font Weights PostCSS

NPM Version Build Status Support Chat

PostCSS Font Weights lets you do this in CSS.

h1, h2, h3 {
  font-weight: light;
}

pre {
   font: light 100% monospace;
}

/* becomes */

h1, h2, h3 {
  font-weight: 300;
}

pre {
   font: 300 100% monospace;
}

Common font weights are found in the Font Weight Numeric Values section of the CSS Fonts Specification.

Common Weight Numeric Value
thin 100
extralight 200
ultralight 200
light 300
book 400
normal 400
regular 400
roman 400
medium 500
semibold 600
demibold 600
bold 700
extrabold 800
ultrabold 800
black 900
heavy 900

These common font weights are converted to their numeric counterpart.

Usage

Add PostCSS Font Weights to your project:

npm install postcss-font-weights --save-dev

Use PostCSS Font Weights to process your CSS:

const postcssFontWeights = require('postcss-font-weights');

postcssFontWeights.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssFontWeights = require('postcss-font-weights');

postcss([
  postcssFontWeights(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Font Weights runs in all Node environments, with special instructions for:

Node PostCSS CLI Webpack Create React App Gulp Grunt

Options

prefix

The prefix option determines the prefix applied to properties being processed (e.g. x for -x-font-weight). Wrapping dashes (-) are automatically applied.

custom

The custom option determines additional font weight keywords and numeric pairs (e.g. custom: { lite: 300 } for font-weight: lite to become font-weight: 300).

更新日志

Changes to PostCSS Font Weights

5.0.0 (October 8, 2018)

  • Use Node 6 (major)
  • Use PostCSS 7.0.5 (major)

4.0.0 (May 25, 2017)

  • Added: Support for PostCSS 6, Node 4
  • Removed: echint and jscs devDependencies
  • Updated: 2 spaces in Markdown
  • Updated: dependencies

3.0.1 (December 8, 2016)

  • Updated: Use destructing assignment on plugin options
  • Updated: Use template literals

3.0.0 (December 5, 2016)

  • Added: Custom font weights through options
  • Updated: boilerplate conventions (Node v6.9.1 LTS)

2.0.1 (December 8, 2015)

  • Updated: Dependencies, Documentation, and Tests

2.0.0 (September 1, 2015)

  • Updated: PostCSS 5
  • Updated: Developer dependencies
  • Updated: ESLint rules

1.0.1 (August 3, 2015)

  • Updated: Documentation

1.0.0 (August 3, 2015)

  • Added: Support for font declaration
  • Removed: Alteration of normal or bold

0.1.2 (June 23, 2015)

  • Fixed: Optimization

0.1.1 (June 22, 2015)

  • Added: Documentation

0.1.0 (June 22, 2015)

  • Added: Initial release