Skip to content

Commit db38931

Browse files
committed
feat(subsets): add font-sharp deps
1 parent a4901cb commit db38931

File tree

10 files changed

+88
-84
lines changed

10 files changed

+88
-84
lines changed

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# 中文 Web Font 切割工具
22

3-
![updateTime](https://img.shields.io/badge/更新时间-2024/03/19-green)
3+
![updateTime](https://img.shields.io/badge/更新时间-2024/03/23-green)
44
![author](https://img.shields.io/badge/author-江夏尧-green)
5-
![npmVersion](https://img.shields.io/badge/LTS_version-4.11.2-green)
5+
![npmVersion](https://img.shields.io/badge/LTS_version-4.12.0-green)
66
[![](https://data.jsdelivr.com/v1/package/npm/@konghayao/cn-font-split/badge)](https://www.jsdelivr.com/package/npm/@konghayao/cn-font-split)
77

88
![CodeFactor](https://www.codefactor.io/repository/github/konghayao/cn-font-split/badge)
@@ -19,10 +19,9 @@
1919
- 🚀 `自研多线程`+ (`WebAssembly``Native`) 分包速度极快;
2020
- 💻 坚持 Web 平台为基底,兼容性极强,浏览器、Node、Deno,统统可以运行。
2121
- 🔧 功能齐全完备,支持生成文字图片预览,支持完整全字符,支持复杂字形!
22+
- ⛰️ 自研 Harfbuzz 文本 SVG 引擎,独立渲染文本。
2223

23-
> 我们正在对 cn-font-split 的实战效果进行测试,并积极提升分包效果!
24-
>
25-
> [Opentype Feature 测试情况](/packages/test/SUPPORT_FEATURE.md) 支持 95 | 部分支持 9| 等待测试 20
24+
> [Opentype Feature 支持情况](/packages/test/SUPPORT_FEATURE.md) 支持 95 | 部分支持 9| 等待测试 20
2625
2726
[详见兼容性章节](#兼容性提醒)
2827
| [Nodejs](#nodejs) | [Deno](#deno) | [Chrome](#browser) | [FireFox](#browser) | [Safari](#browser) | [Bun](#bun) |

packages/subsets/README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# 中文 Web Font 切割工具
22

3-
![updateTime](https://img.shields.io/badge/更新时间-2024/03/19-green)
3+
![updateTime](https://img.shields.io/badge/更新时间-2024/03/23-green)
44
![author](https://img.shields.io/badge/author-江夏尧-green)
5-
![npmVersion](https://img.shields.io/badge/LTS_version-4.11.2-green)
5+
![npmVersion](https://img.shields.io/badge/LTS_version-4.12.0-green)
66
[![](https://data.jsdelivr.com/v1/package/npm/@konghayao/cn-font-split/badge)](https://www.jsdelivr.com/package/npm/@konghayao/cn-font-split)
77

88
![CodeFactor](https://www.codefactor.io/repository/github/konghayao/cn-font-split/badge)
@@ -19,10 +19,9 @@
1919
- 🚀 `自研多线程`+ (`WebAssembly``Native`) 分包速度极快;
2020
- 💻 坚持 Web 平台为基底,兼容性极强,浏览器、Node、Deno,统统可以运行。
2121
- 🔧 功能齐全完备,支持生成文字图片预览,支持完整全字符,支持复杂字形!
22+
- ⛰️ 自研 Harfbuzz 文本 SVG 引擎,独立渲染文本。
2223

23-
> 我们正在对 cn-font-split 的实战效果进行测试,并积极提升分包效果!
24-
>
25-
> [Opentype Feature 测试情况](/packages/test/SUPPORT_FEATURE.md) 支持 95 | 部分支持 9| 等待测试 20
24+
> [Opentype Feature 支持情况](/packages/test/SUPPORT_FEATURE.md) 支持 95 | 部分支持 9| 等待测试 20
2625
2726
[详见兼容性章节](#兼容性提醒)
2827
| [Nodejs](#nodejs) | [Deno](#deno) | [Chrome](#browser) | [FireFox](#browser) | [Safari](#browser) | [Bun](#bun) |

packages/subsets/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@konghayao/cn-font-split",
3-
"version": "4.11.3",
3+
"version": "4.12.0",
44
"description": "中文 web font 切割工具",
55
"main": "dist/index.js",
66
"browser": "dist/browser/index.js",
@@ -41,12 +41,13 @@
4141
"license": "Apache-2.0",
4242
"dependencies": {
4343
"@chinese-fonts/font-contours": "^1.0.0",
44-
"@japont/unicode-range": "^1.0.0",
4544
"@chinese-fonts/wawoff2": "2.0.5",
45+
"@japont/unicode-range": "^1.0.0",
4646
"@konghayao/harfbuzzjs": "8.3.1",
4747
"@konghayao/opentype.js": "2024.3.19",
4848
"@napi-rs/woff-build": "^0.1.1",
4949
"byte-size": "^8.1.1",
50+
"font-sharp": "workspace:^",
5051
"fs-extra": "^11.1.1",
5152
"md5": "^2.3.0",
5253
"os-locale": "^6.0.2",

packages/subsets/src/hb.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export declare namespace HB {
5555
export function hbjs(instance: WebAssembly.Instance) {
5656
'use strict';
5757

58-
const exports = instance.exports as ANY;
58+
const exports = instance.exports as any;
5959
const heapu8 = new Uint8Array(exports.memory.buffer);
6060
const heapu32 = new Uint32Array(exports.memory.buffer);
6161
const heapi32 = new Int32Array(exports.memory.buffer);

packages/subsets/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Latin, getCN_SC_Rank } from './data/Ranks';
1414
import { Assets } from './adapter/assets';
1515
import { env } from './utils/env';
1616
import { ConvertManager } from './convert/convert.manager';
17-
import { makeImage } from './makeImage/index';
17+
import { makeImage } from 'font-sharp/dist/font-sharp/src/makeImage.js';
1818
import { getFeatureData, getFeatureMap } from './subsetService/featureMap';
1919
import { forceSubset } from './subsetService/forceSubset';
2020
import { calcContoursBorder } from './useSubset/calcContoursBorder';

packages/subsets/src/makeImage/index.ts

-50
This file was deleted.

packages/subsets/test/node.test.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import crypto from 'node:crypto'
55
fs.emptyDirSync('./temp/node');
66
fontSplit({
77
destFold: './temp/node',
8-
// FontPath: '../demo/public/SmileySans-Oblique.ttf',
9-
FontPath: './test/temp/NotoColorEmoji.ttf',
8+
FontPath: '../demo/public/SmileySans-Oblique.ttf',
9+
// FontPath: './test/temp/NotoColorEmoji.ttf',
1010
// FontPath: './test/temp/MaokenAssortedSans1.30.ttf',
1111
// FontPath: './test/temp/字魂扁桃体.ttf',
1212
// FontPath: './test/temp/京華老宋体v1.007.ttf',

packages/subsets/test/shape.mjs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import fs from 'fs-extra';
2+
import { fontSplit } from '../dist/index.js';
3+
import crypto from 'node:crypto'
4+
5+
fs.emptyDirSync('./temp/node');
6+
fontSplit({
7+
destFold: './temp/node',
8+
// FontPath: '../demo/public/SmileySans-Oblique.ttf',
9+
FontPath: './test/temp/Yozai-Light.ttf',// 不折行问题
10+
FontPath: './test/temp/qiji-fallback.ttf',// 大小问题
11+
FontPath: './test/temp/随峰体.ttf',// 大小问题
12+
13+
targetType: 'woff2',
14+
// subsets: JSON.parse(await fs.readFile("./subsets/misans.json", "utf-8")),
15+
previewImage: {},
16+
chunkSize: 70 * 1024,
17+
css: {
18+
// fontWeight: false
19+
// localFamily: false,
20+
// comment: false,
21+
// comment: {
22+
// base: false,
23+
// nameTable: false,
24+
// unicodes: true
25+
// }
26+
}
27+
// autoChunk: false,
28+
// subsets: [[31105, 8413]],
29+
// threads: {},
30+
// renameOutputFont: '[hash:10][ext]',
31+
// renameOutputFont: '[index][ext]',
32+
// renameOutputFont({ transferred, ext, index }) {
33+
// const algorithm = 'sha256'
34+
// const hash = crypto.createHash(algorithm).update(transferred).digest('hex')
35+
// // return index.toString() + ext // index 命名
36+
// return hash.slice(0, 6) + ext // 短 hash 命名
37+
// }
38+
});

pnpm-lock.yaml

+34-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
5656
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
5757

58-
// "types": ["./src/env", "./src/global"],
58+
"types": ["node"],
5959

6060
/* Source Map Options */
6161
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */

0 commit comments

Comments
 (0)