fonts-packages/npm-package
xianyu 5558779c0c chore: 更新 package.json 和 README.md 文件
- 升级版本号至 1.0.9
- 简化 package.json 中的 exports 和 files 配置
- 移除 README.md 中的中文翻译,仅保留英文文档
2025-11-28 17:09:32 +08:00
..
fonts chore(project-setup): Reorganize project structure and simplify documentation 2025-11-25 15:00:50 +08:00
scripts feat(npm-package): 添加字体数据优化和模块化支持 2025-11-28 17:06:44 +08:00
src chore: 更新 package.json 和 README.md 文件 2025-11-28 17:09:32 +08:00
.npmignore feat(npm-package): 添加字体数据优化和模块化支持 2025-11-28 17:06:44 +08:00
package-lock.json feat(npm-package): 添加字体数据优化和模块化支持 2025-11-28 17:06:44 +08:00
package.json chore: 更新 package.json 和 README.md 文件 2025-11-28 17:09:32 +08:00
README.md chore: 更新 package.json 和 README.md 文件 2025-11-28 17:09:32 +08:00

Chinese Fonts CDN

A collection of Chinese web fonts with CDN links and comprehensive license information.

Installation

npm i @windfonts/chinese-fonts

Usage

Simply import and the font will be automatically loaded:

// Import and auto-load with default subset (zh-common)
const { loadFont } = require('@windfonts/chinese-fonts');

// Load a font (returns Promise)
loadFont('Albbpht-Bold').then(cssUrl => {
  console.log('Font loaded:', cssUrl);
  // Font is now available to use
});

// Load with specific subset
loadFont('Albbpht-Bold', { subset: 'zh-common' });

// Load with preload for better performance
loadFont('Albbpht-Bold', { subset: 'zh-common', preload: true });

Method 2: Individual Font Import

Import specific fonts directly:

// Import a specific font
const font = require('@windfonts/chinese-fonts/fonts/Albbpht-Bold');

// Load the font (auto-loads with default subset)
font().then(cssUrl => {
  console.log('Font loaded:', cssUrl);
});

// Or with options
font({ subset: 'en' }).then(cssUrl => {
  console.log('English subset loaded:', cssUrl);
});

// Access font information
console.log(font.fontName);  // Font name
console.log(font.info);      // Full font information
console.log(font.getSubsets()); // Available subsets
console.log(font.getCSS('zh-common')); // Get CSS URL without loading

Method 3: Manual CSS URL

Get the CSS URL without auto-loading:

const { getFontCSS, getFontSubsets } = require('@windfonts/chinese-fonts');

// Get CSS URL
const cssUrl = getFontCSS('Albbpht-Bold', 'zh-common');
console.log(`CSS URL: ${cssUrl}`);

// Get available subsets
const subsets = getFontSubsets('Albbpht-Bold');
console.log(`Available subsets: ${subsets.join(', ')}`);

// Manually add to HTML
// <link rel="stylesheet" href="${cssUrl}">

License Information API

This package provides comprehensive license information for each font:

const { getLicenseType, getLicenseUrl, getUsageRights } = require('@windfonts/chinese-fonts');

// Get license type
const licenseType = getLicenseType('FontName');
console.log(`License: ${licenseType}`); // e.g., 'OFL', 'MIT', 'Apache-2.0'

// Get license file URL
const licenseUrl = getLicenseUrl('FontName');
console.log(`License URL: ${licenseUrl}`);

// Get detailed usage rights
const rights = getUsageRights('FontName');
console.log(`Commercial use: ${rights.commercial}`);
console.log(`Modification: ${rights.modification}`);
console.log(`Distribution: ${rights.distribution}`);
console.log(`Private use: ${rights.privateUse}`);

Available Fonts

This package includes 169 fonts:

Alibaba-PuHuiTi-B

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Albbpht/Bold/zh-common/result.css">

Alibaba-PuHuiTi-H

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Albbpht/Heavy/zh/result.css">

Alibaba-PuHuiTi-L

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Albbpht/Light/zh-common/result.css">

Alibaba-PuHuiTi-M

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Albbpht/Medium/en/result.css">

Alibaba-PuHuiTi-R

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Albbpht/Regular/zh-common/result.css">

AliHYAiHei

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Alhyznht/Regular/zh/result.css">

AlimamaDongFangDaKai

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Almmdfdk/Regular/zh/result.css">

Alimama DaoLiTi

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Almmdlt/Regular/zh-common/result.css">

Alimama ShuHeiTi

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Almmsht/Bold/zh/result.css">

Droid Sans Fallback

Usage:

<link rel="stylesheet" href="https://cn.windfonts.com/fonts-packages/Azbzzwzt/Regular/zh/result.css">

... and 159 more fonts.

TypeScript Support

This package includes TypeScript type definitions:

import { FontInfo, UsageRights, getAllFonts, getFontInfo } from '@windfonts/chinese-fonts';

const fonts: string[] = getAllFonts();
const fontInfo: FontInfo | undefined = getFontInfo('FontName');

License

Each font has its own license. Please check the license information for each font before use.

Contributing

To add new fonts or update existing ones, please submit a pull request to the repository.