Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chu121su12/unocss-preset-glyph


https://github.com/chu121su12/unocss-preset-glyph

Last synced: 7 days ago
JSON representation

Awesome Lists containing this project

README

        

# unocss-preset-glyph



npm version


node version

> Glyph subsetter for UnoCSS

Embed subset of glyphs from fonts.

## Installation

```sh
npm i unocss-preset-glyph unocss --save-dev # with npm
yarn add unocss-preset-glyph unocss -D # with yarn
pnpm add unocss-preset-glyph unocss -D # with pnpm
```

## Usage

js:
```js
// unocss.config.js
import { presetUno, defineConfig } from 'unocss'
import { presetGlyph } from 'unocss-preset-glyph'

export default defineConfig({
presets: [
presetGlyph({
fonts: {
'fontname': 'path/to/font.woff',
alias: 'path/to/original-name.otf',
},
}),
// presetUno(),
],
})
```

html:
```html


uno css

```

## Utilities

- `g--`

Where:

- `` is key in `fonts` config.
- `` is list of glyph/character to be subsetted.

### Type of `GlyphOptions`

```ts
export interface GlyphOptions {
/**
* List of font and its path.
*
*/
fonts?: Record
/**
* Class prefix for matching glyph rules.
*
* @default `g-`
*/
prefix?: string
/**
* Rule layer
*
* @default 'glyphs'
*/
layer?: string
/**
* Prefix for font-family declaration.
*
* @default `un-`
*/
familyPrefix?: string
}
```

## Known Issues

- Using woff2 font often result in invalid font payload. Please use woff file insted.

## License

MIT

## Demo

Clone the repo, run `pnpm dev`.