mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-16 15:26:50 +00:00
Paragraph: Kurikaeshi Moji Shori draws a line-start repeat mark as the character it repeats
Paragraph panel menu > Kurikaeshi Moji Shori (text.setFormat
{kurikaeshiMojiShori}) is a paragraph attribute, off by default, saved
only when on and carried by paragraph styles. On, a repeat mark (々, ゝ,
ゞ, ヽ, ヾ) that starts a line of point or area type is drawn as the
character it repeats, with the mark's width, and the text keeps the
mark. Threaded type looks back into the frames before when a paragraph
continues. Live SVG text writes the drawn character and places the
text after it.
This commit is contained in:
@@ -316,6 +316,7 @@ fn content_hash(text: &crate::TextObject) -> Option<[u64; 2]> {
|
||||
let inline_bounds = text.runs.iter().filter_map(|r| r.inline.as_ref()).map(|i| i.bounds.map(|b| [b.x0, b.y0, b.x1, b.y1].map(f64::to_bits)));
|
||||
for h in &mut feed.0 {
|
||||
h.write_u8(u8::from(text.first_para_continues));
|
||||
h.write_u32(text.first_para_lead.map_or(u32::MAX, u32::from));
|
||||
for b in inline_bounds.clone() {
|
||||
match b {
|
||||
None => h.write_u8(0),
|
||||
|
||||
@@ -67,6 +67,12 @@ pub struct TextObject {
|
||||
/// it on a frame that leaves its thread and on a copy. Not saved.
|
||||
#[serde(skip)]
|
||||
pub first_para_continues: bool,
|
||||
/// Threaded text whose first paragraph continues ([`TextObject::first_para_continues`]): the
|
||||
/// last character of that paragraph in the frames before that a repeat mark could stand for
|
||||
/// (Kurikaeshi Moji Shori), or None. The engine sets it with `first_para_continues`; layout
|
||||
/// reads it only while `first_para_continues` is on. Not saved.
|
||||
#[serde(skip)]
|
||||
pub first_para_lead: Option<char>,
|
||||
/// Area Type Options (area type only).
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
pub area: AreaOptions,
|
||||
|
||||
@@ -94,6 +94,7 @@ impl TextObject {
|
||||
para: ParaStyle::default(),
|
||||
paras: Vec::new(),
|
||||
first_para_continues: false,
|
||||
first_para_lead: None,
|
||||
area: AreaOptions::default(),
|
||||
path_effect: PathEffect::default(),
|
||||
path_align: PathAlign::default(),
|
||||
|
||||
@@ -271,6 +271,9 @@ pub struct ParaStyle {
|
||||
/// 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,
|
||||
/// Kurikaeshi Moji Shori (Paragraph panel menu): a repeat mark (々, ゝ, ゞ, ヽ or ヾ) that starts
|
||||
/// a line is drawn as the character it repeats, and the text keeps the mark. Off by default.
|
||||
pub kurikaeshi_moji_shori: 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.
|
||||
@@ -375,6 +378,8 @@ struct ParaStyleFile {
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
bunri_kinshi: bool,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
kurikaeshi_moji_shori: bool,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
roman_hanging: bool,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
kashida: Kashida,
|
||||
@@ -412,6 +417,7 @@ impl From<ParaStyle> for ParaStyleFile {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
kurikaeshi_moji_shori,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -439,6 +445,7 @@ impl From<ParaStyle> for ParaStyleFile {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
kurikaeshi_moji_shori,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -470,6 +477,7 @@ impl From<ParaStyleFile> for ParaStyle {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
kurikaeshi_moji_shori,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -496,6 +504,7 @@ impl From<ParaStyleFile> for ParaStyle {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
kurikaeshi_moji_shori,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1806,6 +1806,7 @@ fn create_in_path(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
para: super::create::new_type_para(),
|
||||
paras: Vec::new(),
|
||||
first_para_continues: false,
|
||||
first_para_lead: None,
|
||||
area: Default::default(),
|
||||
path_effect: Default::default(),
|
||||
path_align: Default::default(),
|
||||
@@ -2112,6 +2113,7 @@ fn headline_tracking(t: &TextObject, target: f64) -> Option<f64> {
|
||||
para: Default::default(),
|
||||
paras: Vec::new(),
|
||||
first_para_continues: false,
|
||||
first_para_lead: None,
|
||||
area: Default::default(),
|
||||
path_effect: Default::default(),
|
||||
path_align: Default::default(),
|
||||
|
||||
@@ -253,6 +253,7 @@ pub fn para_attrs(v: &ParaStyle) -> Map<String, Value> {
|
||||
("kinsoku", json!(v.kinsoku)),
|
||||
("kinsoku_type", json!(v.kinsoku_type)),
|
||||
("bunri_kinshi", json!(v.bunri_kinshi)),
|
||||
("kurikaeshi_moji_shori", json!(v.kurikaeshi_moji_shori)),
|
||||
("roman_hanging", json!(v.roman_hanging)),
|
||||
("kashida", json!(v.kashida)),
|
||||
("korean_line_break_anywhere", json!(v.korean_line_break_anywhere)),
|
||||
|
||||
@@ -225,7 +225,9 @@ pub(crate) fn reflow(before: &Document, doc: &mut Document) {
|
||||
.collect();
|
||||
let refs: Vec<&TextObject> = frames.iter().collect();
|
||||
let parts = vectorcraft_text::thread::distribute(vectorcraft_text::FontDb::global(), &refs, &story, ¶s);
|
||||
for (id, part) in live.iter().zip(parts) {
|
||||
let texts: Vec<String> = parts.iter().map(|p| p.runs.iter().map(|r| r.text.as_str()).collect()).collect();
|
||||
let leads = first_para_leads(&texts, &parts.iter().map(|p| p.continues).collect::<Vec<_>>());
|
||||
for ((id, part), lead) in live.iter().zip(parts).zip(leads) {
|
||||
if let Some(NodeKind::Text(t)) = doc.node_mut(*id).map(|n| &mut n.kind) {
|
||||
let mut next = (**t).clone();
|
||||
next.runs = part.runs;
|
||||
@@ -241,6 +243,7 @@ pub(crate) fn reflow(before: &Document, doc: &mut Document) {
|
||||
|| part.list_count != t.list_count
|
||||
|| part.list_level_counts != t.list_level_counts
|
||||
|| continues != t.first_para_continues
|
||||
|| lead != t.first_para_lead
|
||||
{
|
||||
t.runs = next.runs;
|
||||
t.para = next.para;
|
||||
@@ -250,6 +253,7 @@ pub(crate) fn reflow(before: &Document, doc: &mut Document) {
|
||||
t.list_count = part.list_count;
|
||||
t.list_level_counts = part.list_level_counts;
|
||||
t.first_para_continues = continues;
|
||||
t.first_para_lead = lead;
|
||||
refresh_bounds(t);
|
||||
}
|
||||
}
|
||||
@@ -384,17 +388,43 @@ pub(crate) fn mark_continued(doc: &mut Document) {
|
||||
let live: Vec<NodeId> = thread.into_iter().filter(|id| text_of(doc, *id).is_some()).collect();
|
||||
let frames: Vec<&TextObject> = live.iter().filter_map(|id| text_of(doc, *id)).collect();
|
||||
let marks = vectorcraft_text::thread::continued(&frames);
|
||||
for (id, on) in live.iter().zip(marks) {
|
||||
let texts: Vec<String> = frames.iter().map(|t| t.plain_text()).collect();
|
||||
let leads = first_para_leads(&texts, &marks);
|
||||
for ((id, on), lead) in live.iter().zip(marks).zip(leads) {
|
||||
if let Some(NodeKind::Text(t)) = doc.node_mut(*id).map(|n| &mut n.kind)
|
||||
&& t.first_para_continues != on
|
||||
&& (t.first_para_continues != on || t.first_para_lead != lead)
|
||||
{
|
||||
t.first_para_continues = on;
|
||||
t.first_para_lead = lead;
|
||||
refresh_bounds(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [`TextObject::first_para_lead`] for each frame of a thread, from the frames' plain `texts` and
|
||||
/// whether each one's first paragraph `continues` from the frame before: the last character of
|
||||
/// that paragraph in the frames before that a repeat mark could stand for, or None.
|
||||
fn first_para_leads(texts: &[String], continues: &[bool]) -> Vec<Option<char>> {
|
||||
(0..texts.len())
|
||||
.map(|k| {
|
||||
let mut j = k;
|
||||
while continues.get(j) == Some(&true) && j > 0 {
|
||||
j -= 1;
|
||||
let text = texts.get(j)?;
|
||||
let tail = text.rfind('\n').map_or(Some(text.as_str()), |at| text.get(at + 1..))?;
|
||||
if let Some(c) = vectorcraft_text::repeat_base(tail) {
|
||||
return Some(c);
|
||||
}
|
||||
if tail.len() != text.len() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
thread_local! {
|
||||
/// Tests: how many times [`story_of`] and [`ThreadIndex::of`] went through the document's
|
||||
|
||||
@@ -2226,3 +2226,39 @@ fn paragraph_indents_check_every_entry_and_skip_a_change_that_changes_nothing()
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1);
|
||||
assert_eq!(text_of(&s.doc().unwrap().doc, NodeId(c)).unwrap().para_at(1).left_indent, 30.0);
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: a frame whose first paragraph continues carries the last character of
|
||||
/// that paragraph in the frames before that a repeat mark can stand for, looking past frames that
|
||||
/// hold only repeat marks and stopping at the paragraph's start; a frame that starts a paragraph
|
||||
/// carries none. Flowing the story and opening a file both set it.
|
||||
#[test]
|
||||
fn a_continued_frame_carries_the_character_a_repeat_mark_stands_for() {
|
||||
let leads = |texts: &[&str], continues: &[bool]| first_para_leads(&texts.iter().map(|t| t.to_string()).collect::<Vec<_>>(), continues);
|
||||
assert_eq!(leads(&["時", "々す"], &[false, true]), [None, Some('時')]);
|
||||
assert_eq!(leads(&["時", "々", "々"], &[false, true, true]), [None, Some('時'), Some('時')]);
|
||||
assert_eq!(leads(&["時\nか\u{3099}", "ゝ"], &[false, true]), [None, Some('か')]);
|
||||
assert_eq!(leads(&["時\n々", "々"], &[false, true]), [None, None]);
|
||||
assert_eq!(leads(&["時\n", "々"], &[false, false]), [None, None]);
|
||||
assert_eq!(leads(&[], &[]), Vec::<Option<char>>::new());
|
||||
// Opening a file marks the frames as they were saved.
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 600, "height": 300})).unwrap();
|
||||
let mut ids = Vec::new();
|
||||
for (x, text) in [(10, "日時"), (200, "々す")] {
|
||||
let id =
|
||||
s.execute("text.create", &json!({"x": x, "y": 10, "text": text, "area": {"width": 150, "height": 60}})).unwrap()["id"].as_u64().unwrap();
|
||||
ids.push(NodeId(id));
|
||||
}
|
||||
let mut d = (*s.doc().unwrap().doc).clone();
|
||||
d.text_threads = vec![ids.clone()];
|
||||
mark_continued(&mut d);
|
||||
let tb = text_of(&d, ids[1]).unwrap();
|
||||
assert!(tb.first_para_continues);
|
||||
assert_eq!(tb.first_para_lead, Some('時'));
|
||||
// Flowing the story through the frames sets it from the text each frame now holds.
|
||||
reflow(&d.clone(), &mut d);
|
||||
let (ta, tb) = (text_of(&d, ids[0]).unwrap(), text_of(&d, ids[1]).unwrap());
|
||||
assert_eq!([ta.plain_text(), tb.plain_text()].concat(), "日時々す");
|
||||
assert!(tb.first_para_continues);
|
||||
assert_eq!(tb.first_para_lead, vectorcraft_text::repeat_base(&ta.plain_text()));
|
||||
}
|
||||
|
||||
@@ -504,6 +504,62 @@ fn bunri_kinshi_is_set_per_paragraph_and_saved_only_when_on() {
|
||||
assert!(!text(&s).para_at(0).bunri_kinshi && !text(&s).para_at(1).bunri_kinshi);
|
||||
}
|
||||
|
||||
/// Paragraph panel menu › Kurikaeshi Moji Shori: off for new type and for a paragraph saved before
|
||||
/// it, and saved only when on; `text.setFormat {kurikaeshiMojiShori}` sets it per paragraph in one
|
||||
/// undo step, records nothing when the paragraphs already have the value, refuses a value that is
|
||||
/// not true or false, and paragraph styles carry it. The text keeps its repeat marks.
|
||||
#[test]
|
||||
fn kurikaeshi_moji_shori_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).kurikaeshi_moji_shori, "new type has it off");
|
||||
assert!(serde_json::to_value(text(&s).para_at(0)).unwrap().get("kurikaeshi_moji_shori").is_none());
|
||||
let old: vectorcraft_doc::ParaStyle = serde_json::from_value(json!({"justify": "Left"})).unwrap();
|
||||
assert!(!old.kurikaeshi_moji_shori, "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!({"kurikaeshiMojiShori": true, "start": second, "end": second})).unwrap();
|
||||
assert!(!text(&s).para_at(0).kurikaeshi_moji_shori && text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), steps + 1);
|
||||
assert_eq!(text(&s).plain_text(), "時々\nすゝ", "the text keeps its marks");
|
||||
// The same value again records nothing.
|
||||
s.execute("text.setFormat", &json!({"kurikaeshiMojiShori": true, "start": second, "end": second})).unwrap();
|
||||
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["kurikaeshi_moji_shori"], true);
|
||||
let back: vectorcraft_doc::ParaStyle = serde_json::from_value(saved).unwrap();
|
||||
assert!(back.kurikaeshi_moji_shori);
|
||||
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).kurikaeshi_moji_shori && back.para_at(1).kurikaeshi_moji_shori, "the file keeps it per paragraph");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(!text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert!(text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
for bad in [json!("yes"), json!(1)] {
|
||||
assert!(s.execute("text.setFormat", &json!({"ids": [id], "kurikaeshiMojiShori": bad, "kinsoku": "none"})).is_err(), "{bad}");
|
||||
}
|
||||
assert!(s.execute("text.setRangeStyle", &json!({"id": id, "kurikaeshiMojiShori": false})).is_err());
|
||||
assert!(
|
||||
text(&s).para_at(1).kurikaeshi_moji_shori && text(&s).para_at(1).kinsoku != vectorcraft_doc::Kinsoku::None,
|
||||
"a refused call changes nothing"
|
||||
);
|
||||
// A paragraph style carries it.
|
||||
s.execute("paraStyle.new", &json!({"name": "Repeats", "attrs": {"kurikaeshi_moji_shori": true}})).unwrap();
|
||||
s.execute("paraStyle.apply", &json!({"name": "Repeats", "id": id})).unwrap();
|
||||
assert!(text(&s).para_at(0).kurikaeshi_moji_shori && text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
s.execute("paraStyle.new", &json!({"name": "Marks", "attrs": {"kurikaeshi_moji_shori": false}})).unwrap();
|
||||
s.execute("paraStyle.apply", &json!({"name": "Marks", "id": id})).unwrap();
|
||||
assert!(!text(&s).para_at(0).kurikaeshi_moji_shori && !text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
||||
@@ -491,7 +491,11 @@ impl Writer<'_> {
|
||||
});
|
||||
let Some(chars) = self.fonts.get_mut(at).map(|u| &mut u.chars) else { continue };
|
||||
// As written: a list marker's characters, a hyphen where a line breaks, capitals for All
|
||||
// Caps, the style's Digits.
|
||||
// Caps, the style's Digits, the character a repeat mark is drawn as.
|
||||
if let Some(c) = shown_repeat(lay, i, g) {
|
||||
chars.insert(c);
|
||||
continue;
|
||||
}
|
||||
let src = lay.marker_text(i).unwrap_or_else(|| if g.len == 0 { "-" } else { plain.get(g.byte..g.byte + g.len).unwrap_or("") });
|
||||
for c in src.chars().filter(|c| !c.is_control() && *c != '\u{ad}').map(|c| st.digits.map(c)) {
|
||||
if st.all_caps {
|
||||
@@ -716,6 +720,17 @@ struct Segment {
|
||||
/// given its own position (points).
|
||||
const PLACE_TOLERANCE: f64 = 1e-6;
|
||||
|
||||
/// Kurikaeshi Moji Shori: the character glyph `i` of `lay` shows when the layout drew a repeat mark
|
||||
/// as the character it repeats ([`vectorcraft_text::TextLayout::repeat_marks`]), or None.
|
||||
fn shown_repeat(lay: &vectorcraft_text::TextLayout, i: usize, g: &vectorcraft_text::PositionedGlyph) -> Option<char> {
|
||||
if lay.repeat_marks.is_empty() || g.len == 0 || lay.marker_text(i).is_some() {
|
||||
return None;
|
||||
}
|
||||
// The marks are in text order, one per line.
|
||||
let at = lay.repeat_marks.binary_search_by_key(&g.byte, |&(byte, _)| byte).ok()?;
|
||||
lay.repeat_marks.get(at).map(|&(_, c)| c)
|
||||
}
|
||||
|
||||
/// The laid-out lines of `t` as segments: a new segment at every style change, after tabs and,
|
||||
/// on justified lines, after each word space (unless `fewer`). The text comes from the clusters
|
||||
/// the layout placed: soft hyphens draw nothing, a line broken by hyphenation ends in `-`, all
|
||||
@@ -804,9 +819,15 @@ fn text_lines(t: &TextObject, lay: &vectorcraft_text::TextLayout, fewer: bool) -
|
||||
}
|
||||
None => (g.advance, g.origin.x),
|
||||
};
|
||||
let src: String = source(line.glyph_start + k, g).chars().filter(|c| *c != '\u{ad}').map(|c| run.style.digits.map(c)).collect();
|
||||
let repeat = shown_repeat(lay, line.glyph_start + k, g);
|
||||
let src: String = match repeat {
|
||||
Some(c) => c.to_string(),
|
||||
None => source(line.glyph_start + k, g).chars().filter(|c| *c != '\u{ad}').map(|c| run.style.digits.map(c)).collect(),
|
||||
};
|
||||
let piece = if run.style.all_caps { src.to_uppercase() } else { src };
|
||||
let brk = piece == "\t" || (split_words && !piece.is_empty() && piece.chars().all(char::is_whitespace));
|
||||
// The character a repeat mark is drawn as takes the mark's width on the canvas, which a
|
||||
// reader does not know: the text after it is placed anew.
|
||||
let brk = piece == "\t" || (split_words && !piece.is_empty() && piece.chars().all(char::is_whitespace)) || repeat.is_some();
|
||||
// A glyph Glyph Scaling widens or narrows is a segment of its own, stretched to its width.
|
||||
let scale = if reader.is_some() && (g.scale - 1.0).abs() > 1e-9 && g.scale.is_finite() { g.scale } else { 1.0 };
|
||||
let fresh = std::mem::take(&mut after_inline) || scale != 1.0 || segs.last().is_some_and(|last| last.scale != 1.0);
|
||||
|
||||
@@ -910,3 +910,34 @@ fn paragraphs_aligned_differently_keep_their_alignment() {
|
||||
assert_similar(&render_artboard(&d), &render_artboard(&back), 40.0, 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
/// With Kurikaeshi Moji Shori on, live type writes a repeat mark that starts a line as the
|
||||
/// character it is drawn as and places the text after it anew, with and without embedded fonts; a
|
||||
/// mark inside a line stays.
|
||||
#[test]
|
||||
fn a_repeat_mark_at_a_line_start_is_written_as_the_character_it_draws() {
|
||||
use vectorcraft_text::test_fonts::{RARE_REPEAT_MARK_FAMILY, rare_repeat_mark_font};
|
||||
vectorcraft_text::FontDb::global().add_font(rare_repeat_mark_font().unwrap());
|
||||
let st = CharStyle { font_family: RARE_REPEAT_MARK_FAMILY.into(), ..style(12.0) };
|
||||
for on in [false, true] {
|
||||
let mut t = TextObject::point(Point::new(20.0, 40.0), "龘\u{2028}々龘龘々", st.clone());
|
||||
t.para.kurikaeshi_moji_shori = on;
|
||||
let mut d = Document::new(300.0, 200.0);
|
||||
let n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t)));
|
||||
let l = d.layers[0].id;
|
||||
d.insert(Some(l), 0, n).unwrap();
|
||||
for embed_fonts in [false, true] {
|
||||
let svg = export(&d, &ExportOptions { embed_fonts, ..Default::default() });
|
||||
if !on {
|
||||
assert!(svg.contains(">々龘龘々<"), "{svg}");
|
||||
continue;
|
||||
}
|
||||
// The drawn character takes the mark's width on the canvas, so the text after it is
|
||||
// placed where the canvas draws it.
|
||||
let rest = svg.find(">龘龘々<").unwrap_or_else(|| panic!("{svg}"));
|
||||
let tag = &svg[svg[..rest].rfind('<').unwrap_or(0)..rest];
|
||||
assert!(tag.contains(" x=\""), "{tag}: {svg}");
|
||||
assert_eq!(svg.matches('々').count(), 1, "only the mark inside the line stays: {svg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use super::{
|
||||
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_inseparable_pairs, keep_korean_words};
|
||||
use crate::shape::{keep_inseparable_pairs, keep_korean_words, repeated_char, shape_range};
|
||||
|
||||
/// Does paragraph `para` push characters in (Kinsoku Shori Type Push In First or Push Out First,
|
||||
/// with kinsoku on)?
|
||||
@@ -213,6 +213,9 @@ struct ParagraphData<'a, 'text> {
|
||||
bidi: Option<BidiInfo<'text>>,
|
||||
rtl: bool,
|
||||
continued: bool,
|
||||
/// Kurikaeshi Moji Shori: the character before a `continued` paragraph in the frames before
|
||||
/// ([`TextObject::first_para_lead`]).
|
||||
lead: Option<char>,
|
||||
sg: Vec<SGlyph>,
|
||||
compressed: Vec<bool>,
|
||||
wakan: Vec<f64>,
|
||||
@@ -331,6 +334,7 @@ fn prepare_paragraph<'a, 'text>(
|
||||
bidi,
|
||||
rtl,
|
||||
continued,
|
||||
lead: t.first_para_lead.filter(|_| continued),
|
||||
sg,
|
||||
compressed,
|
||||
wakan,
|
||||
@@ -1272,6 +1276,40 @@ fn emit_line_glyph(
|
||||
cx.emit(glyph, Affine::translate(at.to_vec2()), at, 0.0, w.advance, line_index);
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori (Paragraph panel menu): the glyph drawn in place of `g`, the first glyph of
|
||||
/// a line of the paragraph starting at byte `para_start`, when `g` is a repeat mark, and the
|
||||
/// character it shows: the character [`repeated_char`] gives, shaped in the mark's style with the
|
||||
/// type's features (so vertical type gets the font's vertical forms), from the same face, with the
|
||||
/// mark's advance and place, so the line breaks stay as they are. None when `g` is no repeat mark,
|
||||
/// belongs to a tate-chu-yoko or warichu block, nothing before it in the paragraph fits, or the face
|
||||
/// draws the character with no glyph or with more than one. `lead` stands before a paragraph that
|
||||
/// continues from the frame before ([`TextObject::first_para_lead`]).
|
||||
fn repeat_mark_glyph(cx: &Ctx<'_>, para_start: usize, lead: Option<char>, g: &SGlyph) -> Option<(SGlyph, char)> {
|
||||
if g.tcy.is_some() || g.wari.is_some() || g.inline.is_some() {
|
||||
return None;
|
||||
}
|
||||
let c = repeated_char(lead, cx.text.get(para_start..g.byte)?, g.ch)?;
|
||||
let mut buf = [0; 4];
|
||||
let s: &str = c.encode_utf8(&mut buf);
|
||||
let mut shaped = Vec::with_capacity(1);
|
||||
shape_range(cx.db, s, 0..s.len(), &[(0..s.len(), cx.style_at(g.byte))], &[], &cx.opts.features, &[], &mut shaped);
|
||||
let [one] = shaped.as_slice() else { return None };
|
||||
(one.gid != 0 && one.face.id() == g.face.id()).then(|| (SGlyph { gid: one.gid, ..g.clone() }, c))
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the glyph drawn in place of glyph `first` of `paragraph`, the first
|
||||
/// character of a line that ends before glyph `end`, when the paragraph has the setting on and
|
||||
/// [`repeat_mark_glyph`] gives one; it is recorded in [`crate::TextLayout::repeat_marks`].
|
||||
fn line_start_repeat(cx: &mut Ctx<'_>, paragraph: &ParagraphData<'_, '_>, first: usize, end: usize) -> Option<SGlyph> {
|
||||
if !paragraph.para.kurikaeshi_moji_shori || first >= end {
|
||||
return None;
|
||||
}
|
||||
let g = paragraph.sg.get(first)?;
|
||||
let (glyph, c) = repeat_mark_glyph(cx, paragraph.pr.start, paragraph.lead, g)?;
|
||||
cx.out.repeat_marks.push((g.byte, c));
|
||||
Some(glyph)
|
||||
}
|
||||
|
||||
/// Lay out `line` of `paragraph` as `justification` aligns it: each glyph placed along the
|
||||
/// baseline (tabs as [`tab_glyph`] sets them), its hyphen, and the line's record, then the pen
|
||||
/// moved on past it.
|
||||
@@ -1306,9 +1344,14 @@ fn emit_flow_line(cx: &mut Ctx<'_>, pen: &mut Pen<'_>, paragraph: &ParagraphData
|
||||
let mut marker_tab = 0;
|
||||
// The warichu blocks drawn on the line: the byte that names each and where it starts.
|
||||
let mut wari_blocks: Vec<(usize, f64)> = Vec::new();
|
||||
// Kurikaeshi Moji Shori: the line's first character after any list marker, drawn as the
|
||||
// character it repeats when it is a repeat mark.
|
||||
let first = index.max(paragraph.marker);
|
||||
let repeat = line_start_repeat(cx, paragraph, first, position.end);
|
||||
for (order_index, &offset) in order.iter().enumerate() {
|
||||
let glyph_index = index + offset;
|
||||
let Some(glyph) = sg.get(glyph_index) else { continue };
|
||||
let glyph = if glyph_index == first { repeat.as_ref().unwrap_or(glyph) } else { glyph };
|
||||
let mut advance = glyph.adv;
|
||||
if glyph_index + 1 == trimmed {
|
||||
advance -= line.end_trim;
|
||||
|
||||
@@ -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::{aki_space, inseparable, line_start_space, spacing_scale};
|
||||
pub use shape::{aki_space, inseparable, line_start_space, repeat_base, spacing_scale};
|
||||
pub use vectorcraft_doc::TextObject;
|
||||
|
||||
pub use vectorcraft_doc::{AreaFit, FirstBaseline, TextFlow, VerticalAlign};
|
||||
@@ -401,6 +401,10 @@ pub struct TextLayout {
|
||||
pub inlines: Vec<InlineGlyph>,
|
||||
/// List markers, in text order.
|
||||
pub markers: Vec<ListMarker>,
|
||||
/// Kurikaeshi Moji Shori: the repeat marks drawn as the character they stand for, as (the
|
||||
/// mark's byte offset in the plain text, the character drawn), in text order. Writers that put
|
||||
/// characters in place of glyphs (live SVG text) write that character.
|
||||
pub repeat_marks: Vec<(usize, char)>,
|
||||
}
|
||||
|
||||
impl Default for TextLayout {
|
||||
@@ -419,6 +423,7 @@ impl Default for TextLayout {
|
||||
path_fill: None,
|
||||
inlines: Vec::new(),
|
||||
markers: Vec::new(),
|
||||
repeat_marks: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,6 +450,65 @@ pub fn inseparable(a: char, b: char) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the last character of `text` that a repeat mark after it could stand for:
|
||||
/// the last one that is neither a repeat mark, a soft return (U+2028) nor a combining voicing mark
|
||||
/// (U+3099, U+309A), or None when there is none. The engine gives a threaded frame whose first
|
||||
/// paragraph continues from the frame before the result for the text before it
|
||||
/// (`TextObject::first_para_lead`).
|
||||
pub fn repeat_base(text: &str) -> Option<char> {
|
||||
text.chars().rev().find(|&c| !matches!(c, '々' | 'ゝ' | 'ゞ' | 'ヽ' | 'ヾ' | '\u{2028}' | '\u{3099}' | '\u{309A}'))
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the character the repeat mark `mark` stands for after the text `before`
|
||||
/// it, or None when `mark` is not a repeat mark or nothing before it fits. `lead` stands before
|
||||
/// `before` (the text of a threaded paragraph in the frames before). VectorCraft's rules: the
|
||||
/// repeated character is the last one before the mark that is neither a repeat mark, a soft return
|
||||
/// (U+2028) nor a combining voicing mark ([`repeat_base`]); 々 repeats a Han ideograph, ゝ and ゞ a
|
||||
/// hiragana and ヽ and ヾ a katakana. ゝ and ヽ give the kana without its voicing marks, and ゞ and
|
||||
/// ヾ its voiced form, or the plain kana when it has none.
|
||||
pub(crate) fn repeated_char(lead: Option<char>, before: &str, mark: char) -> Option<char> {
|
||||
let script = match mark {
|
||||
'々' => Script::Han,
|
||||
'ゝ' | 'ゞ' => Script::Hiragana,
|
||||
'ヽ' | 'ヾ' => Script::Katakana,
|
||||
_ => return None,
|
||||
};
|
||||
let base = repeat_base(before).or(lead)?;
|
||||
if base.script() != script || (script != Script::Han && !matches!(base as u32, 0x3041..=0x3096 | 0x30A1..=0x30F6)) {
|
||||
return None;
|
||||
}
|
||||
if script == Script::Han {
|
||||
return Some(base);
|
||||
}
|
||||
// Katakana from U+30A1 to U+30F6 lie 0x60 past their hiragana, so one table serves both.
|
||||
let shift = if script == Script::Katakana { 0x60 } else { 0 };
|
||||
let plain = unvoiced(base as u32 - shift);
|
||||
let kana = if matches!(mark, 'ゞ' | 'ヾ') { voiced(plain).unwrap_or(plain) } else { plain };
|
||||
char::from_u32(kana + shift)
|
||||
}
|
||||
|
||||
/// The hiragana `h` (a code point) without its dakuten or handakuten.
|
||||
fn unvoiced(h: u32) -> u32 {
|
||||
match h {
|
||||
0x304C..=0x3062 if h.is_multiple_of(2) => h - 1,
|
||||
0x3065 | 0x3067 | 0x3069 => h - 1,
|
||||
0x3070..=0x307D => h - (h - 0x306F) % 3,
|
||||
0x3094 => 0x3046,
|
||||
_ => h,
|
||||
}
|
||||
}
|
||||
|
||||
/// The voiced form (with dakuten) of the plain hiragana `h`, if it has one.
|
||||
fn voiced(h: u32) -> Option<u32> {
|
||||
match h {
|
||||
0x304B..=0x3061 if !h.is_multiple_of(2) => Some(h + 1),
|
||||
0x3064 | 0x3066 | 0x3068 => Some(h + 1),
|
||||
0x306F..=0x307B if (h - 0x306F).is_multiple_of(3) => Some(h + 1),
|
||||
0x3046 => Some(0x3094),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -484,6 +484,59 @@ pub fn full_width_font() -> Option<Vec<u8>> {
|
||||
Some(builder.build())
|
||||
}
|
||||
|
||||
/// The family of [`repeat_mark_font`].
|
||||
pub const REPEAT_MARK_FAMILY: &str = "Repeattest Sans";
|
||||
|
||||
/// The Japanese characters [`repeat_mark_font`] maps, each to the glyph of the Latin capital beside
|
||||
/// it: an ideograph, the repeat marks, and kana with and without their voicing marks.
|
||||
pub const REPEAT_MARK_CHARS: [(char, char); 11] =
|
||||
[('時', 'A'), ('々', 'B'), ('す', 'C'), ('ず', 'D'), ('ゝ', 'E'), ('ゞ', 'F'), ('サ', 'G'), ('ザ', 'H'), ('ヽ', 'I'), ('ヾ', 'J'), ('あ', 'K')];
|
||||
|
||||
/// A test-only cmap over bundled Source Sans 3: each of [`REPEAT_MARK_CHARS`] uses the glyph of its
|
||||
/// Latin capital, so the glyph drawn for a repeat mark tells which character was drawn; the space
|
||||
/// keeps its own glyph.
|
||||
pub fn repeat_mark_font() -> Option<Vec<u8>> {
|
||||
repeat_font(REPEAT_MARK_FAMILY, &REPEAT_MARK_CHARS)
|
||||
}
|
||||
|
||||
/// The family of [`rare_repeat_mark_font`].
|
||||
pub const RARE_REPEAT_MARK_FAMILY: &str = "Raretest Sans";
|
||||
|
||||
/// [`repeat_mark_font`] for tests that add it to the shared [`crate::FontDb::global`]: it maps
|
||||
/// only 龘 (to the glyph of A) and 々 (to the glyph of B), characters no other text in those tests
|
||||
/// uses, so other tests' Japanese text does not fall back to it.
|
||||
pub fn rare_repeat_mark_font() -> Option<Vec<u8>> {
|
||||
repeat_font(RARE_REPEAT_MARK_FAMILY, &[('龘', 'A'), ('々', 'B')])
|
||||
}
|
||||
|
||||
/// A font named `family` over bundled Source Sans 3 whose cmap maps each of `chars` to the glyph of
|
||||
/// the Latin capital beside it, and the space to its own glyph.
|
||||
fn repeat_font(family: &str, chars: &[(char, char)]) -> Option<Vec<u8>> {
|
||||
use write_fonts::tables::cmap::Cmap;
|
||||
|
||||
const BASE: &[u8] = include_bytes!("../../../assets/fonts/SourceSans3-Regular.ttf");
|
||||
let font = skrifa::FontRef::new(BASE).ok()?;
|
||||
let charmap = font.charmap();
|
||||
let mut mappings: Vec<(char, write_fonts::types::GlyphId)> = Vec::new();
|
||||
for &(c, latin) in chars.iter().chain(&[(' ', ' ')]) {
|
||||
mappings.push((c, write_fonts::types::GlyphId::new(charmap.map(latin)?.to_u32())));
|
||||
}
|
||||
let cmap = Cmap::from_mappings(mappings).ok()?;
|
||||
let full = format!("{family} Regular");
|
||||
let postscript = format!("{}-Regular", family.replace(' ', ""));
|
||||
let name = name_table(&[(1, family), (2, "Regular"), (4, &full), (6, &postscript)])?;
|
||||
let mut builder = FontBuilder::new();
|
||||
builder.add_table(&cmap).ok()?;
|
||||
builder.add_raw(Tag::new(b"name"), name);
|
||||
for r in font.table_directory.table_records() {
|
||||
let tag = Tag::new(&r.tag().to_be_bytes());
|
||||
if tag != Tag::new(b"GSUB") && !builder.contains(tag) {
|
||||
builder.add_raw(tag, font.table_data(r.tag())?.as_bytes());
|
||||
}
|
||||
}
|
||||
Some(builder.build())
|
||||
}
|
||||
|
||||
/// The family of [`half_form_font`].
|
||||
pub const HALF_FORM_FAMILY: &str = "Halftest Sans";
|
||||
|
||||
|
||||
@@ -2693,6 +2693,123 @@ fn bunri_kinshi_keeps_two_em_dashes_on_one_line() {
|
||||
assert_eq!(ends(&t), [kept, text.len(), second + split, second + text.len()]);
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the character a repeat mark stands for is the last one before it that is
|
||||
/// not a repeat mark, in the mark's script; ゝ and ヽ give it without voicing marks, ゞ and ヾ give
|
||||
/// its voiced form when it has one.
|
||||
#[test]
|
||||
fn repeat_marks_stand_for_the_character_before_them() {
|
||||
use crate::shape::repeated_char;
|
||||
for (before, mark, want) in [
|
||||
("時", '々', Some('時')),
|
||||
("時々", '々', Some('時')),
|
||||
("時\u{2028}", '々', Some('時')),
|
||||
("す", 'ゝ', Some('す')),
|
||||
("ず", 'ゝ', Some('す')),
|
||||
("す", 'ゞ', Some('ず')),
|
||||
("ず", 'ゞ', Some('ず')),
|
||||
("ぱ", 'ゝ', Some('は')),
|
||||
("は", 'ゞ', Some('ば')),
|
||||
("ぽ", 'ゞ', Some('ぼ')),
|
||||
("つ", 'ゞ', Some('づ')),
|
||||
("う", 'ゞ', Some('ゔ')),
|
||||
("あ", 'ゞ', Some('あ')),
|
||||
("サ", 'ヽ', Some('サ')),
|
||||
("ザ", 'ヽ', Some('サ')),
|
||||
("サ", 'ヾ', Some('ザ')),
|
||||
("ウ", 'ヾ', Some('ヴ')),
|
||||
("ピ", 'ヾ', Some('ビ')),
|
||||
("サ", 'ゝ', None),
|
||||
("す", 'ヽ', None),
|
||||
("す", '々', None),
|
||||
("時", 'ゝ', None),
|
||||
("A", '々', None),
|
||||
("", '々', None),
|
||||
("々ゝ", '々', None),
|
||||
("時", 'x', None),
|
||||
// A kana followed by a combining voicing mark is that kana.
|
||||
("か\u{3099}\u{2028}", 'ゝ', Some('か')),
|
||||
("か\u{3099}", 'ゞ', Some('が')),
|
||||
("ハ\u{309A}", 'ヽ', Some('ハ')),
|
||||
] {
|
||||
assert_eq!(repeated_char(None, before, mark), want, "{before:?} {mark}");
|
||||
}
|
||||
// The character before a paragraph that continues from the frame before stands in when the text
|
||||
// before the mark in this frame has none.
|
||||
assert_eq!(repeated_char(Some('時'), "", '々'), Some('時'));
|
||||
assert_eq!(repeated_char(Some('時'), "\u{2028}々", '々'), Some('時'));
|
||||
assert_eq!(repeated_char(Some('時'), "日", '々'), Some('日'));
|
||||
assert_eq!(repeated_char(Some('す'), "", '々'), None);
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori (a paragraph attribute): on, a repeat mark that starts a line is drawn as
|
||||
/// the character it repeats, in point and area type, horizontal and vertical, at a soft return or
|
||||
/// where a line wraps; a mark inside a line, one starting a paragraph and every mark with the
|
||||
/// setting off keep their own glyph. The line breaks and the glyphs' bytes do not change. Uses a test
|
||||
/// font that draws each character with a different Latin glyph.
|
||||
#[test]
|
||||
fn kurikaeshi_moji_shori_draws_the_repeated_character_at_a_line_start() {
|
||||
use crate::test_fonts::{REPEAT_MARK_FAMILY, repeat_mark_font};
|
||||
let db = FontDb::with_font_dirs(vec![]);
|
||||
db.add_font(repeat_mark_font().expect("test font"));
|
||||
let st = CharStyle { size: 20.0, font_family: REPEAT_MARK_FAMILY.into(), font_style: "Regular".into(), ..CharStyle::default() };
|
||||
let face = db.style_face(&st).expect("face");
|
||||
let glyph = |c: char| Some(face.glyph_for(c));
|
||||
let gid_of = |l: &TextLayout, b: usize| l.glyphs.iter().find(|g| g.byte == b).map(|g| g.gid);
|
||||
let ends = |l: &TextLayout| l.lines.iter().map(|line| line.end).collect::<Vec<_>>();
|
||||
// 時 | 々す | ゞ時々ザ | ヽ, then a paragraph that starts with 々.
|
||||
let text = "時\u{2028}々す\u{2028}ゞ時々ザ\u{2028}ヽ\n々";
|
||||
let at = |s: &str| text.find(s).unwrap();
|
||||
let (first_mark, voiced, inner, katakana, para_start) = (at("々す"), at("ゞ"), at("時々ザ") + "時".len(), at("ヽ"), text.len() - "々".len());
|
||||
for vertical in [false, true] {
|
||||
let mut t = TextObject::point(Point::ZERO, text, st.clone());
|
||||
t.vertical = vertical;
|
||||
let off = layout(&db, &t);
|
||||
t.set_paragraph_styles(vec![
|
||||
vectorcraft_doc::ParaStyle { kurikaeshi_moji_shori: true, ..t.para.clone() },
|
||||
vectorcraft_doc::ParaStyle { kurikaeshi_moji_shori: true, ..t.para.clone() },
|
||||
]);
|
||||
let on = layout(&db, &t);
|
||||
assert_eq!(ends(&on), ends(&off), "vertical {vertical}");
|
||||
let bytes = |l: &TextLayout| l.glyphs.iter().map(|g| g.byte).collect::<Vec<_>>();
|
||||
assert_eq!(bytes(&on), bytes(&off), "vertical {vertical}");
|
||||
// Off, each mark has its own glyph.
|
||||
for (b, mark) in [(first_mark, '々'), (voiced, 'ゞ'), (inner, '々'), (katakana, 'ヽ'), (para_start, '々')] {
|
||||
assert_eq!(gid_of(&off, b), glyph(mark), "vertical {vertical}: off, {mark} at {b}");
|
||||
}
|
||||
assert_eq!(gid_of(&on, first_mark), glyph('時'), "vertical {vertical}: 々 drawn as 時");
|
||||
assert_eq!(gid_of(&on, voiced), glyph('ず'), "vertical {vertical}: ゞ after す drawn as ず");
|
||||
assert_eq!(gid_of(&on, katakana), glyph('サ'), "vertical {vertical}: ヽ after ザ drawn as サ");
|
||||
assert_eq!(gid_of(&on, inner), glyph('々'), "vertical {vertical}: a mark inside a line keeps its glyph");
|
||||
assert_eq!(gid_of(&on, para_start), glyph('々'), "vertical {vertical}: a paragraph's first mark keeps its glyph");
|
||||
assert!(off.repeat_marks.is_empty());
|
||||
assert_eq!(on.repeat_marks, [(first_mark, '時'), (voiced, 'ず'), (katakana, 'サ')], "vertical {vertical}");
|
||||
}
|
||||
// Where area type wraps: each line holds one character, so 々 starts the second line.
|
||||
let mut t = TextObject::point(Point::ZERO, "時々", st.clone());
|
||||
let both: f64 = layout(&db, &t).glyphs.iter().map(|g| g.advance).sum();
|
||||
t.xf = Affine::IDENTITY;
|
||||
// The Soft set lets 々 start a line.
|
||||
t.para.kinsoku = vectorcraft_doc::Kinsoku::Soft;
|
||||
t.kind = TextKind::Area { frame: PathData::from_bezpath(&Rect::new(0.0, 0.0, both - 1.0, 200.0).to_path(0.1)) };
|
||||
let off = layout(&db, &t);
|
||||
assert_eq!(ends(&off), ["時".len(), "時々".len()]);
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
let on = layout(&db, &t);
|
||||
assert_eq!(ends(&on), ends(&off));
|
||||
assert_eq!(gid_of(&off, "時".len()), glyph('々'));
|
||||
assert_eq!(gid_of(&on, "時".len()), glyph('時'), "a wrapped line's 々 is drawn as 時");
|
||||
// A threaded frame whose first paragraph continues: a mark that starts the frame is drawn as the
|
||||
// character before it in the frame before, only while the paragraph continues.
|
||||
let mut t = TextObject::point(Point::ZERO, "々す\n々", st.clone());
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
t.first_para_lead = Some('時');
|
||||
assert_eq!(gid_of(&layout(&db, &t), 0), glyph('々'), "a frame that does not continue");
|
||||
t.first_para_continues = true;
|
||||
let on = layout(&db, &t);
|
||||
assert_eq!(gid_of(&on, 0), glyph('時'), "the frame's first 々 is drawn as 時");
|
||||
assert_eq!(gid_of(&on, "々す\n".len()), glyph('々'), "the next paragraph's first mark keeps its glyph");
|
||||
}
|
||||
|
||||
/// 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]
|
||||
|
||||
@@ -2978,6 +2978,7 @@ digits Malayalam Малаялам
|
||||
Roman Hanging Punctuation Латинска висяща пунктуация
|
||||
Korean Line Break Anywhere Пренасяне на корейски текст навсякъде
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Настройки за източноазиатска композиция
|
||||
Korean Composition Settings Настройки за корейска композиция
|
||||
Rotate Завъртане
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2076,6 +2076,7 @@ digits Malayalam Malajalam
|
||||
Roman Hanging Punctuation Latinična viseća interpunkcija
|
||||
Korean Line Break Anywhere Prelom korejskog reda bilo gdje
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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.
|
@@ -3810,6 +3810,7 @@ digits Malayalam Malaiàlam
|
||||
Roman Hanging Punctuation Puntuació penjant romana
|
||||
Korean Line Break Anywhere Salt de línia coreà a qualsevol lloc
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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.
|
@@ -2147,6 +2147,7 @@ digits Malayalam Malajálamské
|
||||
Roman Hanging Punctuation Visící latinková interpunkce
|
||||
Korean Line Break Anywhere Zalomení korejského řádku kdekoli
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -2565,6 +2565,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Romersk hængende tegnsætning
|
||||
Korean Line Break Anywhere Koreansk linjeskift hvor som helst
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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.
|
@@ -3021,6 +3021,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Hängende Interpunktion (lateinisch)
|
||||
Korean Line Break Anywhere Koreanischer Zeilenumbruch überall
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -2073,6 +2073,7 @@ font-technology Variable Μεταβλητές
|
||||
Roman Hanging Punctuation Κρεμαστή στίξη όρθιας γραφής
|
||||
Korean Line Break Anywhere Αλλαγή γραμμής κορεατικών οπουδήποτε
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Ρυθμίσεις σύνθεσης ανατολικής Ασίας
|
||||
Korean Composition Settings Ρυθμίσεις κορεατικής σύνθεσης
|
||||
Rotate Περιστροφή
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3057,6 +3057,7 @@ digits Malayalam Malayálam
|
||||
Roman Hanging Punctuation Puntuación colgante romana
|
||||
Korean Line Break Anywhere Salto de línea coreano en cualquier lugar
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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.
|
@@ -2110,6 +2110,7 @@ digits Malayalam Malajalam
|
||||
Roman Hanging Punctuation Latinalaiset riippuvat välimerkit
|
||||
Korean Line Break Anywhere Korean rivinvaihto missä tahansa
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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.
|
@@ -3049,6 +3049,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Ponctuation romaine hors justification
|
||||
Korean Line Break Anywhere Saut de ligne coréen n’importe où
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -4465,6 +4465,7 @@ antiAlias Sharp શાર્પ
|
||||
Save Prominent Colors મુખ્ય રંગો સાચવો
|
||||
Korean Line Break Anywhere કોરિયન લાઇન ગમે ત્યાં તોડો
|
||||
Bunri-Kinshi બુનરી-કિન્શી
|
||||
Kurikaeshi Moji Shori કુરિકાએશી મોજી શોરી
|
||||
East Asian Composition Settings પૂર્વ એશિયાઈ કમ્પોઝિશન સેટિંગ્સ
|
||||
Korean Composition Settings કોરિયન કમ્પોઝિશન સેટિંગ્સ
|
||||
Show Bounding Box While Moving and Drawing ખસેડતી અને દોરતી વખતે બાઉન્ડિંગ બોક્સ બતાવો
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -4187,6 +4187,7 @@ antiAlias Sharp शार्प
|
||||
Roman Hanging Punctuation रोमन हैंगिंग विराम चिह्न
|
||||
Korean Line Break Anywhere कोरियाई लाइन ब्रेक कहीं भी
|
||||
Bunri-Kinshi बुनरी-किंशी
|
||||
Kurikaeshi Moji Shori कुरिकाएशी मोजी शोरी
|
||||
East Asian Composition Settings पूर्वी एशियाई संरचना सेटिंग्स
|
||||
Korean Composition Settings कोरियाई संरचना सेटिंग्स
|
||||
Rotate घुमाएँ
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3645,6 +3645,7 @@ mark-style Japanese Japán
|
||||
Roman Hanging Punctuation Latin függő írásjelek
|
||||
Korean Line Break Anywhere Koreai sortörés bárhol
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -1899,6 +1899,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Tanda baca gantung Romawi
|
||||
Korean Line Break Anywhere Putus baris Korea di mana saja
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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.
|
||||
|
||||
|
@@ -3098,6 +3098,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Punteggiatura sporgente romana
|
||||
Korean Line Break Anywhere Interruzione di riga coreana ovunque
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -3064,6 +3064,7 @@ mark-style Japanese 日本式
|
||||
Roman Hanging Punctuation 欧文ぶら下がり
|
||||
Korean Line Break Anywhere 韓国語の任意位置での改行
|
||||
Bunri-Kinshi 分離禁止
|
||||
Kurikaeshi Moji Shori 繰り返し文字処理
|
||||
East Asian Composition Settings 東アジア言語の組版設定
|
||||
Korean Composition Settings 韓国語の組版設定
|
||||
Rotate 回転
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3955,6 +3955,7 @@ digits Malayalam მალაიალამური
|
||||
Roman Hanging Punctuation რომაული გამოწეული პუნქტუაცია
|
||||
Korean Line Break Anywhere კორეული სტრიქონის გადატანა ნებისმიერ ადგილას
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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.
|
@@ -3053,6 +3053,7 @@ mark-style Japanese 일본식
|
||||
Roman Hanging Punctuation 로마자 걸림 문장 부호
|
||||
Korean Line Break Anywhere 한글 어디서나 줄 바꿈
|
||||
Bunri-Kinshi 분리 금지
|
||||
Kurikaeshi Moji Shori 반복 문자 처리
|
||||
East Asian Composition Settings 동아시아 조판 설정
|
||||
Korean Composition Settings 한글 조판 설정
|
||||
Rotate 회전
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2461,6 +2461,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Romeinse hangende leestekens
|
||||
Korean Line Break Anywhere Koreaans regeleinde overal
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -2065,6 +2065,7 @@ digits Malayalam Malajalam
|
||||
Roman Hanging Punctuation Wysunięta interpunkcja łacińska
|
||||
Korean Line Break Anywhere Koreański podział wiersza w dowolnym miejscu
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -2544,6 +2544,7 @@ digits Malayalam Malaiala
|
||||
Roman Hanging Punctuation Pontuação Pendurada Romana
|
||||
Korean Line Break Anywhere Quebra de Linha Coreana em Qualquer Lugar
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -3087,6 +3087,7 @@ digits Malayalam Малаялам
|
||||
Roman Hanging Punctuation Римская висячая пунктуация
|
||||
Korean Line Break Anywhere Перенос корейского текста в любом месте
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Параметры восточноазиатского набора
|
||||
Korean Composition Settings Параметры корейского набора
|
||||
Rotate Повернуть
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2991,6 +2991,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Hängande interpunktion (roman)
|
||||
Korean Line Break Anywhere Koreansk radbrytning var som helst
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -2826,6 +2826,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Roma Asılı Noktalama İşaretleri
|
||||
Korean Line Break Anywhere Korece Satırı Her Yerde Kes
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 is too large.
|
@@ -3090,6 +3090,7 @@ digits Malayalam Малаялам
|
||||
Roman Hanging Punctuation Римська висяча пунктуація
|
||||
Korean Line Break Anywhere Перенесення корейського тексту будь-де
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Параметри східноазійського набору
|
||||
Korean Composition Settings Параметри корейського набору
|
||||
Rotate Повернути
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3407,6 +3407,7 @@ mark-style Japanese Kiểu Nhật
|
||||
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
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
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 205 and column 5.
|
@@ -2948,6 +2948,7 @@ digits Malayalam 马拉雅拉姆数字
|
||||
Roman Hanging Punctuation 西文悬挂标点
|
||||
Korean Line Break Anywhere 韩文任意位置换行
|
||||
Bunri-Kinshi 分离禁止
|
||||
Kurikaeshi Moji Shori 重复字符处理
|
||||
East Asian Composition Settings 东亚排版设置
|
||||
Korean Composition Settings 韩文排版设置
|
||||
Rotate 旋转
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4176,6 +4176,7 @@ digits Malayalam 馬來亞拉姆數字
|
||||
Roman Hanging Punctuation 羅馬懸掛標點
|
||||
Korean Line Break Anywhere 韓文任意位置換行
|
||||
Bunri-Kinshi 分離禁止
|
||||
Kurikaeshi Moji Shori 重複字元處理
|
||||
East Asian Composition Settings 東亞排版設定
|
||||
Korean Composition Settings 韓文排版設定
|
||||
Rotate 旋轉
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -859,6 +859,11 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
});
|
||||
});
|
||||
// A repeat mark starting a line is drawn as the character it repeats.
|
||||
let repeat = shared_para(app, |p| p.kurikaeshi_moji_shori) == Some(true);
|
||||
if menu_item(ui, tl!("Kurikaeshi Moji Shori"), has, repeat) {
|
||||
toggle_kurikaeshi_moji_shori(app);
|
||||
}
|
||||
// How a line keeps the kinsoku characters off its ends: the selected paragraphs' type is
|
||||
// checked, and none is when they differ.
|
||||
let kinsoku_type = shared_para(app, |p| p.kinsoku_type);
|
||||
@@ -937,6 +942,14 @@ fn toggle_bunri_kinshi(app: &mut VectorcraftApp) {
|
||||
format(app, json!({"bunriKinshi": !on}));
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori (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.
|
||||
fn toggle_kurikaeshi_moji_shori(app: &mut VectorcraftApp) {
|
||||
let on = shared_para(app, |p| p.kurikaeshi_moji_shori) == Some(true);
|
||||
format(app, json!({"kurikaeshiMojiShori": !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.
|
||||
@@ -949,7 +962,7 @@ fn toggle_korean_line_break_anywhere(app: &mut VectorcraftApp) {
|
||||
/// 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
|
||||
/// Kurikaeshi Moji Shori, 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();
|
||||
@@ -971,7 +984,7 @@ fn reset_panel(app: &mut VectorcraftApp) {
|
||||
"autoLeading": j.auto_leading, "singleWordJustification": "fullJustify",
|
||||
"direction": "auto", "leadingModel": "romanBaseline", "mojikumi": "lineEndHalf", "burasagari": "standard", "kinsoku": "hard",
|
||||
"kinsokuType": "pushOutOnly", "composer": "everyLine", "romanHangingPunctuation": false, "koreanLineBreakAnywhere": false,
|
||||
"bunriKinshi": false
|
||||
"bunriKinshi": false, "kurikaeshiMojiShori": false
|
||||
}),
|
||||
);
|
||||
para_cmd(app, "text.tabs.clear", json!({}));
|
||||
|
||||
@@ -324,6 +324,37 @@ fn bunri_kinshi_toggle_follows_kinsoku_and_the_selected_paragraphs() {
|
||||
assert_eq!(flags(&app), (false, false), "Reset Panel turns it off");
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: new type has it off; the menu item turns it on for the paragraphs the Type
|
||||
/// tool's selection touches in one undo step, a click while the selected paragraphs differ turns it
|
||||
/// on for all of them, and a click while all have it turns it off. Reset Panel turns it off.
|
||||
#[test]
|
||||
fn kurikaeshi_moji_shori_toggle_follows_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).kurikaeshi_moji_shori, text.para_at(1).kurikaeshi_moji_shori)
|
||||
};
|
||||
assert_eq!(flags(&app), (false, false), "new type has it off");
|
||||
select_range(&mut app, 0, 3);
|
||||
let history = app.session.active().unwrap().history.undo.len();
|
||||
toggle_kurikaeshi_moji_shori(&mut app);
|
||||
assert_eq!(flags(&app), (true, false));
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), history + 1);
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
toggle_kurikaeshi_moji_shori(&mut app);
|
||||
assert_eq!(flags(&app), (true, true), "mixed: a click turns it on for all");
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
toggle_kurikaeshi_moji_shori(&mut app);
|
||||
assert_eq!(flags(&app), (false, false), "all on: a click turns it off");
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
toggle_kurikaeshi_moji_shori(&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");
|
||||
|
||||
+24
@@ -9451,6 +9451,30 @@ https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html
|
||||
{"name":"run_command","arguments":{"command":"text.setFormat","params":{"bunriKinshi":true}}}
|
||||
```
|
||||
|
||||
## Kurikaeshi Moji Shori
|
||||
|
||||
`text.setFormat {kurikaeshiMojiShori: bool}` (Paragraph panel menu › Kurikaeshi Moji Shori, 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 repeat mark that starts a line of point or area type, horizontal or vertical, is drawn as the
|
||||
character it repeats, so both characters show when a line break separates them. The text keeps the mark: copying,
|
||||
searching, the caret and the line breaks stay as they were, and the drawn character takes the mark's place and width.
|
||||
SVG export with live type writes the drawn character, and embeds its glyph when fonts are embedded.
|
||||
VectorCraft's set of marks and its rules: 々 repeats a Han ideograph, ゝ and ゞ a hiragana, and ヽ and ヾ a katakana; the
|
||||
repeated character is the last one before the mark in the paragraph that is not a repeat mark, a soft return or a
|
||||
combining voicing mark (U+3099, U+309A), looking back into the frames before when threaded type continues a paragraph
|
||||
from one frame into the next; ゝ and ヽ draw it without its voicing marks, and ゞ and ヾ draw its voiced form, or the
|
||||
plain kana when it has none. A mark is drawn as it is when nothing before it in the paragraph fits, when the font has no glyph for the character, at the start of a
|
||||
paragraph, inside tate-chu-yoko or warichu, and on type on a path. Off by default. It is saved with the paragraph
|
||||
(`kurikaeshi_moji_shori` in `para`) only when on, paragraph styles carry it (`kurikaeshi_moji_shori` in a paragraph
|
||||
style's attributes), and Reset Panel turns it off. A value that is not true or false is refused, and a call that gives
|
||||
the value the paragraphs already have records no undo step. One undo step. `.ai` editing data does not hold it, and a
|
||||
save reports a paragraph with it on 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":{"kurikaeshiMojiShori":true}}}
|
||||
```
|
||||
|
||||
## Korean Line Break Anywhere
|
||||
|
||||
`text.setFormat {koreanLineBreakAnywhere: bool}` (Paragraph panel menu › Korean Line Break Anywhere, shown with the
|
||||
|
||||
@@ -67,6 +67,7 @@ against Illustrator's public documentation; **estimated** unless noted.
|
||||
| CJK: input methods (marked text, candidate window) | done | |
|
||||
| CJK: kinsoku (Hard, Soft, None), the predefined mojikumi sets (None, YakumonoHankaku, GyomatsuYakumonoHankaku, GyomatsuYakumonoZenkaku, YakumonoZenkaku, with VectorCraft's own spacing for each) and Line-end Punctuation Half Width, tate-chu-yoko (auto) | done / partial | custom kinsoku sets, custom mojikumi sets and the Mojikumi Settings dialog missing |
|
||||
| CJK: Kinsoku Shori Type (Push In First, Push Out First, Push Out Only) | done | Paragraph panel menu › Kinsoku Shori Type (`text.setFormat {kinsokuType}`), with the East Asian options ([Formatting Asian characters](https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html)); Push Out Only is the default, and a push-in closes the line's gaps next to CJK characters by at most a tenth of an em each (VectorCraft's own limit). Evidence: `layout::wrapping_tests::kinsoku_shori_type_pushes_a_closing_bracket_in_or_out`, `tests::vertical::kinsoku_shori_type_pushes_a_closing_bracket_in_or_out`, `typecmd::area_tests::kinsoku_shori_type_is_set_per_paragraph_and_saved_only_when_not_push_out_only` |
|
||||
| CJK: Kurikaeshi Moji Shori | done | Paragraph panel menu › Kurikaeshi Moji Shori (`text.setFormat {kurikaeshiMojiShori}`), with the East Asian options ([Format East Asian characters](https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html)): a repeat mark (々, ゝ, ゞ, ヽ, ヾ) that starts a line of point or area type is drawn as the character it repeats, and the text keeps the mark; SVG export with live type writes the drawn character. The set of marks and the voicing rules are VectorCraft's own. Off by default, saved natively only when on, carried by paragraph styles. Evidence: `tests::repeat_marks_stand_for_the_character_before_them`, `tests::kurikaeshi_moji_shori_draws_the_repeated_character_at_a_line_start`, `typecmd::area_tests::kurikaeshi_moji_shori_is_set_per_paragraph_and_saved_only_when_on`, `threads::tests::a_continued_frame_carries_the_character_a_repeat_mark_stands_for`, `panels::paragraph::tests::kurikaeshi_moji_shori_toggle_follows_the_selected_paragraphs`, `text_layout::a_repeat_mark_at_a_line_start_is_written_as_the_character_it_draws` |
|
||||
| CJK: Proportional Metrics (`palt` in horizontal type, `vpal` in vertical type) | done | #966 |
|
||||
| CJK: East Asian Type units (Q, Ha) | done | Preferences › Units › East Asian Type (`unitsAsianType`, Points by default) offers every unit and Q and Ha, a quarter of a millimetre each ([Scripting Guide](https://ai-scripting.docsforadobe.dev/scripting/measurementUnits/): 0.709 pt per Q; [InDesign's unit notation](https://helpx.adobe.com/in/indesign/desktop/layout-and-grid-tools/rulers-and-measure-tools/change-ruler-measurement-units.html): `q`, `h`). The public pages do not say which fields follow it, so no field uses it yet and that waits for a source. Evidence: `q_and_ha_are_a_quarter_millimetre`, `east_asian_type_unit_*` |
|
||||
| CJK: manual tate-chu-yoko | done | Character panel menu › Tate-chu-yoko (`text.setFormat` / `text.setRangeStyle {tateChuYoko}`), with Show East Asian Options: marked characters stand side by side across one em of a vertical column, squeezed to the em when wider; two or three half-width digits still do so without the mark; horizontal type keeps the mark and does not move them. Tate-chu-yoko Settings… (`ui.tateChuYokoSettings`, `{tcyUpDown, tcyLeftRight}` in points) moves a marked block up or down and right or left as one piece. Evidence: `tests_vertical::manual_tate_chu_yoko_sets_marked_characters_across_one_em`, `tests_vertical::tate_chu_yoko_settings_move_a_marked_block_up_down_left_and_right`, `typecmd::tate_chu_yoko_is_a_character_attribute_saved_only_when_on`, `typecmd::tate_chu_yoko_settings_are_character_attributes_saved_only_when_set`, `dialogs::tate_chu_yoko::tests` |
|
||||
|
||||
Reference in New Issue
Block a user