mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 23:31:18 +00:00
Type: Bunri-Kinshi keeps inseparable character pairs on one line
Paragraph panel menu > Bunri-Kinshi (with the East Asian options) and
text.setFormat {bunriKinshi} turn it on per paragraph. A line then
never breaks inside two em dashes, two horizontal ellipses, two two-dot
leaders or the two halves of a vertical kana repeat mark, the pairs W3C
JLREQ lists for class cl-08 (https://www.w3.org/TR/jlreq/#cl-08), nor
inside a chain of em dashes. Both composers, vertical type, Kinsoku
Shori Type, hyphenation and No Break follow it, and a pair wider than
the line stays whole on it. Justification and letter spacing add no
space inside a pair.
The setting works only with a Kinsoku Set: with Kinsoku Set None the
paragraph keeps the value without effect and the menu item is
unavailable. It is off by default, saved with the paragraph only when
on, carried by paragraph styles (Paragraph Style Options > East Asian
Composition Settings), and turned off by Reset Panel. A value that is
not true or false is refused. The .ai editing data has no field for it,
so saving reports a paragraph with it on and a pair in it as left out.
Docs: docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
@@ -237,6 +237,10 @@ pub struct ParaStyle {
|
||||
/// Kinsoku Shori Type (Paragraph panel menu): how a line keeps those characters off its start
|
||||
/// and end, by pushing them in onto the line or out to the next one. No effect without kinsoku.
|
||||
pub kinsoku_type: KinsokuShoriType,
|
||||
/// Bunri-Kinshi (Paragraph panel menu): a line never breaks inside an inseparable pair (two em
|
||||
/// dashes, two ellipses, two two-dot leaders, a vertical kana repeat mark's two halves). Kept
|
||||
/// with kinsoku None, where it has no effect. Off by default.
|
||||
pub bunri_kinshi: bool,
|
||||
/// Roman Hanging Punctuation (Paragraph panel menu): quotation marks, hyphens, full stops and
|
||||
/// commas starting or ending a line hang outside the margin, and asterisks, tildes, ellipses,
|
||||
/// dashes, colons and semicolons hang by half. East Asian punctuation hangs by burasagari.
|
||||
@@ -339,6 +343,8 @@ struct ParaStyleFile {
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
kinsoku_type: KinsokuShoriType,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
bunri_kinshi: bool,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
roman_hanging: bool,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
kashida: Kashida,
|
||||
@@ -375,6 +381,7 @@ impl From<ParaStyle> for ParaStyleFile {
|
||||
burasagari,
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -401,6 +408,7 @@ impl From<ParaStyle> for ParaStyleFile {
|
||||
burasagari,
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -431,6 +439,7 @@ impl From<ParaStyleFile> for ParaStyle {
|
||||
burasagari,
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -456,6 +465,7 @@ impl From<ParaStyleFile> for ParaStyle {
|
||||
burasagari,
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -243,6 +243,7 @@ pub fn para_attrs(v: &ParaStyle) -> Map<String, Value> {
|
||||
("burasagari", json!(v.burasagari)),
|
||||
("kinsoku", json!(v.kinsoku)),
|
||||
("kinsoku_type", json!(v.kinsoku_type)),
|
||||
("bunri_kinshi", json!(v.bunri_kinshi)),
|
||||
("roman_hanging", json!(v.roman_hanging)),
|
||||
("kashida", json!(v.kashida)),
|
||||
("korean_line_break_anywhere", json!(v.korean_line_break_anywhere)),
|
||||
|
||||
@@ -440,6 +440,59 @@ fn korean_line_break_anywhere_is_set_per_paragraph_and_saved_only_when_off() {
|
||||
assert!(!text(&s).para_at(0).korean_line_break_anywhere && !text(&s).para_at(1).korean_line_break_anywhere);
|
||||
}
|
||||
|
||||
/// Paragraph panel menu › Bunri-Kinshi: off for new type and for a paragraph saved before it, and
|
||||
/// saved only when on; `text.setFormat {bunriKinshi}` sets it per paragraph in one undo step and
|
||||
/// refuses a value that is not true or false, kinsoku None keeps it, and paragraph styles carry it.
|
||||
#[test]
|
||||
fn bunri_kinshi_is_set_per_paragraph_and_saved_only_when_on() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
|
||||
let id = s.execute("text.create", &json!({"x": 10, "y": 10, "size": 20, "text": "あ——い\nう……え"})).unwrap()["id"].as_u64().unwrap();
|
||||
let text = |s: &Session| match &s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind {
|
||||
NodeKind::Text(t) => (**t).clone(),
|
||||
_ => panic!("text"),
|
||||
};
|
||||
assert!(!text(&s).para_at(0).bunri_kinshi, "new type has it off");
|
||||
assert!(serde_json::to_value(text(&s).para_at(0)).unwrap().get("bunri_kinshi").is_none());
|
||||
let old: vectorcraft_doc::ParaStyle = serde_json::from_value(json!({"justify": "Left"})).unwrap();
|
||||
assert!(!old.bunri_kinshi, "saved before the option: off");
|
||||
s.execute("select.set", &json!({"ids": [id]})).unwrap();
|
||||
let steps = s.doc().unwrap().history.undo.len();
|
||||
// Only the second paragraph.
|
||||
let second = "あ——い\n".len();
|
||||
s.execute("text.setFormat", &json!({"bunriKinshi": true, "start": second, "end": second})).unwrap();
|
||||
assert!(!text(&s).para_at(0).bunri_kinshi && text(&s).para_at(1).bunri_kinshi);
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), steps + 1);
|
||||
let saved = serde_json::to_value(text(&s).para_at(1)).unwrap();
|
||||
assert_eq!(saved["bunri_kinshi"], true);
|
||||
let back: vectorcraft_doc::ParaStyle = serde_json::from_value(saved).unwrap();
|
||||
assert!(back.bunri_kinshi);
|
||||
let reopened = vectorcraft_format::load(&vectorcraft_format::save(&s.doc().unwrap().doc, false)).unwrap();
|
||||
let Some(NodeKind::Text(back)) = reopened.node(NodeId(id)).map(|n| &n.kind) else { panic!("text") };
|
||||
assert!(!back.para_at(0).bunri_kinshi && back.para_at(1).bunri_kinshi, "the file keeps it per paragraph");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(!text(&s).para_at(1).bunri_kinshi);
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert!(text(&s).para_at(1).bunri_kinshi);
|
||||
for bad in [json!("yes"), json!(1)] {
|
||||
assert!(s.execute("text.setFormat", &json!({"ids": [id], "bunriKinshi": bad, "kinsoku": "none"})).is_err(), "{bad}");
|
||||
}
|
||||
assert!(s.execute("text.setRangeStyle", &json!({"id": id, "bunriKinshi": false})).is_err());
|
||||
assert!(text(&s).para_at(1).bunri_kinshi && text(&s).para_at(1).kinsoku != vectorcraft_doc::Kinsoku::None, "a refused call changes nothing");
|
||||
// Kinsoku None keeps the setting, without effect, and turning kinsoku back on restores it.
|
||||
s.execute("text.setFormat", &json!({"ids": [id], "kinsoku": "none"})).unwrap();
|
||||
assert!(text(&s).para_at(1).bunri_kinshi);
|
||||
s.execute("text.setFormat", &json!({"ids": [id], "kinsoku": "hard"})).unwrap();
|
||||
assert!(text(&s).para_at(1).bunri_kinshi);
|
||||
// A paragraph style carries it.
|
||||
s.execute("paraStyle.new", &json!({"name": "Pairs", "attrs": {"bunri_kinshi": true}})).unwrap();
|
||||
s.execute("paraStyle.apply", &json!({"name": "Pairs", "id": id})).unwrap();
|
||||
assert!(text(&s).para_at(0).bunri_kinshi && text(&s).para_at(1).bunri_kinshi);
|
||||
s.execute("paraStyle.new", &json!({"name": "Split", "attrs": {"bunri_kinshi": false}})).unwrap();
|
||||
s.execute("paraStyle.apply", &json!({"name": "Split", "id": id})).unwrap();
|
||||
assert!(!text(&s).para_at(0).bunri_kinshi && !text(&s).para_at(1).bunri_kinshi);
|
||||
}
|
||||
|
||||
/// Paragraph panel › Insert Kashidas: `text.setFormat {kashida}` sets it per paragraph in one
|
||||
/// undo step, the paragraph is saved with it only when it is not None and opens with it, an
|
||||
/// unknown value changes nothing, and paragraph styles carry it.
|
||||
|
||||
@@ -524,6 +524,7 @@ fn type_commands_refuse_a_number_or_boolean_given_as_text() {
|
||||
("text.setFormat", json!({"ids": [id.0], "hyphenateCapitalized": 0}), "hyphenateCapitalized"),
|
||||
("text.setFormat", json!({"ids": [id.0], "romanHangingPunctuation": "true"}), "romanHangingPunctuation"),
|
||||
("text.setFormat", json!({"ids": [id.0], "koreanLineBreakAnywhere": 1}), "koreanLineBreakAnywhere"),
|
||||
("text.setFormat", json!({"ids": [id.0], "bunriKinshi": "on"}), "bunriKinshi"),
|
||||
("text.getRange", json!({"id": id.0, "effective": "true"}), "effective"),
|
||||
("type.opticalMarginAlignment", json!({"on": "true"}), "on"),
|
||||
("type.systemLayout", json!({"on": "true"}), "on"),
|
||||
|
||||
@@ -3815,6 +3815,42 @@ fn korean_line_break_anywhere_is_reported_only_for_korean_paragraphs() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The text document has no Bunri-Kinshi: a paragraph with it on and an inseparable pair in it is
|
||||
/// reported as left out, and comes back off; with it off, or with no pair, nothing is reported.
|
||||
#[test]
|
||||
fn bunri_kinshi_is_reported_only_for_paragraphs_with_a_pair() {
|
||||
use vectorcraft_doc::TextObject;
|
||||
for (text, on, reported) in [
|
||||
("Wait——now", true, true),
|
||||
("Wait——now", false, false),
|
||||
("Wait—now", true, false),
|
||||
("Wait……now", true, true),
|
||||
("Wait‥‥now", true, true),
|
||||
("あ〳〵い", true, true),
|
||||
("あ〴〵い", true, true),
|
||||
("あ〵〳い", true, false),
|
||||
] {
|
||||
let mut t = TextObject::point(vectorcraft_geom::Point::new(20.0, 40.0), text, style(14.0, Color::BLACK));
|
||||
t.para.bunri_kinshi = on;
|
||||
let mut doc = Document::new(200.0, 200.0);
|
||||
let layer = doc.layers[0].id;
|
||||
let n = text_node(&mut doc, t);
|
||||
doc.insert(Some(layer), usize::MAX, n).unwrap();
|
||||
let out = export_ai_editing(&doc, &opts()).unwrap();
|
||||
assert_eq!(!out.warnings.is_empty(), reported, "{text} {on}: {:?}", out.warnings);
|
||||
let mut all = vec![];
|
||||
paths(&read_back(&doc).layers, &mut all);
|
||||
let paras: Vec<bool> = all
|
||||
.iter()
|
||||
.filter_map(|n| match &n.kind {
|
||||
NodeKind::Text(t) => Some(t.para_at(0).bunri_kinshi),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(paras, [false], "{text} {on}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_is_written_again_as_the_same_bytes() {
|
||||
let doc = typed();
|
||||
|
||||
@@ -387,6 +387,7 @@ pub(in crate::ai_editing) fn loses(t: &TextObject) -> bool {
|
||||
}
|
||||
let hangul =
|
||||
text.chars().any(|c| matches!(c, '\u{1100}'..='\u{11FF}' | '\u{3130}'..='\u{318F}' | '\u{A960}'..='\u{A97F}' | '\u{AC00}'..='\u{D7FF}' | '\u{FFA0}'..='\u{FFDC}'));
|
||||
let pairs = text.chars().zip(text.chars().skip(1)).any(|(a, b)| vectorcraft_text::inseparable(a, b));
|
||||
let held = ParaStyle {
|
||||
justify: p.justify,
|
||||
left_indent: p.left_indent,
|
||||
@@ -403,6 +404,9 @@ pub(in crate::ai_editing) fn loses(t: &TextObject) -> bool {
|
||||
// The text document has no Korean Line Break Anywhere: it reads back off, which
|
||||
// changes only the lines of a paragraph with Hangul in it.
|
||||
korean_line_break_anywhere: p.korean_line_break_anywhere && !hangul,
|
||||
// Nor Bunri-Kinshi: it reads back off, which changes only the lines of a paragraph
|
||||
// with an inseparable pair in it.
|
||||
bunri_kinshi: p.bunri_kinshi && !pairs,
|
||||
..ParaStyle::default()
|
||||
};
|
||||
*p != held
|
||||
|
||||
@@ -100,9 +100,10 @@ fn continues_word(g: &SGlyph, next: Option<&SGlyph>) -> bool {
|
||||
|
||||
/// A glyph letter spacing follows: a visible glyph followed by another character in the same word
|
||||
/// (`next` is the next glyph that is not a format control, or a zero-width space). The glyphs of
|
||||
/// one shaped cluster (a letter and its combining marks) take none between them.
|
||||
/// one shaped cluster (a letter and its combining marks) take none between them, and neither do the
|
||||
/// two halves of an inseparable pair that Bunri-Kinshi keeps together.
|
||||
fn letter_gap(g: &SGlyph, next: Option<&SGlyph>) -> bool {
|
||||
gap_owner(g) && continues_word(g, next)
|
||||
gap_owner(g) && !g.keeps_next && continues_word(g, next)
|
||||
}
|
||||
|
||||
/// The width of a word space in `g`'s font and size: what letter spacing is a share of.
|
||||
|
||||
@@ -688,6 +688,7 @@ mod emit_kashida_mark_last {
|
||||
inline: None,
|
||||
word_end: false,
|
||||
keeps_word: false,
|
||||
keeps_next: false,
|
||||
lead: 0.0,
|
||||
proportional: false,
|
||||
vpal: None,
|
||||
@@ -750,6 +751,7 @@ mod emit_kashida_mark_last {
|
||||
inline: None,
|
||||
word_end: false,
|
||||
keeps_word: false,
|
||||
keeps_next: false,
|
||||
lead: 0.0,
|
||||
proportional: false,
|
||||
vpal: None,
|
||||
|
||||
@@ -347,10 +347,11 @@ pub(super) fn break_line(
|
||||
while g.get(cluster_end).is_some_and(|next| next.byte == gl.byte && (next.len == 0) == (gl.len == 0)) {
|
||||
cluster_end += 1;
|
||||
}
|
||||
// No Break: the marked characters stay on one line, including across a space inside the run.
|
||||
if gl.no_break && gl.ch != '\u{2028}' {
|
||||
// No Break: the marked characters stay on one line, including across a space inside the run;
|
||||
// Bunri-Kinshi keeps an inseparable pair, or a chain of them, on one line too.
|
||||
if gl.ch != '\u{2028}' {
|
||||
while let Some(n) = g.get(cluster_end) {
|
||||
if !n.no_break || n.ch == '\u{2028}' {
|
||||
if !splits_no_break(g, cluster_end) || n.ch == '\u{2028}' {
|
||||
break;
|
||||
}
|
||||
let b = n.byte;
|
||||
@@ -550,9 +551,10 @@ fn may_end_after(g: &[SGlyph], end: usize, kinsoku: Kinsoku) -> bool {
|
||||
last.break_after() && last.len > 0 && !last.is_soft_hyphen() && kinsoku_allows(g, e - 1, kinsoku) && !splits_no_break(g, e)
|
||||
}
|
||||
|
||||
/// Would a line ending at glyph index `end` split a No Break run?
|
||||
/// Would a line ending at glyph index `end` split a No Break run, or an inseparable pair that
|
||||
/// Bunri-Kinshi keeps together ([`SGlyph::keeps_next`])?
|
||||
fn splits_no_break(g: &[SGlyph], end: usize) -> bool {
|
||||
end > 0 && g.get(end - 1).is_some_and(|a| a.no_break) && g.get(end).is_some_and(|b| b.no_break)
|
||||
end > 0 && g.get(end - 1).is_some_and(|a| (a.no_break && g.get(end).is_some_and(|b| b.no_break)) || (a.keeps_next && g.get(end).is_some()))
|
||||
}
|
||||
|
||||
/// Does kinsoku allow a line break after glyph `j`? Not after an opening bracket, nor before a
|
||||
@@ -622,6 +624,7 @@ fn push_in(
|
||||
k >= g.len()
|
||||
|| (g[k].byte != g[k - 1].byte
|
||||
&& kinsoku_allows(g, k - 1, kinsoku)
|
||||
&& !splits_no_break(g, k)
|
||||
&& (g[k].is_space() || (g[k - 1].break_after() && !g[k - 1].is_soft_hyphen())))
|
||||
};
|
||||
let (mut end, mut x) = (cluster_end, x);
|
||||
@@ -686,12 +689,14 @@ fn push_in(
|
||||
|
||||
/// May a push-in close the gap after glyph `a`? A gap between two characters, at least one of them
|
||||
/// CJK, outside a tate-chu-yoko block, a list marker and a shaped cluster, and not next to a space,
|
||||
/// a tab or an inline graphic before it. Zero-width format controls take no gap: the gap is the
|
||||
/// one between the visible characters on either side, before `end`, as the layout justifies it.
|
||||
/// a tab or an inline graphic before it, nor inside an inseparable pair that Bunri-Kinshi keeps
|
||||
/// together. Zero-width format controls take no gap: the gap is the one between the visible
|
||||
/// characters on either side, before `end`, as the layout justifies it.
|
||||
fn closes(g: &[SGlyph], a: usize, end: usize) -> bool {
|
||||
let Some(p) = g.get(a).filter(|p| !is_format_control(p.ch)) else { return false };
|
||||
let Some(n) = g.get(a + 1..end).and_then(|rest| rest.iter().find(|n| !is_format_control(n.ch))) else { return false };
|
||||
p.len > 0
|
||||
&& !p.keeps_next
|
||||
&& p.byte != n.byte
|
||||
&& p.inline.is_none()
|
||||
&& !p.is_space()
|
||||
|
||||
@@ -11,7 +11,7 @@ use super::{
|
||||
fit_line, hyphen_glyph, is_cjk, is_word_space, kashida, mark_word_ends, no_line_end, no_line_start, style_metrics,
|
||||
};
|
||||
use crate::justify::is_format_control;
|
||||
use crate::shape::keep_korean_words;
|
||||
use crate::shape::{keep_inseparable_pairs, keep_korean_words};
|
||||
|
||||
/// Does paragraph `para` push characters in (Kinsoku Shori Type Push In First or Push Out First,
|
||||
/// with kinsoku on)?
|
||||
@@ -230,6 +230,10 @@ fn prepare_paragraph<'a, 'text>(
|
||||
if !para.korean_line_break_anywhere {
|
||||
keep_korean_words(&mut sg);
|
||||
}
|
||||
// Bunri-Kinshi keeps inseparable pairs on one line, while kinsoku is on.
|
||||
if para.bunri_kinshi && para.kinsoku != Kinsoku::None {
|
||||
keep_inseparable_pairs(text, &mut sg);
|
||||
}
|
||||
// Japanese composition: consecutive punctuation shares one half-em space.
|
||||
let mut compressed = if para.mojikumi == Mojikumi::LineEndHalf { compress_punctuation(&mut sg) } else { vec![] };
|
||||
// …and a quarter em between Japanese and Latin text.
|
||||
@@ -736,16 +740,24 @@ fn gap_pair<'a>(glyph: usize, held: &[usize], after: &[Option<usize>], index: us
|
||||
fn is_cjk_gap(glyph: usize, held: &[usize], after: &[Option<usize>], index: usize, sg: &[SGlyph]) -> bool {
|
||||
gap_pair(glyph, held, after, index, sg).is_some_and(|(a, b)| {
|
||||
a.byte != b.byte && !a.is_space() && !b.is_space() && !b.continues_tcy() && a.ch != '\t' && (is_cjk(a.ch) || is_cjk(b.ch))
|
||||
}) && !in_pair(glyph, index, after, sg)
|
||||
}
|
||||
|
||||
// Bunri-Kinshi: are glyph `glyph` and the glyph drawn after it the two halves of an inseparable
|
||||
// pair? Justification adds no space between them.
|
||||
fn in_pair(glyph: usize, index: usize, after: &[Option<usize>], sg: &[SGlyph]) -> bool {
|
||||
drawn_after(index, glyph, after).is_some_and(|next| {
|
||||
(next == glyph + 1 && sg.get(glyph).is_some_and(|a| a.keeps_next)) || (glyph == next + 1 && sg.get(next).is_some_and(|b| b.keeps_next))
|
||||
})
|
||||
}
|
||||
|
||||
// Single Word Justification's Full Justify spreads a line's leftover room over the gaps between
|
||||
// its drawn glyphs: not after a held glyph, nor inside a tate-chu-yoko block (one cell) or a
|
||||
// shaped cluster, whose glyphs (a letter and its combining marks, a conjunct and its matra) stay
|
||||
// together. On a line that ends in a drawn hyphen, the gap before the hyphen counts too: it follows
|
||||
// the line's last visible glyph.
|
||||
// its drawn glyphs: not after a held glyph, nor inside a tate-chu-yoko block (one cell), a shaped
|
||||
// cluster, whose glyphs (a letter and its combining marks, a conjunct and its matra) stay
|
||||
// together, or an inseparable pair. On a line that ends in a drawn hyphen, the gap before the
|
||||
// hyphen counts too: it follows the line's last visible glyph.
|
||||
fn is_letter_gap(glyph: usize, held: &[usize], after: &[Option<usize>], index: usize, sg: &[SGlyph], hyphen: bool) -> bool {
|
||||
if held.contains(&glyph) || sg.get(glyph).is_none_or(|a| is_format_control(a.ch)) {
|
||||
if held.contains(&glyph) || sg.get(glyph).is_none_or(|a| is_format_control(a.ch)) || in_pair(glyph, index, after, sg) {
|
||||
return false;
|
||||
}
|
||||
match gap_pair(glyph, held, after, index, sg) {
|
||||
|
||||
@@ -34,6 +34,7 @@ fn synthetic_glyphs(specs: &[(usize, usize, f64, char)]) -> Vec<SGlyph> {
|
||||
inline: None,
|
||||
word_end: false,
|
||||
keeps_word: false,
|
||||
keeps_next: false,
|
||||
lead: 0.0,
|
||||
proportional: false,
|
||||
vpal: None,
|
||||
@@ -627,3 +628,89 @@ fn korean_words_take_no_hyphen() {
|
||||
assert_eq!(hyphens(true), 1, "on, the word's Latin letters hyphenate as before");
|
||||
});
|
||||
}
|
||||
|
||||
/// The glyphs of `text`, each 10 pt wide, with its inseparable pairs kept together when `bunri`
|
||||
/// (Bunri-Kinshi on).
|
||||
fn pairs(text: &str, bunri: bool) -> Vec<SGlyph> {
|
||||
let mut glyphs = full_width(text);
|
||||
if bunri {
|
||||
crate::shape::keep_inseparable_pairs(text, &mut glyphs);
|
||||
}
|
||||
glyphs
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi: both composers never break inside two em dashes, two ellipses, two two-dot
|
||||
/// leaders or a vertical kana repeat mark, nor inside a chain of em dashes; off, the line may break
|
||||
/// between them where it could before. Unlike neighbors and characters on either side of a forced
|
||||
/// line break are not a pair.
|
||||
#[test]
|
||||
fn bunri_kinshi_keeps_jlreq_pairs_in_both_composers() {
|
||||
use KinsokuShoriType::PushOutOnly;
|
||||
let ends = |text: &str, bunri: bool| candidates(text, &pairs(text, bunri), None, Kinsoku::Hard).iter().map(|b| b.end).collect::<Vec<_>>();
|
||||
let text = "あい——う〳〵え";
|
||||
assert_eq!(ends(text, false), [1, 2, 3, 4, 5, 6, 7]);
|
||||
assert_eq!(ends(text, true), [1, 2, 4, 5, 7]);
|
||||
assert_eq!(ends("———あ", false), [1, 2, 3]);
|
||||
assert_eq!(ends("———あ", true), [3], "a chain stays together");
|
||||
assert_eq!(ends("あ〴〵い", true), [1, 3]);
|
||||
assert_eq!(ends("—…あ", true), ends("—…あ", false), "unlike neighbors are not a pair");
|
||||
for text in ["あ……い", "あ‥‥い"] {
|
||||
assert!(!ends(text, true).contains(&2), "{text}");
|
||||
}
|
||||
let marked = |text: &str| pairs(text, true).iter().filter(|g| g.keeps_next).count();
|
||||
assert_eq!((marked("……‥‥〳〵〴〵"), marked("—\u{2028}—"), marked("—〵"), marked("〵〳")), (4, 0, 0, 0));
|
||||
// 35 pt holds "あい—" and not "あい——".
|
||||
let greedy =
|
||||
|g: &[SGlyph], width: f64| break_line(text, g, 0, width, &[], 0.0, None, Burasagari::None, Kinsoku::Hard, PushOutOnly, false, false, &[]).0;
|
||||
assert_eq!(greedy(&pairs(text, false), 35.0), 3, "off: the line ends between the dashes");
|
||||
assert_eq!(greedy(&pairs(text, true), 35.0), 2, "on: both dashes go to the next line");
|
||||
assert_eq!(breaking::word_width(&pairs("——あ", true), 0, &[], Kinsoku::Hard), 20.0);
|
||||
assert_eq!(breaking::word_width(&pairs("——あ", false), 0, &[], Kinsoku::Hard), 10.0);
|
||||
let params = Params { justify_last: false, ragged: true, tolerance: f64::INFINITY, uniform_from: 0, hyphen_limit: 0 };
|
||||
let on = pairs("あい——う", true);
|
||||
let cands = candidates("あい——う", &on, None, Kinsoku::Hard);
|
||||
assert_eq!(compose(&on, &|_| 35.0, &|_| 0.0, &|_| 0.0, &cands, &[], ¶ms), Some(vec![(2, false), (5, false)]));
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi: a pair wider than the line stays whole on it and the next line starts after it;
|
||||
/// every Kinsoku Shori Type and both kinsoku sets leave pairs whole at every width, and each line
|
||||
/// moves on. No Break and a pair next to it stay together as one run.
|
||||
#[test]
|
||||
fn bunri_kinshi_progresses_with_an_overlong_pair_and_no_break() {
|
||||
use KinsokuShoriType::{PushInFirst, PushOutFirst, PushOutOnly};
|
||||
let line = |text: &str, g: &[SGlyph], i: usize, width: f64, kinsoku: Kinsoku, ty: KinsokuShoriType| {
|
||||
break_line(text, g, i, width, &[], 0.0, None, Burasagari::None, kinsoku, ty, false, false, &[]).0
|
||||
};
|
||||
let text = "——あ";
|
||||
assert_eq!(line(text, &pairs(text, true), 0, 15.0, Kinsoku::Hard, PushOutOnly), 2, "the pair overflows the line whole");
|
||||
assert_eq!(line(text, &pairs(text, true), 2, 15.0, Kinsoku::Hard, PushOutOnly), 3);
|
||||
assert_eq!(line(text, &pairs(text, false), 0, 15.0, Kinsoku::Hard, PushOutOnly), 1);
|
||||
let text = "あい——」う〳〵」え";
|
||||
let glyphs = pairs(text, true);
|
||||
for kinsoku in [Kinsoku::Hard, Kinsoku::Soft] {
|
||||
for ty in [PushInFirst, PushOutFirst, PushOutOnly] {
|
||||
for width in (10..=90).step_by(5).map(f64::from) {
|
||||
let mut i = 0;
|
||||
while i < glyphs.len() {
|
||||
let end = line(text, &glyphs, i, width, kinsoku, ty);
|
||||
assert!(end > i, "{kinsoku:?} {ty:?} {width}: no progress at {i}");
|
||||
assert!(end != 3 && end != 7, "{kinsoku:?} {ty:?} {width}: a pair split at {end}");
|
||||
i = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let text = "あ——い";
|
||||
let mut on = pairs(text, true);
|
||||
let mut off = pairs(text, false);
|
||||
for g in on[..2].iter_mut().chain(off[..2].iter_mut()) {
|
||||
g.no_break = true;
|
||||
}
|
||||
assert_eq!(line(text, &on, 0, 25.0, Kinsoku::Hard, PushOutOnly), 3, "No Break and the pair are one run");
|
||||
assert_eq!(line(text, &off, 0, 25.0, Kinsoku::Hard, PushOutOnly), 2);
|
||||
// Push In First closes each gap by up to 1 pt here: 」 needs 3.5 pt, which the four gaps give
|
||||
// and the three outside the pair do not, so on, い moves to the next line with 」.
|
||||
let text = "あ〳〵い」";
|
||||
assert_eq!(line(text, &pairs(text, false), 0, 46.5, Kinsoku::Hard, PushInFirst), 5);
|
||||
assert_eq!(line(text, &pairs(text, true), 0, 46.5, Kinsoku::Hard, PushInFirst), 3);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ pub use svg_glyph::{SvgGlyphReader, set_svg_glyph_reader};
|
||||
pub use kept::{KeptLayoutsFrame, LayoutStamp, keep_layout, take_kept_layout};
|
||||
use kurbo::{Affine, BezPath, Point, Rect, Shape, Vec2};
|
||||
pub use layout::{decorations, drawn, fit_first_line, fit_source_lines, layout, layout_with, scaled};
|
||||
pub use shape::{line_start_space, spacing_scale};
|
||||
pub use shape::{inseparable, line_start_space, spacing_scale};
|
||||
pub use vectorcraft_doc::TextObject;
|
||||
|
||||
pub use vectorcraft_doc::{AreaFit, FirstBaseline, TextFlow, VerticalAlign};
|
||||
|
||||
@@ -79,6 +79,9 @@ pub(crate) struct SGlyph {
|
||||
/// A letter of a Korean word kept whole (Korean Line Break Anywhere off): a CJK character
|
||||
/// here doesn't let the line break after it ([`keep_korean_words`]).
|
||||
pub keeps_word: bool,
|
||||
/// Bunri-Kinshi (Paragraph panel menu): the glyph's cluster ends with the first character of
|
||||
/// an inseparable pair, so a line may not break after it ([`keep_inseparable_pairs`]).
|
||||
pub keeps_next: bool,
|
||||
/// No Break (Character panel menu): keep this glyph on the same line as the neighbouring
|
||||
/// glyphs that have it.
|
||||
pub no_break: bool,
|
||||
@@ -349,6 +352,36 @@ pub(crate) fn keep_korean_words(sg: &mut [SGlyph]) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi: mark each glyph of `sg` (a paragraph's glyphs, shaped from `text`, which their
|
||||
/// bytes index) whose cluster ends right before the second character of an inseparable pair
|
||||
/// ([`inseparable`]) as [`SGlyph::keeps_next`], so a line never breaks inside the pair. A pair is
|
||||
/// two neighboring source characters, whatever their fonts and styles; an inline graphic or a
|
||||
/// shaped cluster holding both characters is never a pair.
|
||||
pub(crate) fn keep_inseparable_pairs(text: &str, sg: &mut [SGlyph]) {
|
||||
for k in 1..sg.len() {
|
||||
let (a, b) = (&sg[k - 1], &sg[k]);
|
||||
if a.byte == b.byte || a.inline.is_some() || b.inline.is_some() || a.byte + a.len != b.byte {
|
||||
continue;
|
||||
}
|
||||
let last = text.get(a.byte..b.byte).and_then(|s| s.chars().next_back()).unwrap_or(a.ch);
|
||||
if inseparable(last, b.ch) {
|
||||
sg[k - 1].keeps_next = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Is `a` followed by `b` an inseparable pair that Bunri-Kinshi keeps on one line? VectorCraft's
|
||||
/// set is the pairs W3C JLREQ lists for its class cl-08 (https://www.w3.org/TR/jlreq/#cl-08): two
|
||||
/// em dashes, two horizontal ellipses, two two-dot leaders, and the upper half of a vertical kana
|
||||
/// repeat mark (U+3033 or U+3034) followed by its lower half (U+3035). File writers call it to
|
||||
/// report whether a paragraph's lines depend on Bunri-Kinshi.
|
||||
pub fn inseparable(a: char, b: char) -> bool {
|
||||
matches!(
|
||||
(a, b),
|
||||
('\u{2014}', '\u{2014}') | ('\u{2026}', '\u{2026}') | ('\u{2025}', '\u{2025}') | ('\u{3033}', '\u{3035}') | ('\u{3034}', '\u{3035}')
|
||||
)
|
||||
}
|
||||
|
||||
/// Is `c` Hangul: a syllable, a jamo or a compatibility jamo (full or half width)?
|
||||
pub(crate) fn is_hangul(c: char) -> bool {
|
||||
c.script() == Script::Hangul
|
||||
@@ -1166,6 +1199,7 @@ fn inline_glyph(
|
||||
inline: Some(InlineBox { art: drawn, xf }),
|
||||
word_end: false,
|
||||
keeps_word: false,
|
||||
keeps_next: false,
|
||||
no_break: st.no_break,
|
||||
vertical_roman: false,
|
||||
cursive: false,
|
||||
@@ -1638,6 +1672,7 @@ fn shape_segment(text: &str, context: &Range<usize>, seg: &Segment, feats: &OtFe
|
||||
inline: None,
|
||||
word_end: false,
|
||||
keeps_word: false,
|
||||
keeps_next: false,
|
||||
no_break: gst.no_break,
|
||||
vertical_roman: gst.standard_vertical_roman,
|
||||
cursive,
|
||||
|
||||
@@ -2552,6 +2552,87 @@ fn korean_words_stay_whole_unless_line_break_anywhere_is_on() {
|
||||
assert_eq!(ends(&t), ["가나다 라".len(), text.len(), second + first, second + text.len()]);
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi (a paragraph attribute): on, two em dashes that do not both fit move to the next
|
||||
/// line together, with either composer and in vertical type; off, or with kinsoku None, the line
|
||||
/// breaks between them. Each paragraph follows its own setting.
|
||||
#[test]
|
||||
fn bunri_kinshi_keeps_two_em_dashes_on_one_line() {
|
||||
let text = "あいう——え";
|
||||
let (split, kept) = ("あいう—".len(), "あいう".len());
|
||||
let measure = |vertical: bool| {
|
||||
let mut t = point("あいう—", style(20.0));
|
||||
t.vertical = vertical;
|
||||
layout(db(), &t).glyphs.iter().map(|g| g.advance).sum::<f64>()
|
||||
};
|
||||
let ends = |t: &TextObject| layout(db(), t).lines.iter().map(|l| l.end).collect::<Vec<_>>();
|
||||
for vertical in [false, true] {
|
||||
let fits = measure(vertical);
|
||||
let frame = if vertical { Rect::new(0.0, 0.0, 400.0, fits + 1.0) } else { Rect::new(0.0, 0.0, fits + 1.0, 400.0) };
|
||||
for composer in [Composer::SingleLine, Composer::EveryLine] {
|
||||
let mut t = area(text, style(20.0), frame, Justify::Left);
|
||||
(t.vertical, t.para.composer) = (vertical, composer);
|
||||
assert_eq!(ends(&t), [split, text.len()], "{composer:?} vertical {vertical}: off");
|
||||
t.para.bunri_kinshi = true;
|
||||
assert_eq!(ends(&t), [kept, text.len()], "{composer:?} vertical {vertical}: on");
|
||||
t.para.kinsoku = vectorcraft_doc::Kinsoku::None;
|
||||
assert_eq!(ends(&t), [split, text.len()], "{composer:?} vertical {vertical}: kinsoku None");
|
||||
}
|
||||
}
|
||||
let fits = measure(false);
|
||||
let mut t = area(&format!("{text}\n{text}"), style(20.0), Rect::new(0.0, 0.0, fits + 1.0, 400.0), Justify::Left);
|
||||
t.para.composer = Composer::SingleLine;
|
||||
let on = vectorcraft_doc::ParaStyle { bunri_kinshi: true, ..t.para.clone() };
|
||||
t.set_paragraph_styles(vec![on, t.para.clone()]);
|
||||
let second = text.len() + 1;
|
||||
assert_eq!(ends(&t), [kept, text.len(), second + split, second + text.len()]);
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi: a justified line spreads its room over the gaps between its CJK characters but not
|
||||
/// over the gap inside a vertical kana repeat mark, and still fills its width.
|
||||
#[test]
|
||||
fn bunri_kinshi_adds_no_justification_space_inside_a_pair() {
|
||||
let text = "あ〳〵いう";
|
||||
let upper = "あ".len();
|
||||
let natural = layout(db(), &point(text, style(20.0))).glyphs.iter().find(|g| g.byte == upper).map(|g| g.advance).unwrap();
|
||||
let frame = Rect::new(0.0, 0.0, 300.0, 400.0);
|
||||
let set = |bunri: bool| {
|
||||
let mut t = area(text, style(20.0), frame, Justify::JustifyAll);
|
||||
t.para.bunri_kinshi = bunri;
|
||||
let l = layout(db(), &t);
|
||||
assert!((l.lines[0].x1 - frame.x1).abs() < 1e-6, "{bunri}: {:?}", l.lines[0]);
|
||||
l.glyphs.iter().find(|g| g.byte == upper).map(|g| g.advance).unwrap()
|
||||
};
|
||||
assert!(set(false) > natural + 1.0, "off: the gap after 〳 widens");
|
||||
assert!((set(true) - natural).abs() < 1e-6, "on: the pair keeps its spacing");
|
||||
// Nor does a Maximum Letter Spacing widen the gap between two em dashes on a line with spaces.
|
||||
let text = "ab——cd ef";
|
||||
let dash = "ab".len();
|
||||
let natural = layout(db(), &point(text, style(20.0))).glyphs.iter().find(|g| g.byte == dash).map(|g| g.advance).unwrap();
|
||||
let set = |bunri: bool| {
|
||||
let mut t = area(text, style(20.0), frame, Justify::JustifyAll);
|
||||
t.para.justification.letter_spacing = [0.0, 0.0, 100.0];
|
||||
t.para.bunri_kinshi = bunri;
|
||||
let l = layout(db(), &t);
|
||||
l.glyphs.iter().find(|g| g.byte == dash).map(|g| g.advance).unwrap()
|
||||
};
|
||||
assert!(set(false) > natural + 1.0, "off: letter spacing widens the gap after the first dash");
|
||||
assert!((set(true) - natural).abs() < 1e-6, "on: the dashes keep their spacing");
|
||||
// A Desired Letter Spacing adds no space inside the pair on a ragged line either.
|
||||
let desired = |bunri: bool| {
|
||||
let mut t = area(text, style(20.0), frame, Justify::Left);
|
||||
t.para.justification.letter_spacing = [0.0, 50.0, 100.0];
|
||||
t.para.bunri_kinshi = bunri;
|
||||
let l = layout(db(), &t);
|
||||
let adv = |b: usize| l.glyphs.iter().find(|g| g.byte == b).map(|g| g.advance).unwrap();
|
||||
(adv(dash), adv(0))
|
||||
};
|
||||
let (off, _) = desired(false);
|
||||
assert!(off > natural + 1.0, "off: Desired spacing widens the gap after the first dash");
|
||||
let (on, a) = desired(true);
|
||||
assert!((on - natural).abs() < 1e-6, "on: the dashes keep their spacing");
|
||||
assert!(a > layout(db(), &point(text, style(20.0))).glyphs[0].advance + 1.0, "on: other letters still take Desired spacing");
|
||||
}
|
||||
|
||||
/// No Break (Character panel menu) keeps the marked words on one line, where the same text wraps
|
||||
/// at the space without the mark.
|
||||
#[test]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Paragraph Style Options fields shared by editing and creating a paragraph style: General, Basic
|
||||
//! Paragraph Formats (alignment, indents and spacing), Tabs (the style's tab stops), Composition
|
||||
//! (composer and Roman Hanging Punctuation), Hyphenation, Justification and East Asian Composition
|
||||
//! Settings (Korean Line Break Anywhere).
|
||||
//! Settings (Bunri-Kinshi and Korean Line Break Anywhere).
|
||||
//!
|
||||
//! Each field is unset (empty, or a checkbox in its unset state) or set, and an unset field leaves
|
||||
//! its attribute out of the style. Distances are shown and typed in the General unit and kept in
|
||||
@@ -105,6 +105,7 @@ pub(super) const SPEC: DialogSpec = DialogSpec {
|
||||
"glyph_max",
|
||||
"auto_leading",
|
||||
"single_word",
|
||||
"bunri_kinshi",
|
||||
"korean_line_break_anywhere",
|
||||
"tabs",
|
||||
"section",
|
||||
@@ -234,7 +235,7 @@ pub(crate) fn fields_from_attrs(attrs: &Map<String, Value>, unit: Unit) -> Map<S
|
||||
fields.insert(key.into(), distance_field(attrs.get(key), unit));
|
||||
}
|
||||
fields.insert("composer".into(), attrs.get("composer").filter(|v| v.is_string()).cloned().unwrap_or(Value::Null));
|
||||
for key in ["roman_hanging", "hyphenate", "korean_line_break_anywhere"] {
|
||||
for key in ["roman_hanging", "hyphenate", "bunri_kinshi", "korean_line_break_anywhere"] {
|
||||
fields.insert(key.into(), attrs.get(key).filter(|v| v.is_boolean()).cloned().unwrap_or(Value::Null));
|
||||
}
|
||||
let hyphenation = attrs.get("hyphenation");
|
||||
@@ -378,8 +379,10 @@ pub(crate) fn edited_attrs(d: &Dialog) -> Result<Map<String, Value>, String> {
|
||||
let value = if same { None } else { tab_stops(d, &original, unit)? };
|
||||
keep_or(&mut attrs, "tabs", same, value);
|
||||
|
||||
let same = unchanged("korean_line_break_anywhere", "__resetEastAsian");
|
||||
keep_or(&mut attrs, "korean_line_break_anywhere", same, switch("korean_line_break_anywhere"));
|
||||
for key in ["bunri_kinshi", "korean_line_break_anywhere"] {
|
||||
let same = unchanged(key, "__resetEastAsian");
|
||||
keep_or(&mut attrs, key, same, switch(key));
|
||||
}
|
||||
Ok(attrs)
|
||||
}
|
||||
|
||||
@@ -559,9 +562,11 @@ fn reset_tabs(d: &mut Dialog) {
|
||||
d.fields.insert("__tabSel".into(), json!(0));
|
||||
}
|
||||
|
||||
/// Reset Panel in East Asian Composition Settings: Korean Line Break Anywhere becomes unset.
|
||||
/// Reset Panel in East Asian Composition Settings: Bunri-Kinshi and Korean Line Break Anywhere
|
||||
/// become unset.
|
||||
fn reset_east_asian(d: &mut Dialog) {
|
||||
d.fields.insert("__resetEastAsian".into(), json!(true));
|
||||
d.fields.insert("bunri_kinshi".into(), Value::Null);
|
||||
d.fields.insert("korean_line_break_anywhere".into(), Value::Null);
|
||||
}
|
||||
|
||||
@@ -905,8 +910,12 @@ pub(crate) fn justification_body(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
});
|
||||
}
|
||||
|
||||
/// East Asian Composition Settings: Korean Composition Settings › Korean Line Break Anywhere.
|
||||
/// East Asian Composition Settings: Bunri-Kinshi, and Korean Composition Settings › Korean Line
|
||||
/// Break Anywhere.
|
||||
pub(crate) fn east_asian_body(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
egui::Grid::new("paragraph-style-bunri-kinshi").num_columns(2).spacing([18.0, 8.0]).show(ui, |ui| {
|
||||
switch(ui, d, "bunri_kinshi", tl!("Bunri-Kinshi"), true);
|
||||
});
|
||||
ui.strong(tl!("Korean Composition Settings"));
|
||||
egui::Grid::new("paragraph-style-east-asian").num_columns(2).spacing([18.0, 8.0]).show(ui, |ui| {
|
||||
switch(ui, d, "korean_line_break_anywhere", tl!("Korean Line Break Anywhere"), true);
|
||||
|
||||
@@ -158,7 +158,7 @@ fn reset_panel_clears_only_its_section() {
|
||||
let mut app = app();
|
||||
let all = json!({"justify": "Center", "space_after": 6.0, "composer": "singleLine", "roman_hanging": true, "hyphenate": true,
|
||||
"hyphenation": {"words_longer_than": 8}, "justification": {"auto_leading": 150.0}, "tabs": [{"position": 20.0}],
|
||||
"korean_line_break_anywhere": true});
|
||||
"korean_line_break_anywhere": true, "bunri_kinshi": true});
|
||||
app.run("paraStyle.new", json!({"name": "Body", "attrs": all})).unwrap();
|
||||
let stored = def(&app, "Body");
|
||||
for (section, cleared) in [
|
||||
@@ -167,7 +167,7 @@ fn reset_panel_clears_only_its_section() {
|
||||
("composition", &["composer", "roman_hanging"]),
|
||||
("hyphenation", &["hyphenate", "hyphenation"]),
|
||||
("justification", &["justification"]),
|
||||
("eastAsian", &["korean_line_break_anywhere"]),
|
||||
("eastAsian", &["korean_line_break_anywhere", "bunri_kinshi"]),
|
||||
] {
|
||||
app.run("ui.paraStyleOptions", json!({"name": "Body"})).unwrap();
|
||||
assert!(app.run("ui.paraStyleOptions.resetPanel", json!({})).is_err(), "General has no Reset Panel");
|
||||
@@ -286,6 +286,34 @@ fn korean_line_break_anywhere_is_set_by_the_east_asian_section() {
|
||||
assert!(paras(&app, id)[0].korean_line_break_anywhere, "the style's paragraphs take it");
|
||||
}
|
||||
|
||||
/// East Asian Composition Settings › Bunri-Kinshi sets the style's attribute, which its paragraphs
|
||||
/// take; set off again, the style holds it off, and unset, the style leaves it out.
|
||||
#[test]
|
||||
fn bunri_kinshi_is_set_by_the_east_asian_section() {
|
||||
let mut app = app();
|
||||
let id = app.run("text.create", json!({"x": 10, "y": 40, "text": "あ——い"})).unwrap()["id"].as_u64().unwrap();
|
||||
app.run("paraStyle.new", json!({"name": "Body", "attrs": {}})).unwrap();
|
||||
app.run("paraStyle.apply", json!({"name": "Body", "id": id})).unwrap();
|
||||
assert!(!paras(&app, id)[0].bunri_kinshi);
|
||||
app.run("ui.paraStyleOptions", json!({"name": "Body"})).unwrap();
|
||||
assert!(app.ui.dialog.as_ref().unwrap().fields["bunri_kinshi"].is_null());
|
||||
set(&mut app, "section", json!("eastAsian"));
|
||||
set(&mut app, "bunri_kinshi", json!(true));
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert_eq!(def(&app, "Body").get("bunri_kinshi"), Some(&json!(true)));
|
||||
assert!(paras(&app, id)[0].bunri_kinshi, "the style's paragraphs take it");
|
||||
app.run("ui.paraStyleOptions", json!({"name": "Body"})).unwrap();
|
||||
assert_eq!(app.ui.dialog.as_ref().unwrap().fields["bunri_kinshi"], json!(true));
|
||||
set(&mut app, "bunri_kinshi", json!(false));
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert_eq!(def(&app, "Body").get("bunri_kinshi"), Some(&json!(false)));
|
||||
assert!(!paras(&app, id)[0].bunri_kinshi);
|
||||
app.run("ui.paraStyleOptions", json!({"name": "Body"})).unwrap();
|
||||
set(&mut app, "bunri_kinshi", Value::Null);
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert_eq!(def(&app, "Body").get("bunri_kinshi"), None);
|
||||
}
|
||||
|
||||
/// The rows of the `tabs` field of the open dialog.
|
||||
fn tab_rows(app: &VectorcraftApp) -> Vec<Value> {
|
||||
app.ui.dialog.as_ref().unwrap().fields["tabs"].as_array().cloned().unwrap_or_default()
|
||||
@@ -534,6 +562,7 @@ fn every_section_draws_its_fields() {
|
||||
("hyphenation", "Hyphenation Zone:"),
|
||||
("justification", "Glyph Scaling:"),
|
||||
("eastAsian", "Korean Line Break Anywhere"),
|
||||
("eastAsian", "Bunri-Kinshi"),
|
||||
] {
|
||||
set(&mut app, "section", json!(section));
|
||||
let mut texts = String::new();
|
||||
|
||||
@@ -2856,6 +2856,7 @@ digits Malayalam Малаялам
|
||||
Roman Baseline Латинска основна линия
|
||||
Roman Hanging Punctuation Латинска висяща пунктуация
|
||||
Korean Line Break Anywhere Пренасяне на корейски текст навсякъде
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Настройки за източноазиатска композиция
|
||||
Korean Composition Settings Настройки за корейска композиция
|
||||
Rotate Завъртане
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2007,6 +2007,7 @@ digits Malayalam Malajalam
|
||||
Right-to-Left Paragraph Direction Smjer pasusa s desna nalijevo
|
||||
Roman Hanging Punctuation Latinična viseća interpunkcija
|
||||
Korean Line Break Anywhere Prelom korejskog reda bilo gdje
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Postavke istočnoazijske kompozicije
|
||||
Korean Composition Settings Postavke korejske kompozicije
|
||||
Select a text object to edit its paragraph attributes. Odaberite tekstualni objekat da uredite njegove atribute pasusa.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3663,6 +3663,7 @@ digits Malayalam Malaiàlam
|
||||
Roman Baseline Línia de base romana
|
||||
Roman Hanging Punctuation Puntuació penjant romana
|
||||
Korean Line Break Anywhere Salt de línia coreà a qualsevol lloc
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Configuració de composició de l’Àsia oriental
|
||||
Korean Composition Settings Configuració de composició coreana
|
||||
Rotate Gira
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2038,6 +2038,7 @@ digits Malayalam Malajálamské
|
||||
Right-to-Left Paragraph Direction Směr odstavce zprava doleva
|
||||
Roman Hanging Punctuation Visící latinková interpunkce
|
||||
Korean Line Break Anywhere Zalomení korejského řádku kdekoli
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Nastavení východoasijské sazby
|
||||
Korean Composition Settings Nastavení korejské sazby
|
||||
Select a text object to edit its paragraph attributes. Vyberte textový objekt, abyste mohli upravit atributy jeho odstavce.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1840,6 +1840,7 @@ digits Malayalam Malayalam
|
||||
Right-to-Left Paragraph Direction Afsnitsretning fra højre mod venstre
|
||||
Roman Hanging Punctuation Romersk hængende tegnsætning
|
||||
Korean Line Break Anywhere Koreansk linjeskift hvor som helst
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Indstillinger for østasiatisk komposition
|
||||
Korean Composition Settings Indstillinger for koreansk komposition
|
||||
Select a text object to edit its paragraph attributes. Markér et tekstobjekt for at redigere dets afsnitsattributter.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2902,6 +2902,7 @@ digits Malayalam Malayalam
|
||||
Roman Baseline Lateinische Grundlinie
|
||||
Roman Hanging Punctuation Hängende Interpunktion (lateinisch)
|
||||
Korean Line Break Anywhere Koreanischer Zeilenumbruch überall
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Einstellungen für ostasiatischen Satz
|
||||
Korean Composition Settings Einstellungen für koreanischen Satz
|
||||
Rotate Drehen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1978,6 +1978,7 @@ font-technology Variable Μεταβλητές
|
||||
Rise… Ανύψωση…
|
||||
Roman Hanging Punctuation Κρεμαστή στίξη όρθιας γραφής
|
||||
Korean Line Break Anywhere Αλλαγή γραμμής κορεατικών οπουδήποτε
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Ρυθμίσεις σύνθεσης ανατολικής Ασίας
|
||||
Korean Composition Settings Ρυθμίσεις κορεατικής σύνθεσης
|
||||
Rotate Περιστροφή
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2935,6 +2935,7 @@ digits Malayalam Malayálam
|
||||
Roman Baseline Línea de base latina
|
||||
Roman Hanging Punctuation Puntuación colgante romana
|
||||
Korean Line Break Anywhere Salto de línea coreano en cualquier lugar
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Ajustes de composición de Asia oriental
|
||||
Korean Composition Settings Ajustes de composición coreana
|
||||
Rotate Rotar
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1999,6 +1999,7 @@ digits Malayalam Malajalam
|
||||
Right-to-Left Paragraph Direction Kappaleen suunta oikealta vasemmalle
|
||||
Roman Hanging Punctuation Latinalaiset riippuvat välimerkit
|
||||
Korean Line Break Anywhere Korean rivinvaihto missä tahansa
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Itäaasialaisen ladonnan asetukset
|
||||
Korean Composition Settings Korean ladonnan asetukset
|
||||
Select a text object to edit its paragraph attributes. Valitse tekstiobjekti, jonka kappalemääritteitä haluat muokata.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2927,6 +2927,7 @@ digits Malayalam Malayalam
|
||||
Roman Baseline Ligne de base romaine
|
||||
Roman Hanging Punctuation Ponctuation romaine hors justification
|
||||
Korean Line Break Anywhere Saut de ligne coréen n’importe où
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Paramètres de composition d’Asie orientale
|
||||
Korean Composition Settings Paramètres de composition coréenne
|
||||
Rotate Rotation
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -4000,6 +4000,7 @@ antiAlias Sharp शार्प
|
||||
Roman Baseline रोमन बेसलाइन
|
||||
Roman Hanging Punctuation रोमन हैंगिंग विराम चिह्न
|
||||
Korean Line Break Anywhere कोरियाई लाइन ब्रेक कहीं भी
|
||||
Bunri-Kinshi बुनरी-किंशी
|
||||
East Asian Composition Settings पूर्वी एशियाई संरचना सेटिंग्स
|
||||
Korean Composition Settings कोरियाई संरचना सेटिंग्स
|
||||
Rotate घुमाएँ
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3510,6 +3510,7 @@ mark-style Japanese Japán
|
||||
Roman Baseline Latin alapvonal
|
||||
Roman Hanging Punctuation Latin függő írásjelek
|
||||
Korean Line Break Anywhere Koreai sortörés bárhol
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Kelet-ázsiai szedési beállítások
|
||||
Korean Composition Settings Koreai szedési beállítások
|
||||
Rotate Elforgatás
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1840,6 +1840,7 @@ digits Malayalam Malayalam
|
||||
Right-to-Left Paragraph Direction Arah paragraf kanan ke kiri
|
||||
Roman Hanging Punctuation Tanda baca gantung Romawi
|
||||
Korean Line Break Anywhere Putus baris Korea di mana saja
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Pengaturan komposisi Asia Timur
|
||||
Korean Composition Settings Pengaturan komposisi Korea
|
||||
Select a text object to edit its paragraph attributes. Pilih objek teks untuk mengedit atribut paragrafnya.
|
||||
|
||||
|
@@ -2978,6 +2978,7 @@ digits Malayalam Malayalam
|
||||
Roman Baseline Linea di base romana
|
||||
Roman Hanging Punctuation Punteggiatura sporgente romana
|
||||
Korean Line Break Anywhere Interruzione di riga coreana ovunque
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Impostazioni di composizione dell’Asia orientale
|
||||
Korean Composition Settings Impostazioni di composizione coreana
|
||||
Rotate Ruota
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2966,6 +2966,7 @@ mark-style Japanese 日本式
|
||||
Right: 右:
|
||||
Roman Hanging Punctuation 欧文ぶら下がり
|
||||
Korean Line Break Anywhere 韓国語の任意位置での改行
|
||||
Bunri-Kinshi 分離禁止
|
||||
East Asian Composition Settings 東アジア言語の組版設定
|
||||
Korean Composition Settings 韓国語の組版設定
|
||||
Rotate 回転
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1769,6 +1769,7 @@ digits Malayalam მალაიალამური
|
||||
Right-to-Left Paragraph Direction აბზაცის მიმართულება მარჯვნიდან მარცხნივ
|
||||
Roman Hanging Punctuation ლათინური გამოწეული პუნქტუაცია
|
||||
Korean Line Break Anywhere კორეული სტრიქონის გადატანა ნებისმიერ ადგილას
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings აღმოსავლეთ აზიური აწყობის პარამეტრები
|
||||
Korean Composition Settings კორეული აწყობის პარამეტრები
|
||||
Select a text object to edit its paragraph attributes. აბზაცის ატრიბუტების რედაქტირებისთვის მონიშნეთ ტექსტური ობიექტი.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2955,6 +2955,7 @@ mark-style Japanese 일본식
|
||||
Right: 오른쪽:
|
||||
Roman Hanging Punctuation 로마자 걸림 문장 부호
|
||||
Korean Line Break Anywhere 한글 어디서나 줄 바꿈
|
||||
Bunri-Kinshi 분리 금지
|
||||
East Asian Composition Settings 동아시아 조판 설정
|
||||
Korean Composition Settings 한글 조판 설정
|
||||
Rotate 회전
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1854,6 +1854,7 @@ digits Malayalam Malayalam
|
||||
Right-to-Left Paragraph Direction Alinearichting van rechts naar links
|
||||
Roman Hanging Punctuation Romeinse hangende leestekens
|
||||
Korean Line Break Anywhere Koreaans regeleinde overal
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Instellingen voor Oost-Aziatische zetting
|
||||
Korean Composition Settings Instellingen voor Koreaanse zetting
|
||||
Select a text object to edit its paragraph attributes. Selecteer een tekstobject om de alineakenmerken ervan te bewerken.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1956,6 +1956,7 @@ digits Malayalam Malajalam
|
||||
Right-to-Left Paragraph Direction Kierunek akapitu od prawej do lewej
|
||||
Roman Hanging Punctuation Wysunięta interpunkcja łacińska
|
||||
Korean Line Break Anywhere Koreański podział wiersza w dowolnym miejscu
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Ustawienia składu wschodnioazjatyckiego
|
||||
Korean Composition Settings Ustawienia składu koreańskiego
|
||||
Select a text object to edit its paragraph attributes. Zaznacz obiekt tekstowy, aby edytować atrybuty akapitu.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2465,6 +2465,7 @@ digits Malayalam Malaiala
|
||||
Roman Baseline Linha de Base Romana
|
||||
Roman Hanging Punctuation Pontuação Pendurada Romana
|
||||
Korean Line Break Anywhere Quebra de Linha Coreana em Qualquer Lugar
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Configurações de Composição do Leste Asiático
|
||||
Korean Composition Settings Configurações de Composição Coreana
|
||||
Rotate Girar
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -2965,6 +2965,7 @@ digits Malayalam Малаялам
|
||||
Roman Baseline Римская базовая линия
|
||||
Roman Hanging Punctuation Римская висячая пунктуация
|
||||
Korean Line Break Anywhere Перенос корейского текста в любом месте
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Параметры восточноазиатского набора
|
||||
Korean Composition Settings Параметры корейского набора
|
||||
Rotate Повернуть
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2871,6 +2871,7 @@ digits Malayalam Malayalam
|
||||
Roman Baseline Baslinje (roman)
|
||||
Roman Hanging Punctuation Hängande interpunktion (roman)
|
||||
Korean Line Break Anywhere Koreansk radbrytning var som helst
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Inställningar för östasiatisk sättning
|
||||
Korean Composition Settings Inställningar för koreansk sättning
|
||||
Rotate Rotera
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -2738,6 +2738,7 @@ digits Malayalam Malayalam
|
||||
Roman Baseline Roma Taban Çizgisi
|
||||
Roman Hanging Punctuation Roma Asılı Noktalama İşaretleri
|
||||
Korean Line Break Anywhere Korece Satırı Her Yerde Kes
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Doğu Asya Dizgi Ayarları
|
||||
Korean Composition Settings Korece Dizgi Ayarları
|
||||
Rotate Döndür
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -2970,6 +2970,7 @@ digits Malayalam Малаялам
|
||||
Roman Baseline Римська базова лінія
|
||||
Roman Hanging Punctuation Римська висяча пунктуація
|
||||
Korean Line Break Anywhere Перенесення корейського тексту будь-де
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Параметри східноазійського набору
|
||||
Korean Composition Settings Параметри корейського набору
|
||||
Rotate Повернути
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 182 and column 5.
|
@@ -3274,6 +3274,7 @@ mark-style Japanese Kiểu Nhật
|
||||
Roman Baseline Đường cơ sở Roman
|
||||
Roman Hanging Punctuation Dấu câu treo Roman
|
||||
Korean Line Break Anywhere Ngắt dòng tiếng Hàn ở bất kỳ đâu
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
East Asian Composition Settings Cài đặt dàn trang Đông Á
|
||||
Korean Composition Settings Cài đặt dàn trang tiếng Hàn
|
||||
Rotate Xoay
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 204 and column 5.
|
@@ -2834,6 +2834,7 @@ digits Malayalam 马拉雅拉姆数字
|
||||
Roman Baseline 罗马基线
|
||||
Roman Hanging Punctuation 西文悬挂标点
|
||||
Korean Line Break Anywhere 韩文任意位置换行
|
||||
Bunri-Kinshi 分离禁止
|
||||
East Asian Composition Settings 东亚排版设置
|
||||
Korean Composition Settings 韩文排版设置
|
||||
Rotate 旋转
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3946,6 +3946,7 @@ digits Malayalam 馬來亞拉姆數字
|
||||
Roman Baseline 羅馬基線
|
||||
Roman Hanging Punctuation 羅馬懸掛標點
|
||||
Korean Line Break Anywhere 韓文任意位置換行
|
||||
Bunri-Kinshi 分離禁止
|
||||
East Asian Composition Settings 東亞排版設定
|
||||
Korean Composition Settings 韓文排版設定
|
||||
Rotate 旋轉
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -877,6 +877,11 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
});
|
||||
});
|
||||
// Inseparable pairs stay on one line; only with a kinsoku set.
|
||||
let (kinsoku_on, bunri) = bunri_kinshi_item(app);
|
||||
if menu_item(ui, tl!("Bunri-Kinshi"), has && kinsoku_on, bunri) {
|
||||
toggle_bunri_kinshi(app);
|
||||
}
|
||||
// Korean lines break between any two syllables, not only between words.
|
||||
let anywhere = shared_para(app, |p| p.korean_line_break_anywhere) == Some(true);
|
||||
if menu_item(ui, tl!("Korean Line Break Anywhere"), has, anywhere) {
|
||||
@@ -904,6 +909,19 @@ fn set_kinsoku_type(app: &mut VectorcraftApp, key: &str) {
|
||||
format(app, json!({"kinsokuType": key}));
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi's menu item for the paragraphs the panel acts on ([`format`]): (available, checked).
|
||||
/// It is available when none of them has kinsoku None, and checked when every one of them has it.
|
||||
fn bunri_kinshi_item(app: &VectorcraftApp) -> (bool, bool) {
|
||||
(shared_para(app, |p| p.kinsoku == Kinsoku::None) == Some(false), shared_para(app, |p| p.bunri_kinshi) == Some(true))
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi (Paragraph panel menu): a click turns it off for all the paragraphs the panel acts
|
||||
/// on ([`format`]) when every one of them has it, and on for all of them otherwise, in one undo step.
|
||||
fn toggle_bunri_kinshi(app: &mut VectorcraftApp) {
|
||||
let on = shared_para(app, |p| p.bunri_kinshi) == Some(true);
|
||||
format(app, json!({"bunriKinshi": !on}));
|
||||
}
|
||||
|
||||
/// Korean Line Break Anywhere (Paragraph panel menu): the menu item is checked when every paragraph
|
||||
/// the panel acts on ([`format`]) has it, and a click turns it off for all of them then, and on for
|
||||
/// all of them otherwise, in one undo step.
|
||||
@@ -915,8 +933,8 @@ fn toggle_korean_line_break_anywhere(app: &mut VectorcraftApp) {
|
||||
/// Reset Panel: the paragraphs the panel acts on ([`format`]) take Auto alignment, no list, no
|
||||
/// indents or paragraph spacing, Hyphenate off with the default Hyphenation and Justification
|
||||
/// options, Auto direction, Bottom-to-Bottom Leading, the Line-end Punctuation Half Width Mojikumi
|
||||
/// Set, Regular burasagari, the Hard kinsoku set, Push Out Only, the Every-line Composer, Roman
|
||||
/// Hanging Punctuation and Korean Line Break Anywhere off, no kashidas and no tab stops, as one undo
|
||||
/// Set, Regular burasagari, the Hard kinsoku set, Push Out Only, the Every-line Composer, Bunri-Kinshi,
|
||||
/// Roman Hanging Punctuation and Korean Line Break Anywhere off, no kashidas and no tab stops, as one undo
|
||||
/// step named Reset Panel (inside an undo group that is already open, as part of its step).
|
||||
fn reset_panel(app: &mut VectorcraftApp) {
|
||||
let h = HyphenationOptions::default();
|
||||
@@ -937,7 +955,8 @@ fn reset_panel(app: &mut VectorcraftApp) {
|
||||
"wordSpacing": j.word_spacing, "letterSpacing": j.letter_spacing, "glyphScaling": j.glyph_scaling,
|
||||
"autoLeading": j.auto_leading, "singleWordJustification": "fullJustify",
|
||||
"direction": "auto", "leadingModel": "romanBaseline", "mojikumi": "lineEndHalf", "burasagari": "standard", "kinsoku": "hard",
|
||||
"kinsokuType": "pushOutOnly", "composer": "everyLine", "romanHangingPunctuation": false, "koreanLineBreakAnywhere": false
|
||||
"kinsokuType": "pushOutOnly", "composer": "everyLine", "romanHangingPunctuation": false, "koreanLineBreakAnywhere": false,
|
||||
"bunriKinshi": false
|
||||
}),
|
||||
);
|
||||
para_cmd(app, "text.tabs.clear", json!({}));
|
||||
|
||||
@@ -166,6 +166,48 @@ fn korean_line_break_anywhere_toggles_the_selected_paragraphs_in_one_undo_step()
|
||||
assert_eq!(flags(&app), (false, false), "Reset Panel turns it off");
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi: new type has it off; the menu item turns it on for the paragraphs the Type tool's
|
||||
/// selection touches in one undo step, is unchecked while the selected paragraphs differ, and is
|
||||
/// unavailable while any of them has kinsoku None, which keeps the setting. Reset Panel turns it off.
|
||||
#[test]
|
||||
fn bunri_kinshi_toggle_follows_kinsoku_and_the_selected_paragraphs() {
|
||||
let (mut app, id) = editing_text("あ——い\nう……え\n");
|
||||
app.session.prefs.show_east_asian_options = true;
|
||||
let flags = |app: &VectorcraftApp| {
|
||||
let node = app.session.active().unwrap().doc.node(NodeId(id.as_u64().unwrap())).unwrap();
|
||||
let NodeKind::Text(text) = &node.kind else { panic!("text") };
|
||||
(text.para_at(0).bunri_kinshi, text.para_at(1).bunri_kinshi)
|
||||
};
|
||||
assert_eq!(flags(&app), (false, false), "new type has it off");
|
||||
select_range(&mut app, 0, 3);
|
||||
assert_eq!(bunri_kinshi_item(&app), (true, false));
|
||||
let history = app.session.active().unwrap().history.undo.len();
|
||||
toggle_bunri_kinshi(&mut app);
|
||||
assert_eq!(flags(&app), (true, false));
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), history + 1);
|
||||
assert_eq!(bunri_kinshi_item(&app), (true, true));
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
assert_eq!(bunri_kinshi_item(&app), (true, false), "mixed: unchecked");
|
||||
toggle_bunri_kinshi(&mut app);
|
||||
assert_eq!(flags(&app), (true, true));
|
||||
// Kinsoku None on one paragraph: the item is unavailable and the setting stays.
|
||||
let second = "あ——い\n".len();
|
||||
app.run("text.setFormat", json!({"id": id, "start": second, "end": second, "kinsoku": "none"})).unwrap();
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
assert_eq!(bunri_kinshi_item(&app), (false, true));
|
||||
assert_eq!(flags(&app), (true, true));
|
||||
app.run("text.setFormat", json!({"id": id, "kinsoku": "soft"})).unwrap();
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
assert_eq!(bunri_kinshi_item(&app), (true, true));
|
||||
toggle_bunri_kinshi(&mut app);
|
||||
assert_eq!(flags(&app), (false, false));
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
toggle_bunri_kinshi(&mut app);
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
reset_panel(&mut app);
|
||||
assert_eq!(flags(&app), (false, false), "Reset Panel turns it off");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paragraph_mixed_indent_fields_show_blank() {
|
||||
let (mut app, id) = editing_text("A\nB\n");
|
||||
|
||||
+21
@@ -7536,6 +7536,27 @@ Panel sets it back to Push Out Only. One undo step.
|
||||
{"name":"run_command","arguments":{"command":"text.setFormat","params":{"kinsokuType":"pushInFirst"}}}
|
||||
```
|
||||
|
||||
## Bunri-Kinshi
|
||||
|
||||
`text.setFormat {bunriKinshi: bool}` (Paragraph panel menu › Bunri-Kinshi, shown with the East Asian options) turns it
|
||||
on or off for the paragraphs of the selected type (or `ids`, or the paragraphs a `start` / `end` range touches). On, a
|
||||
line never breaks inside an inseparable pair: two em dashes (U+2014), two horizontal ellipses (U+2026), two two-dot
|
||||
leaders (U+2025), or the upper half of a vertical kana repeat mark (U+3033 or U+3034) followed by its lower half
|
||||
(U+3035), the pairs W3C JLREQ lists for its class cl-08 (https://www.w3.org/TR/jlreq/#cl-08), which are VectorCraft's
|
||||
set. A chain of em dashes stays together as well. A pair is two neighboring characters, whatever their fonts and
|
||||
styles; a forced line break between them ends the line as before. Both composers, vertical type, Kinsoku Shori Type,
|
||||
hyphenation and No Break follow it, and a pair wider than the line stays whole on it. Justification adds no space inside
|
||||
a pair. The setting works only with a Kinsoku Set: with Kinsoku Set None the paragraph keeps the value without effect,
|
||||
and the menu item is unavailable. Off by default, for new type and for paragraphs saved before the option. It is saved
|
||||
with the paragraph (`bunri_kinshi` in `para`) only when on, paragraph styles carry it (Paragraph Style Options › East
|
||||
Asian Composition Settings), and Reset Panel turns it off. A value that is not true or false is refused. One undo
|
||||
step. `.ai` editing data does not hold it, and a save reports a paragraph with it on and a pair in it as left out. The help page:
|
||||
https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html
|
||||
|
||||
```json
|
||||
{"name":"run_command","arguments":{"command":"text.setFormat","params":{"bunriKinshi":true}}}
|
||||
```
|
||||
|
||||
## Korean Line Break Anywhere
|
||||
|
||||
`text.setFormat {koreanLineBreakAnywhere: bool}` (Paragraph panel menu › Korean Line Break Anywhere, shown with the
|
||||
|
||||
@@ -1218,8 +1218,9 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Type › Optical Margin Alignment (`type.opticalMarginAlignment`) hangs the punctuation and letter edges at the ends of a type object's lines outside its margins: at the left of left-aligned lines, at the right of right-aligned lines, and at both ends of centered and justified lines, in point and area type of left-to-right paragraphs. Quotation marks, hyphens, full stops and commas hang wholly; asterisks, tildes, ellipses, en and em dashes, colons and semicolons hang by half; and A, V, W, Y, v, w and y hang by a tenth of their width. It is off by default and saved with the type object. Justification's Glyph Scaling leaves the glyphs that hang at their width, so they hang exactly their share, and Standard burasagari counts what hangs at a line's start as room before hanging a comma; `crates/text/src/tests/hang.rs` checks whole paragraphs with both composers, ragged, centred and justified, with Line-end Punctuation Half Width and bidirectional lines.
|
||||
Optical Margin Alignment and Roman Hanging Punctuation hang right-to-left paragraphs of point and area type, and type on a path whose first paragraph runs right to left, too. Auto aligns a right-to-left line at its right, or at the end bracket of a path, so it hangs there. A right-to-left line is read from right to left: where it hangs at its left margin, `."` ending it hangs both glyphs.
|
||||
The Paragraph panel menu's Kinsoku Shori Type (`text.setFormat {kinsokuType}`, with the East Asian options) picks Push In First, Push Out First or Push Out Only for each paragraph: a character the Kinsoku Set keeps off a line's start or end is set on the line, with the line's gaps next to CJK characters closed by at most a tenth of an em each to fit, or moved to the next line with the character before it. Push Out First pushes in only when pushing out would leave the line more than an em short. Push Out Only is the default, the setting is saved only when it is not, and paragraph styles carry it.
|
||||
The Paragraph panel menu's Bunri-Kinshi (`text.setFormat {bunriKinshi}`, with the East Asian options, and the East Asian Composition Settings section of Paragraph Style Options) keeps inseparable pairs on one line in each paragraph that has it: two em dashes, two ellipses, two two-dot leaders and the two halves of a vertical kana repeat mark (the pairs of W3C JLREQ's class cl-08, VectorCraft's set). Both composers and vertical type follow it, and justification adds no space inside a pair. It works with a Kinsoku Set only, is off by default and is saved only when on; editing the set of pairs is not available.
|
||||
The Paragraph panel menu's Korean Line Break Anywhere (`text.setFormat {koreanLineBreakAnywhere}`, with the East Asian options, and the East Asian Composition Settings section of Paragraph Style Options) sets for each paragraph whether a line may break between any two Hangul syllables. When it is off, a word that contains Hangul breaks only at its spaces and after punctuation, or where the word is wider than the line, and takes no hyphen. New type has it off; paragraphs saved before the option read as on, so their lines do not move.
|
||||
The Paragraph panel menu's Reset Panel (`text.setStyle`, `text.setFormat` and `text.tabs.clear`) gives the selected type's paragraphs, or the paragraphs the Type tool's selection touches, Auto alignment, no indents or paragraph spacing, Hyphenate off with the default Hyphenation and Justification options, Auto direction, Bottom-to-Bottom Leading, the Line-end Punctuation Half Width Mojikumi Set, Regular burasagari, the Hard kinsoku set, Push Out Only, the Every-line Composer, Roman Hanging Punctuation and Korean Line Break Anywhere off, no kashidas and no tab stops, as one undo step.
|
||||
The Paragraph panel menu's Reset Panel (`text.setStyle`, `text.setFormat` and `text.tabs.clear`) gives the selected type's paragraphs, or the paragraphs the Type tool's selection touches, Auto alignment, no indents or paragraph spacing, Hyphenate off with the default Hyphenation and Justification options, Auto direction, Bottom-to-Bottom Leading, the Line-end Punctuation Half Width Mojikumi Set, Regular burasagari, the Hard kinsoku set, Push Out Only, the Every-line Composer, Bunri-Kinshi, Roman Hanging Punctuation and Korean Line Break Anywhere off, no kashidas and no tab stops, as one undo step.
|
||||
The Paragraph panel menu's Hyphenation… (`ui.hyphenation`, `text.setFormat {wordsLongerThan, afterFirst, beforeLast, hyphenLimit, hyphenationZone, hyphenateCapitalized}`) sets each paragraph's hyphenation limits: the shortest word that breaks, the fewest letters on each side of the hyphen, the most hyphenated lines in a row, a zone at the right edge where the Single-line Composer breaks before a word instead of hyphenating it, and whether capitalized words break. The defaults are words longer than 5 letters, 3 letters on each side, no limit or zone, and capitalized words hyphenated; paragraph styles and the native file keep the options.
|
||||
PDF export with type as text writes the hyphen that ends a line broken inside a word as a hyphen character where the line draws it, and the file opens with the hyphen in the line's text; kashidas are drawn as paths.
|
||||
The Paragraph panel's Insert Kashidas (with the Indic options; `text.setFormat {kashida}`) lengthens each Arabic word of a justified horizontal area type line with a kashida, a tatweel between its last pair of joined letters, before the word spaces widen: Short, Medium and Long kashidas are at most a quarter, half and a whole em long, Stylistic ones are whole tatweels up to an em, and None (the default) leaves the line as before; paragraph styles and the native file keep the setting.
|
||||
|
||||
Reference in New Issue
Block a user