postcss-unicode-characters
![Dependency Status](https://camo.githubusercontent.com/bb59f69c3f24fddfd6322410cec378a1dc98cfe5bb10de0551081f19cec9d484/68747470733a2f2f67656d6e617369756d2e636f6d2f62656e2d65622f706f73746373732d756e69636f64652d636861726163746572732e737667)
An easier way to write unicode-range descriptors.
With npm do:
npm install postcss-unicode-characters --save
This module provides syntactic sugar for the unicode-range
descriptor,
inspired by @svgeesus' dotCSS talk. It provides three different ways to
construct a standard unicode-range
descriptor by using the non-standard
unicode-characters
descriptor.
The formal syntax for unicode-characters
looks like this:
[ <string> | name( <string> ) | script( <string> ) ]#
Write in the characters that you want to subset directly, using a string:
@font-face {
font-family: test;
src: local("Baskerville");
unicode-characters: "hello";
}
@font-face {
font-family: test;
src: local("Baskerville");
unicode-range: U+68, U+65, U+6C, U+6F;
}
Using this method, duplicate characters are automatically removed for you.
If you can remember a Unicode description for a character, using this function will save some time obtaining the literal:
@font-face {
font-family: test;
src: local("Baskerville");
unicode-characters: name("black star");
}
@font-face {
font-family: test;
src: local("Baskerville");
unicode-range: U+2605;
}
You can also use the script
function for a range of characters.
@font-face {
font-family: test;
src: local("Baskerville");
unicode-characters: script("arrows");
}
@font-face {
font-family: test;
src: local("Baskerville");
unicode-range: U+2190-21FF;
}
Note that you can mix and match as many combinations as you like, even using
the classic unicode-range
syntax. Just remember that these should be separated
by a comma:
@font-face {
font-family: test;
src: local("Baskerville");
unicode-characters: script("arrows"), "hello", U+26;
}
@font-face {
font-family: test;
src: local("Baskerville");
unicode-range: U+2190-21FF, U+68, U+65, U+6C, U+6F, U+26;
}
See the PostCSS documentation for examples for your environment.
Thanks goes to these wonderful people (emoji key):
Ben Briggs 💻 📖 👀 |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT © Ben Briggs