mirror of
https://github.com/2234839/web-font.git
synced 2026-09-04 14:53:32 +08:00
千字文 ttf 0.396ms→0.252ms(-36%),woff2 不受影响(不走 node Buffer 路径)。 Writer 的 ArrayBuffer 精确分配为 ttfSize(offset=0),getBuffer 返回完整 buffer, Buffer.from 共享底层内存无 over-exposure 风险。SSIM 全部不变。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9 lines
629 B
TypeScript
9 lines
629 B
TypeScript
import { readFileSync } from 'fs';
|
|
import { fontSubset } from './backend/font_util/font.js';
|
|
const buf = readFileSync('font/令东齐伋复刻体.ttf');
|
|
const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
const text = '天地玄黄宇宙洪荒日月盈昃辰宿列张寒来暑往秋收冬藏闰余成岁律吕调阳云腾致雨露结为霜金生丽水玉出昆冈剑号巨阙珠称夜光果珍李柰菜重芥姜海咸河淡鳞潜羽翔';
|
|
fontSubset(ab, text, { sourceType: 'ttf', outType: 'ttf' });
|
|
const N = 500;
|
|
for (let i = 0; i < N; i++) fontSubset(ab, text, { sourceType: 'ttf', outType: 'ttf' });
|