@docx-editor.dev/fonts-cjk

中文文档
2.38.0发布于 2026/11/16Apache-2.0 AND OFL-1.1TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 12.8万

Noto Sans CJK JP fallback font for Chinese, Japanese, and Korean text in @docx-editor.dev/docx-to-pdf and the editor.

原始使用文档
文档目录7 节
  1. Install
  2. Font selection
  3. Deploy the package
  4. Use the font in the editor
  5. Use the font directly
  6. Coverage and limits
  7. Licenses

DOCX Editor by EigenPal

@docx-editor.dev/fonts-cjk

This package supplies Noto Sans CJK JP for Chinese, Japanese, and Korean text. The @docx-editor.dev/docx-to-pdf package uses it as an optional fallback, and the editor uses it through the cjkFonts() resolver. The font file is about 16 MB, so it ships separately.

Install

Use Node.js ^20.16.0 || >=22.3.0. Install the package with the PDF converter and its required engine peer:

npm install @docx-editor.dev/docx-to-pdf @docx-editor.dev/core @docx-editor.dev/fonts-cjk

The converter declares @docx-editor.dev/fonts-cjk as an optional peer dependency. Use versions that satisfy the converter's peer dependency ranges. PDF export finds the package without configuration and reads its font from disk. It makes no network request for the font.

Font selection

PDF export uses this font when earlier sources lack the requested CJK family or characters. Your fonts, enabled system fonts, packaged substitutes, and fallbackFonts sources take priority. This font resolves before document-embedded fonts and lastResortFonts. For the complete order, see Configure PDF fonts.

The default glyph fallback list includes this font. If you supply glyphFallbacks, your list replaces the defaults. For this fallback, add an entry with family: NOTO_SANS_CJK_JP_FAMILY, weight: 400, and style: 'normal'.

You can omit this package when installed or supplied fonts cover your CJK text. Installed fonts such as SimSun, Batang, and MS Gothic take priority when useSystemFonts is true. If no font covers a CJK character, export reports a missing-glyph diagnostic. When this package is absent, the diagnostic names it. Strict export fails for missing glyphs.

Deploy the package

Add the package to your production dependencies. Keep it external to your server bundle so Node.js can resolve it at runtime. Retain its dist/ and assets/ directories in their package locations. Include its license files when distributing the package.

An installed package with missing or unreadable font assets reports font-origin-failed. Inspect result.fontResolution.originFailures to find the cause. Setting fontPolicy: 'strict' rejects these source failures.

For deployment examples, see Integrate PDF conversion.

Use the font in the editor

For a browser editor, install this package alongside your existing editor dependencies:

npm install @docx-editor.dev/fonts-cjk

The @docx-editor.dev/fonts-cjk/browser entry exports cjkFonts(), a font resolver with the same shape as packagedFonts() and googleFonts() from @docx-editor.dev/fonts. Put it after the origins whose fonts you prefer:

import { packagedFonts } from '@docx-editor.dev/fonts';
import { googleFonts } from '@docx-editor.dev/fonts/google';
import { cjkFonts } from '@docx-editor.dev/fonts-cjk/browser';

const fonts = [packagedFonts(), googleFonts(), cjkFonts()];

The first paint does not wait for this download. The editor paints the document with its other fonts, then lays it out again when this font arrives. To install it with the other fonts instead, pass cjkFonts({ loading: 'wait' }). A document export that receives this resolver always waits for the font.

If you can load fonts from a third party, googleFonts({ cjk: true }) from @docx-editor.dev/fonts/google is an alternative. It loads a smaller regional face for each language a document uses. Do not combine cjk: true with cjkFonts(): both fonts would download, and the origin listed first would paint.

The resolver downloads the font only when a document names one of the CJK_SUBSTITUTED_FAMILIES, or one of their localized names in LOCALIZED_CJK_FAMILIES. Your bundler emits the font file as an asset, and the resolver fetches it from there. No request goes to a third party. The browser entry is ECMAScript modules only, because it finds the file through import.meta.url.

