# Cjk全字符集与汉字拼形 网页应用模块

**URL:** <https://forum.freemdict.com/t/topic/13651>\
**Category:** 技术交流与词典编修\
**Tags:** 汉字, 缺字, 电子书\
**Created:** [2022 年6 月 17 日 13:37 UTC](https://forum.freemdict.com/t/topic/13651 "2022-06-17T13:37:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

作者： ![accelon](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/accelon/32/27309_2.png) [@accelon](https://forum.freemdict.com/u/accelon)\
发布日期： [2022 年6 月 17 日 13:37 UTC](https://forum.freemdict.com/t/topic/13651/1 "2022-06-17T13:37:15Z")

</div>

本模块让基於HTML+JS的应用（包括离线的电子书阅读软件）轻松地加入显示超大字集(扩A到G）和拼形组字功能。商业运用是受到鼓励的。

[在线演示](https://hanziku.github.io/hzpx-engine/index.html) Github ／ [腾讯](https://www.nissaya.cn/hzpx-engine/index.html)

[网页插件离线包 1.8MB](https://github.com/accelon/hzpx-engine/releases/tag/debute) Github／ [腾讯](https://www.nissaya.cn/releases/hzpx-purehtml-20220618.zip)  
`插件的工作原理是，每一个网页加载字库後，程序会找出含有 hzpx class name 的元素，找出里头的拼形式或扩区字，调用组字系统产生SVG 填入。因为Chrome 的每个页面都是独立的内存空间，每个页面都要载入字库，大约增加10MB的开销。`

纯文本显示需用[浏览器扩充程序安裝包](https://github.com/accelon/hzpx-extension/releases/tag/debute)Github含组字介面 ／[腾讯](https://www.nissaya.cn/releases/hzpx-extension-20220618.zip)  
`扩充程序的工作原理，会处理http/https/file 这三个协议，以 html/htm/txt 後缀的文件，其中html/htm 一样是找 class name 为 hzpx 的元素，纯文本则是整体替代。擴充程序安裝後不會再訪問網路，字形產生是背景service worker負責，速度很快，多个页面可共享字库，不会增加内存开销`

不依赖任何前端框架，只须最基础的html+css 知识即可调用。即使您不需要组字的功能，您只须添加css，即可让您的软件显示全字符集(CJK 扩A~G）。

全字符集的字型通常较大，绝大多数的字在文章中是看不到的。为了寥寥无几的缺字，要付出安装包肥大和载入字型文件的内存的代价。改用生成的方式，大量显示固然比不上字型档迅速，但少量显示很合适。

更新 20220618： index.html 去掉script ，只要在需組字的元素的css class 加上 “hzpx” 即可自動替換。  
纯文本的场合，必须用扩充程序，因为txt 无法加载 javascript 。

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2022 年6 月 18 日 06:20 UTC](https://forum.freemdict.com/t/topic/13651/2 "2022-06-18T06:20:54Z")

</div>

国内访问可以直接用jsdelivr的静态链接，目前访问良好，只需要提交到npm上就可以了。

> **[jsDelivr - A free, fast, and reliable CDN for JS and Open Source](https://www.jsdelivr.com/)**
>
> Optimized for JS and ESM delivery from npm and GitHub. Works with all web formats. Serving more than 150 billion requests per month. Built for production use.

国内的静态资源cdn主要同步cdnjs的资源。

先把资源提交到：

> **[cdnjs - The #1 free and open source CDN built to make life easier for developers](https://cdnjs.com/)**
>
> Simple. Fast. Reliable. Content delivery at its finest. cdnjs is a free and open-source CDN service trusted by over 12.5% of all websites, serving over 200 billion requests each month, powered by Cloudflare. We make it faster and easier to load...

之后国内的cdn会同步的。比如字节跳动的公共资源库：

> **[字节跳动静态资源公共库](http://cdn.bytedance.com/)**
>
> 字节跳动静态资源库支持多协议、资源动态拼接、快速检索及资源的动态更新,安全、稳定、实时。

---

<div class="post-metadata">

作者： ![accelon](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/accelon/32/27309_2.png) [@accelon](https://forum.freemdict.com/u/accelon)\
发布日期： [2022 年6 月 18 日 06:41 UTC](https://forum.freemdict.com/t/topic/13651/3 "2022-06-18T06:41:23Z")

</div>

谢谢，等功能稳定一些再上传到 CDN 。
