feat: support CJK & ANS spacing

This commit is contained in:
Sivan 2020-03-01 05:51:00 +08:00
parent 25cfc2229a
commit 20c70557b5
12 changed files with 1028 additions and 49 deletions

View file

@ -23,21 +23,16 @@
margin-block-end: $std-block-unit;
font-size: $font-size-h1;
line-height: $line-height-size-h1;
// 中文大标题增加微小文字间距
letter-spacing: $font-size-h1 * 0.05;
}
h2 {
font-size: $font-size-h2;
line-height: $line-height-size-h2;
letter-spacing: $font-size-h2 * 0.05;
}
h3 {
font-size: $font-size-h3;
line-height: $line-height-size-h3;
letter-spacing: $font-size-h3 * 0.05;
}
h4 {
@ -58,6 +53,9 @@
h1,
h2,
h3 {
// 中文大标题增加微小文字间距
letter-spacing: 0.05em;
// 非中文时不加间距
@include non-cjk-block {
letter-spacing: 0;

View file

@ -111,6 +111,7 @@
margin-inline-end: 0.25em;
font-size: 0.75em;
font-family: $font-family-hei;
font-style: normal;
line-height: 1;
vertical-align: baseline;
}
@ -155,7 +156,16 @@
}
}
// 为所有加划线的元素增加缝隙
// 为带划线的元素添加间距以防止视觉上混为一个元素
// : 如果设成为两个相连元素添加间距会有一个问题
// 如果结构是 `<u>倚天</u><u>屠龙</u>`屠龙前面仍然会有边距
// 此处跟预期不一致应该只在两个同名元素紧邻时增加边距`<u>倚天剑</u><u>屠龙刀</u>`
//@each $tag in (abbr[title], del, ins, s, u) {
// #{$tag} + #{$tag} {
// margin-inline-start: 0.125em;
// }
//}
// 因此采用下面的形式为所有加划线的元素增加缝隙
abbr[title],
del,
ins,
@ -164,12 +174,4 @@
margin-inline-start: 1px;
margin-inline-end: 1px;
}
// 带边框的元素两个相连时添加间距以防止视觉上混为一个元素
// @todo: 此处有一个问题如果结构是 <u>倚天</u><u>屠龙</u>屠龙前面仍然会有边距此处跟预期不一致应该只在两个同名元素紧邻时增加边距<u>倚天剑</u><u>屠龙刀</u>
//@each $tag in (abbr[title], del, ins, s, u) {
// #{$tag} + #{$tag} {
// margin-inline-start: 0.125em;
// }
//}
}

23
lib/helpers/_add-on.scss Normal file
View file

@ -0,0 +1,23 @@
// Author: Sivan [sun.sivan@gmail.com]
// Description: define add-ons.
@import "../variables";
@mixin hetiAddOns {
// 用于中西文混排增加边距
heti-spacing {
display: inline;
&.heti-spacing-start {
margin-inline-end: 0.25em;
}
&.heti-spacing-end {
margin-inline-start: 0.25em;
}
& + sup,
& + sub {
margin-inline-start: 0;
}
}
}

View file

@ -26,6 +26,7 @@
&-x-large {
font-size: $font-size-x-large;
line-height: $line-height-size-x-large;
letter-spacing: 0.05em;
}
&-small {

View file

@ -17,6 +17,7 @@
@import "modifiers/annotation";
@import "helpers/block";
@import "helpers/inline";
@import "helpers/add-on";
#{$root-selector} {
// 中文每行展示文字CPL建议在 30~50 之间默认 42
@ -52,4 +53,5 @@
// .heti .heti-verse, .heti .heti-hang
@include hetiBlockHelperClasses();
@include hetiInlineHelperClasses();
@include hetiAddOns();
}