A failed download calls the onFailure option, or writes a console warning. The document then keeps its other fonts.

Use the font directly

The Node.js entry has these public exports:

ExportTypeValue
NOTO_SANS_CJK_JP_FAMILYString literal'Noto Sans CJK JP'
NOTO_SANS_CJK_JP_URLURLA file: URL for assets/NotoSansCJKjp-Regular.otf.
CJK_SUBSTITUTED_FAMILIESreadonly string[]The East Asian families the font stands in for.
LOCALIZED_CJK_FAMILIESReadonlyMap<string, string>Localized family names, mapped to their English names.

Use the exported URL to read the font without constructing a package path:

import { readFile } from 'node:fs/promises';
import { NOTO_SANS_CJK_JP_FAMILY, NOTO_SANS_CJK_JP_URL } from '@docx-editor.dev/fonts-cjk';

const bytes = await readFile(NOTO_SANS_CJK_JP_URL);
console.log(NOTO_SANS_CJK_JP_FAMILY, bytes.byteLength);

The Node.js entry does not bundle the font into JavaScript or install a browser font.

Coverage and limits

  • The package includes one OpenType font with CFF outlines: Noto Sans CJK JP Regular.
  • Its weight is 400, and its style is 'normal'.
  • It supplies the Japanese regional face, without separate Chinese or Korean regional faces.
  • PDF export can synthesize bold and italic from this regular face.
  • Substituting this font can change glyph forms, line breaks, and page counts.
  • Characters outside the font's coverage still require another font.

Supply your own font through the converter's fonts option when you need a specific regional face or designed style.

Licenses

The package code uses the Apache License 2.0. For more information, see LICENSE. The PDF converter uses the separate EigenPal Pro License.

The font uses the SIL Open Font License, Version 1.1. The license text is in licenses/NotoSansCJK-OFL.txt.

The font file is the unmodified upstream binary. assets/sources.json records its source URL and SHA-256 hash. PDF export embeds only the glyphs that the document uses.

版本与发布记录

@docx-editor.dev/fonts-cjk 共发布 29 个版本,首次发布于 2026/09/28;过去 12 个月发布了 29 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.38.0latest2026/11/16今天
2.38.0-canary.20261116033356.sha-2662bd1canary2026/11/16今天
2.38.0-canary.20261115032819.sha-05856f62026/11/151 天前
2.38.0-canary.20261114032659.sha-cdc64af2026/11/142 天前
2.38.0-canary.20261113032851.sha-e2cbc552026/11/133 天前
2.37.02026/11/115 天前

其他发布通道:bootstrap → 0.0.1,canary → 2.38.0-canary.20261116033356.sha-2662bd1。

关于 @docx-editor.dev/fonts-cjk 的常见问题

@docx-editor.dev/fonts-cjk 是什么?

Noto Sans CJK JP fallback font for Chinese, Japanese, and Korean text in @docx-editor.dev/docx-to-pdf and the editor.

如何安装 @docx-editor.dev/fonts-cjk?

在项目目录运行 npm install @docx-editor.dev/fonts-cjk,或使用 pnpm add / yarn add / bun add。

@docx-editor.dev/fonts-cjk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@docx-editor.dev/fonts-cjk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@docx-editor.dev/fonts-cjk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^20.16.0 || >=22.3.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@docx-editor.dev/fonts-cjk 可以商用吗?

@docx-editor.dev/fonts-cjk 使用 Apache-2.0 AND OFL-1.1 许可。声明的许可为 Apache-2.0 AND OFL-1.1,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@docx-editor.dev/fonts-cjk 的下载量有多少?

根据 npm 官方下载统计,@docx-editor.dev/fonts-cjk 在 2026/10/13 – 2026/11/11 这 30 天内被下载 127,797 次,日均约 4,260 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@docx-editor.dev/fonts-cjk 还在维护吗?

最新版本 2.38.0 发布于 2026/11/16(今天);至今共发布 29 个版本,其中过去 12 个月发布了 29 个;首次发布于 2026/09/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。