2d42c7ecf2
從零重寫之第一垂直切片(依 ARCHITECTURE.md 契約),涵蓋並超越 v1 全部功能。 核心基座(src/core):unicode 字元表+標點子類+字形側位;locale 語言與 全角/開明政策(全域 lang.style +逐 lang policy);dom(jz-* 工廠+可還原 標記);finder 遍歷引擎(avoid/scope.include/邏輯 run/pill 鄰字/分塊閘); pass 聚合管線。 功能 pass(src/typeset): - spacing:中西間隙採 margin 模型——包裹邊界左側字、以 margin-right 留隙, 不注入空白字元(textContent 完全不變、複製緊湊、justify 不暴增、不撐框、 行首乾淨)。含跨樣式邊界、pill、原檔空格移除。 - gapTrim(lineedge):layout pass,行末去隙,修正 justify 右緣內縮。 - longword:長英文詞 <span lang> + hyphens。 - jiya:標點 charify + 全角/開明/半角(全域 + 逐 lang);半形以字型 OpenType halt 渲染(按字形正確定位、不重疊,居中字形 !? 與繁體 locl 句逗點號皆正確); 行內連續擠壓。 - jinze:行首行末避頭尾(閉類/點號綁前字、開類綁後字,以詞元為邊界、長引文 中段可斷);亦為 justify 綁定載體。 - lineedge:行端擠壓 layout pass(括號引號;ResizeObserver 重算,瀏覽器專用)。 §8 justify:jz-char inline-block 原子,句末標點單份間距。 v1 相容層(compat/v1):createCjkAutospace().apply 映射,IIFE 全域別名。 構建:esbuild → ESM/IIFE/CSS;tsc → d.ts。測試:39 個 jsdom 案例。 demo:簡繁並列+justify+強制繁體開明+標點寬度量測,載 Noto webfont 作參考 (擠壓依賴字型 halt)。間隔號 · 不觸發中西間隙;200% 等詞元不被禁則切斷。
80 lines
1.3 KiB
CSS
80 lines
1.3 KiB
CSS
/* src/css/_normalize.css */
|
|
@supports (text-autospace: no-autospace) {
|
|
.juzhen {
|
|
text-autospace: no-autospace;
|
|
}
|
|
}
|
|
jz-char,
|
|
jz-inner,
|
|
jz-hws,
|
|
jz-cs,
|
|
jz-jinze,
|
|
jz-em {
|
|
font: inherit;
|
|
color: inherit;
|
|
}
|
|
|
|
/* src/css/_lang.css */
|
|
:where(.juzhen):lang(zh-Hans),
|
|
:where(.juzhen) :lang(zh-Hans) {
|
|
font-family:
|
|
"Noto Serif SC",
|
|
"Noto Serif CJK SC",
|
|
"Source Han Serif SC",
|
|
serif;
|
|
}
|
|
:where(.juzhen):lang(zh-Hant),
|
|
:where(.juzhen) :lang(zh-Hant) {
|
|
font-family:
|
|
"Noto Serif TC",
|
|
"Noto Serif CJK TC",
|
|
"Source Han Serif TC",
|
|
serif;
|
|
}
|
|
:where(.juzhen):lang(zh-HK),
|
|
:where(.juzhen) :lang(zh-HK) {
|
|
font-family:
|
|
"Noto Serif HK",
|
|
"Noto Serif CJK HK",
|
|
"Noto Serif TC",
|
|
serif;
|
|
}
|
|
:where(.juzhen):lang(ja),
|
|
:where(.juzhen) :lang(ja) {
|
|
font-family:
|
|
"Noto Serif JP",
|
|
"Noto Serif CJK JP",
|
|
serif;
|
|
}
|
|
|
|
/* src/css/_spacing.css */
|
|
jz-hws {
|
|
margin-right: 0.25em;
|
|
}
|
|
jz-hws.jz-hws-trim {
|
|
margin-right: 0;
|
|
}
|
|
|
|
/* src/css/_jiya.css */
|
|
jz-char {
|
|
display: inline-block;
|
|
vertical-align: baseline;
|
|
}
|
|
jz-inner {
|
|
display: inline;
|
|
}
|
|
jz-char.jz-half jz-inner,
|
|
jz-char.jz-half-le jz-inner {
|
|
font-feature-settings: "halt" 1;
|
|
-webkit-font-feature-settings: "halt" 1;
|
|
}
|
|
|
|
/* src/css/_jinze.css */
|
|
jz-jinze {
|
|
display: inline-block;
|
|
white-space: nowrap;
|
|
vertical-align: baseline;
|
|
}
|
|
|
|
/* src/css/juzhen.css */
|