mirror of
https://github.com/storytold/designcraft.git
synced 2026-12-02 20:21:15 -05:00
Mojikumi: the reduction tier follows the character classes
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013phQ3ekq6uGBEWD6FjFYG2
This commit is contained in:
1 parent
4b05bb3804
commit
4db54f5d47
1 file changed
+14
-5
@@ -128,17 +128,20 @@ impl<'a> Rules<'a> {
|
||||
}
|
||||
let punctuation = trailing(left).max(leading(right));
|
||||
if punctuation > 0.0 {
|
||||
// The Japanese sets take a line in at the quarter ems of middle dots first, then at the
|
||||
// half ems of brackets and commas, and don't reduce the space after a full stop
|
||||
// (JLREQ 3.8.3). The Chinese sets reduce all punctuation blanks together.
|
||||
// The Japanese sets take a line in at the quarter ems of middle dots (・:;) first, then
|
||||
// at the half ems of brackets and commas, and don't reduce the space after a full stop
|
||||
// (JLREQ 3.8.3). !? share the first tier: JLREQ sets them solid (Table 1) and
|
||||
// gives the quarter em only as an alternative (3.1.6), so reducing it first returns
|
||||
// to that default. The tier follows the character classes, not the blank's size. The
|
||||
// Chinese sets reduce all punctuation blanks together.
|
||||
let japanese = self.base != Base::Chinese;
|
||||
let quarter = punctuation < 0.5;
|
||||
let bracket_or_comma = matches!(left, 2 | 6 | 21 | 28..=31) || matches!(right, 1 | 26 | 27);
|
||||
let full_stop = matches!(left, 6 | 31);
|
||||
return Aki {
|
||||
min: if japanese && full_stop { punctuation } else { 0.0 },
|
||||
desired: punctuation,
|
||||
max: punctuation,
|
||||
priority: if japanese && !quarter { 2 } else { 1 },
|
||||
priority: if japanese && bracket_or_comma { 2 } else { 1 },
|
||||
discrete: false,
|
||||
};
|
||||
}
|
||||
@@ -298,6 +301,12 @@ mod tests {
|
||||
assert!(dot.priority == after_dot.priority && dot.priority < comma.priority, "{set}");
|
||||
assert!(comma.priority == close.priority && close.priority == open.priority && open.priority < wa_ou.priority, "{set}");
|
||||
assert_eq!((dot.min, comma.min, close.min, open.min), (0.0, 0.0, 0.0, 0.0), "{set}");
|
||||
// The tier follows the class: :;!? share the middle dots' tier, and a bracket's half
|
||||
// em beside a middle dot stays with the brackets.
|
||||
for (a, b) in [('漢', ':'), (';', '漢'), ('漢', '!'), ('?', '漢')] {
|
||||
assert_eq!(aki(a, b).priority, dot.priority, "{set}: {a}{b}");
|
||||
}
|
||||
assert_eq!(aki('・', '「').priority, open.priority, "{set}: ・「");
|
||||
// After a full stop the half em stays, before an opening bracket too.
|
||||
for b in ['漢', '「'] {
|
||||
let a = aki('。', b);
|
||||
|
||||
Reference in new issue
Block a user