npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unocss-preset-chinese

v0.3.2

Published

[![CI][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript_code style][code-style-image]][code-style-url]

Downloads

966

Readme

unocss-preset-chinese

CI npm downloads javascript_code style

简介

这是一个旨在优化中文网站或应用程序字体显示的项目。 通过使用这个项目,您可以获得一个默认的字体排列方案,以确保在没有指定字体的情况下,页面中选择的字体尽可能符合中文阅读的要求。 这个项目的字体排列方案是基于中文阅读体验的考虑,它优先选择在中文环境中广泛使用和受欢迎的字体,并根据字体支持的字形、符号以及跨平台支持来确定字体的优先级顺序。

功能

提供多种字体排列方案,以适应不同类型的中文字符(简体或繁体)。 支持中英文混排,有效避免中文标点符号受英文字体影响。

如何使用

  1. 使用 npm 或 pnpm 安装 unocss 和 unocss-preset-chinese:
npm install unocss unocss-preset-chinese --save-dev
  1. 在您的 UnoCss 配置文件中引入 unocss-preset-chinese 并将其添加到 presets 部分:
// unocss.config.js
import presetChinese from "unocss-preset-chinese";
import { defineConfig, presetUno } from "unocss";

export default defineConfig({
  presets: [
    presetUno(),
    presetChinese({
      chineseType: "simplified", // 指定文本为简体中文
    }),
    // ...custom presets
  ],
});

配置选项

您可以使用以下配置选项来自定义字体排列方案:

  • extendTheme (boolean, 默认值: true): 是否扩展主题对象。

  • themeKey (string, 默认值: "fontFamily"): 主题对象的键。

  • fonts (Record<string, string | string[]>): 扩展字体,您可以指定不同的字体和字体权重。

  • chineseType (ChineseType, 默认值: "simplified"): 中文的类型,可选值为 "simplified"(简体)或 "traditional"(繁体)。

  • fallbackFont (string[] | null): 用于中文字符的备选字体。

  • declareEnglishFont (string[]): 声明英文文本的字体。

示例

以下是一个示例配置,演示如何使用这些选项来自定义字体排列方案:

import presetChinese from "unocss-preset-chinese";
import { defineConfig, presetUno } from "unocss";

export default defineConfig({
  presets: [
    presetUno(),
    presetChinese({
      extendTheme: false, // 不扩展主题对象
      themeKey: 'customFontFamily', // 使用自定义的主题键
      chineseType: "traditional", // 指定文本为繁体中文
    }),
    // ...custom presets
  ],
});

License

MIT License © 2022-PRESENT Kirk Lin