Skip to content

Commit

Permalink
feat(subsets): add font-sharp deps
Browse files Browse the repository at this point in the history
  • Loading branch information
KonghaYao committed Mar 23, 2024
1 parent a4901cb commit db38931
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 84 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 中文 Web Font 切割工具

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

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

> 我们正在对 cn-font-split 的实战效果进行测试,并积极提升分包效果!
>
> [Opentype Feature 测试情况](/packages/test/SUPPORT_FEATURE.md) 支持 95 | 部分支持 9| 等待测试 20
> [Opentype Feature 支持情况](/packages/test/SUPPORT_FEATURE.md) 支持 95 | 部分支持 9| 等待测试 20
[详见兼容性章节](#兼容性提醒)
| [Nodejs](#nodejs) | [Deno](#deno) | [Chrome](#browser) | [FireFox](#browser) | [Safari](#browser) | [Bun](#bun) |
Expand Down
9 changes: 4 additions & 5 deletions packages/subsets/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 中文 Web Font 切割工具

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

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

> 我们正在对 cn-font-split 的实战效果进行测试,并积极提升分包效果!
>
> [Opentype Feature 测试情况](/packages/test/SUPPORT_FEATURE.md) 支持 95 | 部分支持 9| 等待测试 20
> [Opentype Feature 支持情况](/packages/test/SUPPORT_FEATURE.md) 支持 95 | 部分支持 9| 等待测试 20
[详见兼容性章节](#兼容性提醒)
| [Nodejs](#nodejs) | [Deno](#deno) | [Chrome](#browser) | [FireFox](#browser) | [Safari](#browser) | [Bun](#bun) |
Expand Down
5 changes: 3 additions & 2 deletions packages/subsets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@konghayao/cn-font-split",
"version": "4.11.3",
"version": "4.12.0",
"description": "中文 web font 切割工具",
"main": "dist/index.js",
"browser": "dist/browser/index.js",
Expand Down Expand Up @@ -41,12 +41,13 @@
"license": "Apache-2.0",
"dependencies": {
"@chinese-fonts/font-contours": "^1.0.0",
"@japont/unicode-range": "^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.1.1",
"byte-size": "^8.1.1",
"font-sharp": "workspace:^",
"fs-extra": "^11.1.1",
"md5": "^2.3.0",
"os-locale": "^6.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/subsets/src/hb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export declare namespace HB {
export function hbjs(instance: WebAssembly.Instance) {
'use strict';

const exports = instance.exports as ANY;
const exports = instance.exports as any;
const heapu8 = new Uint8Array(exports.memory.buffer);
const heapu32 = new Uint32Array(exports.memory.buffer);
const heapi32 = new Int32Array(exports.memory.buffer);
Expand Down
2 changes: 1 addition & 1 deletion packages/subsets/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Latin, getCN_SC_Rank } from './data/Ranks';
import { Assets } from './adapter/assets';
import { env } from './utils/env';
import { ConvertManager } from './convert/convert.manager';
import { makeImage } from './makeImage/index';
import { makeImage } from 'font-sharp/dist/font-sharp/src/makeImage.js';
import { getFeatureData, getFeatureMap } from './subsetService/featureMap';
import { forceSubset } from './subsetService/forceSubset';
import { calcContoursBorder } from './useSubset/calcContoursBorder';
Expand Down
50 changes: 0 additions & 50 deletions packages/subsets/src/makeImage/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/subsets/test/node.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import crypto from 'node:crypto'
fs.emptyDirSync('./temp/node');
fontSplit({
destFold: './temp/node',
// FontPath: '../demo/public/SmileySans-Oblique.ttf',
FontPath: './test/temp/NotoColorEmoji.ttf',
FontPath: '../demo/public/SmileySans-Oblique.ttf',
// FontPath: './test/temp/NotoColorEmoji.ttf',
// FontPath: './test/temp/MaokenAssortedSans1.30.ttf',
// FontPath: './test/temp/字魂扁桃体.ttf',
// FontPath: './test/temp/京華老宋体v1.007.ttf',
Expand Down
38 changes: 38 additions & 0 deletions packages/subsets/test/shape.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import fs from 'fs-extra';
import { fontSplit } from '../dist/index.js';
import crypto from 'node:crypto'

fs.emptyDirSync('./temp/node');
fontSplit({
destFold: './temp/node',
// FontPath: '../demo/public/SmileySans-Oblique.ttf',
FontPath: './test/temp/Yozai-Light.ttf',// 不折行问题
FontPath: './test/temp/qiji-fallback.ttf',// 大小问题
FontPath: './test/temp/随峰体.ttf',// 大小问题

targetType: 'woff2',
// subsets: JSON.parse(await fs.readFile("./subsets/misans.json", "utf-8")),
previewImage: {},
chunkSize: 70 * 1024,
css: {
// fontWeight: false
// localFamily: false,
// comment: false,
// comment: {
// base: false,
// nameTable: false,
// unicodes: true
// }
}
// autoChunk: false,
// subsets: [[31105, 8413]],
// threads: {},
// renameOutputFont: '[hash:10][ext]',
// renameOutputFont: '[index][ext]',
// renameOutputFont({ transferred, ext, index }) {
// const algorithm = 'sha256'
// const hash = crypto.createHash(algorithm).update(transferred).digest('hex')
// // return index.toString() + ext // index 命名
// return hash.slice(0, 6) + ext // 短 hash 命名
// }
});
51 changes: 34 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

// "types": ["./src/env", "./src/global"],
"types": ["node"],

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

0 comments on commit db38931

Please sign in to comment.