0.2.4 • Published 1 year ago

unocss-preset-glyph v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

unocss-preset-glyph

Glyph subsetter for UnoCSS

Embed subset of glyphs from fonts.

Installation

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:

// 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:

<div class="g-fontname-uno g-alias-cs">
  uno css
</div>

Utilities

  • g-<font item>-<glyphs>

    Where:

    • <font item> is key in fonts config.
    • <glyphs> is list of glyph/character to be subsetted.

Type of GlyphOptions

export interface GlyphOptions {
  /**
   * List of font and its path.
   *
   */
  fonts?: Record<string, string>
  /**
   * 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.

0.2.1

1 year ago

0.2.0

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.4

1 year ago

0.0.6

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago