Skip to content

Commit

Permalink
chore: 发布 vite-plugin-font
Browse files Browse the repository at this point in the history
  • Loading branch information
KonghaYao committed May 22, 2024
1 parent fda877b commit 97169d3
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 156 deletions.
142 changes: 71 additions & 71 deletions packages/subsets/package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
{
"name": "@konghayao/cn-font-split",
"version": "4.12.0",
"description": "中文 web font 切割工具",
"main": "dist/index.js",
"browser": "dist/browser/index.js",
"type": "module",
"bin": {
"cn-font-split": "bin/cn-font-split.mjs"
},
"repository": {
"type": "git",
"url": "https://github.com/KonghaYao/cn-font-split/tree/ts/packages/subsets"
},
"homepage": "https://chinese-font.netlify.app/",
"scripts": {
"build": "rollup -c ",
"dev": "rollup -c -w",
"build:browser": "rollup -c rollup.config.browser.mjs ",
"dev:browser": "rollup -c rollup.config.browser.mjs -w",
"test": "vitest",
"test:node": "node ./test/node.test.mjs",
"test:deno": "deno run -A --no-npm ./test/deno.test.js",
"test:bun": "bun run ./test/bun.test.mjs",
"test:browser": "live-server --port=9000 --cors --no-browser ./dist/browser&&vitest --mode browser test/browser.test.js",
"coverage": "vitest run --coverage",
"prepublish": "tsc && pnpm build && pnpm build:browser && tsc"
},
"keywords": [
"font",
"converter",
"performance",
"wasm",
"woff2",
"ttf",
"otf",
"opentype-fonts",
"font-subsetter",
"font-subset",
"cjk"
],
"author": "KonghaYao<dongzhongzhidong@qq.com>",
"license": "Apache-2.0",
"dependencies": {
"@chinese-fonts/font-contours": "^1.0.0",
"@chinese-fonts/wawoff2": "2.0.5",
"@japont/unicode-range": "^1.0.0",
"@konghayao/harfbuzzjs": "8.3.1",
"@konghayao/opentype.js": "2024.3.19",
"@napi-rs/woff-build": "^0.2.0",
"byte-size": "^8.1.1",
"font-sharp": "workspace:^",
"fs-extra": "^11.1.1",
"md5": "^2.3.0",
"os-locale": "^6.0.2",
"tslog": "^4.9.2",
"workerpool": "^9.1.1"
},
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
"@types/byte-size": "^8.1.1",
"@types/md5": "^2.3.4",
"@types/opentype.js": "^1.3.7",
"@types/workerpool": "^6.4.5",
"@vitest/browser": "^1.6.0",
"comlink": "^4.4.1",
"live-server": "^1.2.2",
"path-browserify": "^1.0.1",
"resolve": "^1.22.8",
"vitest": "^1.6.0",
"webdriverio": "^8.20.4"
}
"name": "@konghayao/cn-font-split",
"version": "4.13.0",
"description": "中文 web font 切割工具",
"main": "dist/index.js",
"browser": "dist/browser/index.js",
"type": "module",
"bin": {
"cn-font-split": "bin/cn-font-split.mjs"
},
"repository": {
"type": "git",
"url": "https://github.com/KonghaYao/cn-font-split/tree/ts/packages/subsets"
},
"homepage": "https://chinese-font.netlify.app/",
"scripts": {
"build": "rollup -c ",
"dev": "rollup -c -w",
"build:browser": "rollup -c rollup.config.browser.mjs ",
"dev:browser": "rollup -c rollup.config.browser.mjs -w",
"test": "vitest",
"test:node": "node ./test/node.test.mjs",
"test:deno": "deno run -A --no-npm ./test/deno.test.js",
"test:bun": "bun run ./test/bun.test.mjs",
"test:browser": "live-server --port=9000 --cors --no-browser ./dist/browser&&vitest --mode browser test/browser.test.js",
"coverage": "vitest run --coverage",
"prepublish": "tsc && pnpm build && pnpm build:browser && tsc"
},
"keywords": [
"font",
"converter",
"performance",
"wasm",
"woff2",
"ttf",
"otf",
"opentype-fonts",
"font-subsetter",
"font-subset",
"cjk"
],
"author": "KonghaYao<dongzhongzhidong@qq.com>",
"license": "Apache-2.0",
"dependencies": {
"@chinese-fonts/font-contours": "^1.0.0",
"@chinese-fonts/wawoff2": "2.0.5",
"@japont/unicode-range": "^1.0.0",
"@konghayao/harfbuzzjs": "8.3.1",
"@konghayao/opentype.js": "2024.3.19",
"@napi-rs/woff-build": "^0.2.0",
"byte-size": "^8.1.1",
"font-sharp": "workspace:^",
"fs-extra": "^11.1.1",
"md5": "^2.3.0",
"os-locale": "^6.0.2",
"tslog": "^4.9.2",
"workerpool": "^9.1.1"
},
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
"@types/byte-size": "^8.1.1",
"@types/md5": "^2.3.4",
"@types/opentype.js": "^1.3.7",
"@types/workerpool": "^6.4.5",
"@vitest/browser": "^1.6.0",
"comlink": "^4.4.1",
"live-server": "^1.2.2",
"path-browserify": "^1.0.1",
"resolve": "^1.22.8",
"vitest": "^1.6.0",
"webdriverio": "^8.20.4"
}
}
33 changes: 17 additions & 16 deletions packages/vite/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
# 🔠 vite-plugin-cn-font-split
# 🔠 vite-plugin-font ⚡

[中文](./README_zh.md) | [english](./README.md)

[vite-plugin-cn-font-split](https://www.npmjs.com/package/vite-plugin-cn-font-split) is a font building tool for [Chinese web fonts project](https://chinese-font.netlify.app) supported by Vite. It can split large fonts into Webfonts, with powerful performance and simplicity. vite-plugin-cn-font-split is supported by [cn-font-split](https://www.npmjs.com/package/cn-font-split).
[vite-plugin-font](https://www.npmjs.com/package/vite-plugin-font) is a font building tool for [Chinese web fonts project](https://chinese-font.netlify.app) supported by Vite. It can split large fonts into Webfonts, with powerful performance and simplicity. vite-plugin-font is supported by [cn-font-split](https://www.npmjs.com/package/cn-font-split).

## 📦 Install

```sh
npm i -D vite-plugin-cn-font-split
npm i -D vite-plugin-font
```

```js
// vite.config.js
import { defineConfig } from 'vite';
import viteFont from 'vite-plugin-cn-font-split';
import viteFont from 'vite-plugin-font';
export default defineConfig({
plugins: [viteFont()],
plugins: [viteFont()],
});
```


```jsx
// Automatically inject CSS to import fonts, and support tree shaking optimization of font information!
import { css } from '../../demo/public/SmileySans-Oblique.ttf'; // Directly import font files
import { css } from '../../demo/public/SmileySans-Oblique.ttf'; // Directly import font files
console.log(css.family, css.weight); // You can get CSS-related data from here

export const App = ()=>{
return <div style={{
fontFamily: css.family
}}></div>
}

export const App = () => {
return (
<div
style={{
fontFamily: css.family,
}}
></div>
);
};
```

## Typescript Support
Expand All @@ -40,12 +42,11 @@ The source code includes the `src/font.d.ts` file, which you can add to your `ts
```ts
{
\"compilerOptions\": {
\"types\": [\"vite-plugin-cn-font-split/src/font.d\"]
\"types\": [\"vite-plugin-font/src/font.d\"]
}
}
```


## Input Parameters

Please refer to the usage instructions of [cn-font-split](https://www.npmjs.com/package/cn-font-split) for input parameters, most of which are common.
Please refer to the usage instructions of [cn-font-split](https://www.npmjs.com/package/cn-font-split) for input parameters, most of which are common.
32 changes: 16 additions & 16 deletions packages/vite/README_zh.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
# 🔠 vite-plugin-cn-font-split
# 🔠 vite-plugin-font ⚡

[中文](./README_zh.md) | [english](./README.md)

[中文网字计划](https://chinese-font.netlify.app) 开发支持的 vite 字体构建工具。 vite-plugin-cn-font-split 可以将庞大的字体切割成 Webfonts,性能强大且简单。vite-plugin-cn-font-split 由 [cn-font-split](https://www.npmjs.com/package/cn-font-split) 支持

[中文网字计划](https://chinese-font.netlify.app) 开发支持的 vite 字体构建工具。 vite-plugin-font 可以将庞大的字体切割成 Webfonts,性能强大且简单。vite-plugin-font 由 [cn-font-split](https://www.npmjs.com/package/cn-font-split) 支持

## 📦 Install

```sh
npm i -D vite-plugin-cn-font-split
npm i -D vite-plugin-font
```

```js
// vite.config.js
import { defineConfig } from 'vite';
import viteFont from 'vite-plugin-cn-font-split';
import viteFont from 'vite-plugin-font';
export default defineConfig({
plugins: [viteFont()],
});
```


```jsx
// 自动注入 css 导入字体,并且支持字体信息的摇树优化!
import { css } from '../../demo/public/SmileySans-Oblique.ttf'; // 直接 import 字体文件
import { css } from '../../demo/public/SmileySans-Oblique.ttf'; // 直接 import 字体文件
console.log(css.family, css.weight); // 你可以从这里得到 css 相关的数据

export const App = ()=>{
return <div style={{
fontFamily: css.family
}}></div>
}

export const App = () => {
return (
<div
style={{
fontFamily: css.family,
}}
></div>
);
};
```

## Typescript 支持
Expand All @@ -41,12 +42,11 @@ export const App = ()=>{
```ts
{
"compilerOptions": {
"types": ["vite-plugin-cn-font-split/src/font.d"]
"types": ["vite-plugin-font/src/font.d"]
}
}
```


## 输入参数

输入参数请见 [cn-font-split](https://www.npmjs.com/package/cn-font-split) 使用说明,大部分参数都是通用的。
输入参数请见 [cn-font-split](https://www.npmjs.com/package/cn-font-split) 使用说明,大部分参数都是通用的。
101 changes: 49 additions & 52 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@
{
"version": "0.1.0",
"name": "vite-plugin-cn-font-split",
"description": "Vite plugin for bundle otf,ttf... font to webfonts",
"main": "./dist/index.js",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/KonghaYao/cn-font-split.git"
},
"files": [
"dist",
"src"
],
"author": "KonghaYao<dongzhongzhidong@qq.com>",
"license": "Apache-2.0",
"scripts": {
"build": "tsc -p tsconfig.node.json",
"dev": "vite",
"prepublish": "pnpm build"
},
"keywords": [
"vite",
"vite-plugin",
"web-font",
"webfont",
"vue",
"react",
"converter",
"performance",
"wasm",
"woff2",
"ttf",
"otf",
"opentype-fonts",
"font-subsetter",
"font-subset",
"cjk"
],
"peerDependencies": {
"vite": "^2 || ^3 || ^4 || ^5"
},
"devDependencies": {
"vite": "^5"
},
"dependencies": {
"@konghayao/cn-font-split": "workspace:^"
},
"bugs": {
"url": "https://github.com/KonghaYao/cn-font-split/issues"
},
"homepage": "https://chinese-font.netlify.app"
}
"version": "0.2.0",
"name": "vite-plugin-font",
"description": "Vite plugin for bundle otf,ttf... font to webfonts",
"main": "./dist/index.js",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/KonghaYao/cn-font-split.git"
},
"files": ["dist", "src"],
"author": "KonghaYao<dongzhongzhidong@qq.com>",
"license": "Apache-2.0",
"scripts": {
"build": "tsc -p tsconfig.node.json",
"dev": "vite",
"prepublish": "pnpm build"
},
"keywords": [
"vite",
"vite-plugin",
"web-font",
"webfont",
"vue",
"react",
"converter",
"performance",
"wasm",
"woff2",
"ttf",
"otf",
"opentype-fonts",
"font-subsetter",
"font-subset",
"cjk"
],
"peerDependencies": {
"vite": "^2 || ^3 || ^4 || ^5"
},
"devDependencies": {
"vite": "^5"
},
"dependencies": {
"@konghayao/cn-font-split": "workspace:^"
},
"bugs": {
"url": "https://github.com/KonghaYao/cn-font-split/issues"
},
"homepage": "https://chinese-font.netlify.app"
}
2 changes: 1 addition & 1 deletion packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function split(
let viteConfig;
let cacheDir = config.cacheDir;
return <Plugin>{
name: 'vite-plugin-cn-font-split',
name: 'vite-plugin-font',
enforce: 'pre',
configResolved(c) {
viteConfig = c;
Expand Down

0 comments on commit 97169d3

Please sign in to comment.