From 40f4c920e732c4649dc198aed75672612b078ac6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 10:26:11 -0800 Subject: [PATCH] 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. --- crates/doc/src/text/para_style.rs | 10 +++ crates/engine/src/cmd/panelcmds.rs | 7 +- crates/engine/src/cmd/textstyles.rs | 1 + crates/engine/src/cmd/typecmd/area_tests.rs | 53 +++++++++++ crates/engine/src/tests/textedit.rs | 1 + crates/eps/src/ai_editing/tests.rs | 36 ++++++++ crates/eps/src/ai_editing/writer/texts.rs | 4 + crates/text/src/justify.rs | 5 +- crates/text/src/layout.rs | 2 + crates/text/src/layout/breaking.rs | 19 ++-- crates/text/src/layout/flow.rs | 24 +++-- crates/text/src/layout/wrapping_tests.rs | 87 +++++++++++++++++++ crates/text/src/lib.rs | 2 +- crates/text/src/shape.rs | 35 ++++++++ crates/text/src/tests.rs | 81 +++++++++++++++++ .../ui-egui/src/dialogs/para_style_options.rs | 21 +++-- .../src/dialogs/para_style_options/tests.rs | 33 ++++++- crates/ui-egui/src/i18n/bg.tsv | 1 + crates/ui-egui/src/i18n/bs.tsv | 1 + crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/hi.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/vi.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + crates/ui-egui/src/panels/paragraph.rs | 25 +++++- crates/ui-egui/src/panels/paragraph/tests.rs | 42 +++++++++ docs/mcp.md | 21 +++++ docs/target-app-parity.md | 3 +- 48 files changed, 510 insertions(+), 29 deletions(-) diff --git a/crates/doc/src/text/para_style.rs b/crates/doc/src/text/para_style.rs index bb3725072e..a2c2a66498 100644 --- a/crates/doc/src/text/para_style.rs +++ b/crates/doc/src/text/para_style.rs @@ -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 for ParaStyleFile { burasagari, kinsoku, kinsoku_type, + bunri_kinshi, roman_hanging, kashida, korean_line_break_anywhere, @@ -401,6 +408,7 @@ impl From for ParaStyleFile { burasagari, kinsoku, kinsoku_type, + bunri_kinshi, roman_hanging, kashida, korean_line_break_anywhere, @@ -431,6 +439,7 @@ impl From for ParaStyle { burasagari, kinsoku, kinsoku_type, + bunri_kinshi, roman_hanging, kashida, korean_line_break_anywhere, @@ -456,6 +465,7 @@ impl From for ParaStyle { burasagari, kinsoku, kinsoku_type, + bunri_kinshi, roman_hanging, kashida, korean_line_break_anywhere, diff --git a/crates/engine/src/cmd/panelcmds.rs b/crates/engine/src/cmd/panelcmds.rs index 83a0655284..325be0dd3c 100644 --- a/crates/engine/src/cmd/panelcmds.rs +++ b/crates/engine/src/cmd/panelcmds.rs @@ -67,7 +67,7 @@ pub fn specs() -> Vec { "Character / Paragraph", [], None, - "{ids?|id?, kerning?: 1/1000 em|\"auto\"|\"optical\", baselineShift?: pt, hScale?: %, vScale?: %, rotation?: deg counter-clockwise (0: upright), underline?, strikethrough?, allCaps?, smallCaps?: bool, position?: \"normal\"|\"superscript\"|\"subscript\" (sizes from Document Setup), antiAlias?: \"none\"|\"sharp\"|\"crisp\"|\"strong\" (Character panel › Anti-aliasing Method, how the type's edges are drawn as pixels; it sets each targeted type object, with or without a range; each frame of a thread keeps its own method; graph labels keep it for every label of their kind when the graph is drawn again; new type: \"sharp\"), leftIndent?, rightIndent?, firstLineIndent?, spaceBefore?, spaceAfter?: pt (±1296), list?: \"none\"|\"bullet\"|\"number\", bullet?: \"none\"|\"dot\"|\"dash\"|\"circle\"|\"square\", number?: \"none\"|\"arabic\"|\"upperLetters\"|\"lowerLetters\"|\"upperRoman\"|\"lowerRoman\"|\"twoDigits\"|\"threeDigits\", listAlign?: \"left\"|\"right\", listLevel?: 1..9 (Paragraph panel › Bullets and Numbered List: each paragraph of a list starts with its marker, drawn in the font, size and color of the paragraph's first character, and its text starts at the next tab stop after the marker, the left indent counting as a stop; a bulleted list's marker is its bullet, and a numbered list's is the paragraph's number and a period: 1, 2, 3; A to Z, then AA, BB; a to z, then aa, bb; I, II, III; i, ii, iii; 01 to 99, then 100; 001 to 999, then 1000; letters and roman numerals past 3999 in Arabic digits; the numbers count the story's numbered paragraphs, its threaded frames included, from 1 after a paragraph in no list, and an empty or bulleted paragraph is not counted; list \"bullet\" keeps a list's bullet, else a dot, and list \"number\" keeps a numbered list's style, else arabic; without list, a number style makes a numbered list and a bullet makes a bulleted one; \"none\" in any of the three turns the list off; a paragraph that joins a list with left and first-line indents of 0 gets 18 and -18 unless the call sets an indent; a horizontal right-to-left list paragraph has its indents mirrored, measured from the right; listAlign \"right\" (Bullets and Numbering…'s Alignment) puts the marker against the text, and \"left\" (the default) puts it at the first line's start, the text starting at the same place with either; it sets the paragraphs that are in a list or that the call puts in one, and a list keeps it when it changes between bullets and numbers; listLevel (Tab and Shift+Tab at the start of a list paragraph, Bullets and Numbering…'s Level) is a whole number from 1 to 9 that sets the paragraphs in a list or that the call puts in one, a list keeping it when it changes between bullets and numbers, and a list turned on without listLevel starting at level 1; each level past the first sets the paragraph 18 pt further in than its left indent, and each level counts its own numbers: a list paragraph with text sets the counts of the levels deeper than its own back to 0, so a deeper numbered paragraph after it counts from 1, and a paragraph back at a shallower level goes on with that level's count), hyphenate?: bool, wordsLongerThan?: letters 1..25 (5), afterFirst?, beforeLast?: letters 1..15 (3), hyphenLimit?: lines 0..25 (0: no limit), hyphenationZone?: pt 0..1296 (0; Single-line Composer only), hyphenateCapitalized?: bool (true) (Paragraph panel menu › Hyphenation…: only words longer than wordsLongerThan break, keeping afterFirst letters before the hyphen and beforeLast after it; at most hyphenLimit lines in a row end with a hyphen; a line whose text already ends within hyphenationZone of its right edge breaks before the next word instead of hyphenating it; the counts are rounded, and every value is clamped to its range), wordSpacing?: % 0..1000 (80, 100, 133), letterSpacing?: % of a word space -100..500 (0, 0, 0), glyphScaling?: % 50..200 (100, 100, 100): each [min, desired, max] or {min?, desired?, max?} (Paragraph panel menu › Justification…: Desired applies to every line, Minimum and Maximum bound what justified lines may use; values are clamped to their range, and Minimum ≤ Desired ≤ Maximum must hold afterwards or nothing changes), autoLeading?: % of the size 0..500 (120; the leading of characters whose leading is Auto), singleWordJustification?: \"fullJustify\"|\"alignLeft\"|\"alignCenter\"|\"alignRight\" (a justified line holding one word), mojikumi?: \"none\"|\"lineEndHalf\" (Japanese punctuation spacing), kinsoku?: \"none\"|\"hard\"|\"soft\" (Kinsoku Set: Soft lets 々, ー and small kana start a line), kinsokuType?: \"pushInFirst\"|\"pushOutFirst\"|\"pushOutOnly\" (Paragraph panel menu › Kinsoku Shori Type: how area type keeps those characters off a line's ends; pushInFirst sets them on the line when its gaps next to CJK characters can close up enough, by at most a tenth of an em each, pushOutFirst does so only when moving the character before them to the next line would leave the line more than an em short, and pushOutOnly, the default, moves it unless Burasagari hangs an overflowing comma or full stop; no effect with kinsoku \"none\"), direction?: \"auto\"|\"leftToRight\"|\"rightToLeft\" (paragraph direction; auto: from each paragraph's first strong character), leadingModel?: \"romanBaseline\"|\"emBoxTop\" (leading measured baseline to baseline, or em box top to top), charAlign?: \"romanBaseline\"|\"emBoxTop\"|\"emBoxCenter\"|\"emBoxBottom\"|\"icfTop\"|\"icfBottom\" (where characters smaller than the largest on their line line up with it), proportionalMetrics?: bool (full-width glyphs on the font's proportional widths: `palt` in horizontal type, `vpal` in vertical type), tateChuYoko?: bool (Character panel menu › Tate-chu-yoko, with Show East Asian Options: in vertical type those characters stand side by side across one em of the column; kept on the characters and ignored in horizontal type), tcyUpDown?, tcyLeftRight?: pt -1296..1296 (Character panel menu › Tate-chu-yoko Settings, as text.setRangeStyle: a tate-chu-yoko block moves up or down, right or left, and on a vertical path toward or away from the path's start, to its left or right), standardVerticalRoman?: bool (Character panel menu › Standard Vertical Roman Alignment, as text.setRangeStyle), noBreak?: bool (Character panel menu › No Break: these characters stay on one line, including across a space inside the run), kashidas?: bool (Character panel menu › Kashidas: selected characters allow insertion only when both joined neighbors have it on; on by default), charDirection?: \"default\"|\"leftToRight\"|\"rightToLeft\" (Character panel menu › Character Direction: the characters are set left to right or right to left inside their paragraph, as a Unicode bidi embedding; default: as the bidi algorithm sets them), digits?: \"default\"|\"arabic\"|\"hindi\"|\"farsi\"|\"devanagari\"|\"bengali\"|\"gurmukhi\"|\"gujarati\"|\"odia\"|\"tamil\"|\"telugu\"|\"kannada\"|\"malayalam\" (Character panel menu › Digits: the numeral system every digit is drawn in, whatever was typed: Western, Arabic-Indic (hindi), Eastern Arabic-Indic (farsi) or an Indic script's own digits), fontHeightReference?: \"emBox\"|\"capHeight\"|\"xHeight\"|\"icfBox\" (Character panel › Set Font Height Reference, as text.setRangeStyle: the height of the font that the size measures), language?: name|tag (Character panel › Language, as text.setRangeStyle), fontAxes?: {\"wght\": 650, …} (Character panel › Variable Font, as text.setRangeStyle: each axis named set in its units and clamped to its range, null back to the style's own setting), burasagari?: \"none\"|\"standard\"|\"forced\" (Paragraph panel menu › Burasagari None/Regular/Force: an East Asian comma or full stop ending an area type line hangs outside it: when it doesn't fit, or always; new type: \"standard\"), romanHangingPunctuation?: bool (Paragraph panel menu › Roman Hanging Punctuation: quotation marks, hyphens, full stops and commas starting or ending a line hang outside the margin, asterisks, tildes, ellipses, dashes, colons and semicolons by half; off by default), koreanLineBreakAnywhere?: bool (Paragraph panel menu › Korean Line Break Anywhere: a line may break between any two Hangul syllables; off, a word with Hangul in it breaks only at its spaces and punctuation, or where it is wider than the line; new type: false, paragraphs saved before the option: true), kashida?: \"none\"|\"short\"|\"medium\"|\"long\"|\"stylistic\" (Paragraph panel › Insert Kashidas: justified lines of horizontal area type lengthen each Arabic word with a kashida between its last pair of joined letters, at most a quarter, half or whole em long, or whole tatweels up to an em for stylistic, before they widen their word spaces; none by default), composer?: \"singleLine\"|\"everyLine\" (line breaking, Every-line by default), start?: byte, end?: byte} (baselineShift is in document points and hScale includes the object transform; groups include their text descendants; with a range: the character attributes style that range and the paragraph attributes apply to the paragraphs it touches; without: all the text, and graph labels keep the character and paragraph attributes for every label of their kind when the graph is drawn again, the graph still setting each label's alignment)", + "{ids?|id?, kerning?: 1/1000 em|\"auto\"|\"optical\", baselineShift?: pt, hScale?: %, vScale?: %, rotation?: deg counter-clockwise (0: upright), underline?, strikethrough?, allCaps?, smallCaps?: bool, position?: \"normal\"|\"superscript\"|\"subscript\" (sizes from Document Setup), antiAlias?: \"none\"|\"sharp\"|\"crisp\"|\"strong\" (Character panel › Anti-aliasing Method, how the type's edges are drawn as pixels; it sets each targeted type object, with or without a range; each frame of a thread keeps its own method; graph labels keep it for every label of their kind when the graph is drawn again; new type: \"sharp\"), leftIndent?, rightIndent?, firstLineIndent?, spaceBefore?, spaceAfter?: pt (±1296), list?: \"none\"|\"bullet\"|\"number\", bullet?: \"none\"|\"dot\"|\"dash\"|\"circle\"|\"square\", number?: \"none\"|\"arabic\"|\"upperLetters\"|\"lowerLetters\"|\"upperRoman\"|\"lowerRoman\"|\"twoDigits\"|\"threeDigits\", listAlign?: \"left\"|\"right\", listLevel?: 1..9 (Paragraph panel › Bullets and Numbered List: each paragraph of a list starts with its marker, drawn in the font, size and color of the paragraph's first character, and its text starts at the next tab stop after the marker, the left indent counting as a stop; a bulleted list's marker is its bullet, and a numbered list's is the paragraph's number and a period: 1, 2, 3; A to Z, then AA, BB; a to z, then aa, bb; I, II, III; i, ii, iii; 01 to 99, then 100; 001 to 999, then 1000; letters and roman numerals past 3999 in Arabic digits; the numbers count the story's numbered paragraphs, its threaded frames included, from 1 after a paragraph in no list, and an empty or bulleted paragraph is not counted; list \"bullet\" keeps a list's bullet, else a dot, and list \"number\" keeps a numbered list's style, else arabic; without list, a number style makes a numbered list and a bullet makes a bulleted one; \"none\" in any of the three turns the list off; a paragraph that joins a list with left and first-line indents of 0 gets 18 and -18 unless the call sets an indent; a horizontal right-to-left list paragraph has its indents mirrored, measured from the right; listAlign \"right\" (Bullets and Numbering…'s Alignment) puts the marker against the text, and \"left\" (the default) puts it at the first line's start, the text starting at the same place with either; it sets the paragraphs that are in a list or that the call puts in one, and a list keeps it when it changes between bullets and numbers; listLevel (Tab and Shift+Tab at the start of a list paragraph, Bullets and Numbering…'s Level) is a whole number from 1 to 9 that sets the paragraphs in a list or that the call puts in one, a list keeping it when it changes between bullets and numbers, and a list turned on without listLevel starting at level 1; each level past the first sets the paragraph 18 pt further in than its left indent, and each level counts its own numbers: a list paragraph with text sets the counts of the levels deeper than its own back to 0, so a deeper numbered paragraph after it counts from 1, and a paragraph back at a shallower level goes on with that level's count), hyphenate?: bool, wordsLongerThan?: letters 1..25 (5), afterFirst?, beforeLast?: letters 1..15 (3), hyphenLimit?: lines 0..25 (0: no limit), hyphenationZone?: pt 0..1296 (0; Single-line Composer only), hyphenateCapitalized?: bool (true) (Paragraph panel menu › Hyphenation…: only words longer than wordsLongerThan break, keeping afterFirst letters before the hyphen and beforeLast after it; at most hyphenLimit lines in a row end with a hyphen; a line whose text already ends within hyphenationZone of its right edge breaks before the next word instead of hyphenating it; the counts are rounded, and every value is clamped to its range), wordSpacing?: % 0..1000 (80, 100, 133), letterSpacing?: % of a word space -100..500 (0, 0, 0), glyphScaling?: % 50..200 (100, 100, 100): each [min, desired, max] or {min?, desired?, max?} (Paragraph panel menu › Justification…: Desired applies to every line, Minimum and Maximum bound what justified lines may use; values are clamped to their range, and Minimum ≤ Desired ≤ Maximum must hold afterwards or nothing changes), autoLeading?: % of the size 0..500 (120; the leading of characters whose leading is Auto), singleWordJustification?: \"fullJustify\"|\"alignLeft\"|\"alignCenter\"|\"alignRight\" (a justified line holding one word), mojikumi?: \"none\"|\"lineEndHalf\" (Japanese punctuation spacing), kinsoku?: \"none\"|\"hard\"|\"soft\" (Kinsoku Set: Soft lets 々, ー and small kana start a line), kinsokuType?: \"pushInFirst\"|\"pushOutFirst\"|\"pushOutOnly\" (Paragraph panel menu › Kinsoku Shori Type: how area type keeps those characters off a line's ends; pushInFirst sets them on the line when its gaps next to CJK characters can close up enough, by at most a tenth of an em each, pushOutFirst does so only when moving the character before them to the next line would leave the line more than an em short, and pushOutOnly, the default, moves it unless Burasagari hangs an overflowing comma or full stop; no effect with kinsoku \"none\"), bunriKinshi?: bool (Paragraph panel menu › Bunri-Kinshi: a line never breaks inside an inseparable pair, two em dashes, two horizontal ellipses, two two-dot leaders or the two halves of a vertical kana repeat mark, and justification adds no space inside one; kept but without effect with kinsoku \"none\"; off by default), direction?: \"auto\"|\"leftToRight\"|\"rightToLeft\" (paragraph direction; auto: from each paragraph's first strong character), leadingModel?: \"romanBaseline\"|\"emBoxTop\" (leading measured baseline to baseline, or em box top to top), charAlign?: \"romanBaseline\"|\"emBoxTop\"|\"emBoxCenter\"|\"emBoxBottom\"|\"icfTop\"|\"icfBottom\" (where characters smaller than the largest on their line line up with it), proportionalMetrics?: bool (full-width glyphs on the font's proportional widths: `palt` in horizontal type, `vpal` in vertical type), tateChuYoko?: bool (Character panel menu › Tate-chu-yoko, with Show East Asian Options: in vertical type those characters stand side by side across one em of the column; kept on the characters and ignored in horizontal type), tcyUpDown?, tcyLeftRight?: pt -1296..1296 (Character panel menu › Tate-chu-yoko Settings, as text.setRangeStyle: a tate-chu-yoko block moves up or down, right or left, and on a vertical path toward or away from the path's start, to its left or right), standardVerticalRoman?: bool (Character panel menu › Standard Vertical Roman Alignment, as text.setRangeStyle), noBreak?: bool (Character panel menu › No Break: these characters stay on one line, including across a space inside the run), kashidas?: bool (Character panel menu › Kashidas: selected characters allow insertion only when both joined neighbors have it on; on by default), charDirection?: \"default\"|\"leftToRight\"|\"rightToLeft\" (Character panel menu › Character Direction: the characters are set left to right or right to left inside their paragraph, as a Unicode bidi embedding; default: as the bidi algorithm sets them), digits?: \"default\"|\"arabic\"|\"hindi\"|\"farsi\"|\"devanagari\"|\"bengali\"|\"gurmukhi\"|\"gujarati\"|\"odia\"|\"tamil\"|\"telugu\"|\"kannada\"|\"malayalam\" (Character panel menu › Digits: the numeral system every digit is drawn in, whatever was typed: Western, Arabic-Indic (hindi), Eastern Arabic-Indic (farsi) or an Indic script's own digits), fontHeightReference?: \"emBox\"|\"capHeight\"|\"xHeight\"|\"icfBox\" (Character panel › Set Font Height Reference, as text.setRangeStyle: the height of the font that the size measures), language?: name|tag (Character panel › Language, as text.setRangeStyle), fontAxes?: {\"wght\": 650, …} (Character panel › Variable Font, as text.setRangeStyle: each axis named set in its units and clamped to its range, null back to the style's own setting), burasagari?: \"none\"|\"standard\"|\"forced\" (Paragraph panel menu › Burasagari None/Regular/Force: an East Asian comma or full stop ending an area type line hangs outside it: when it doesn't fit, or always; new type: \"standard\"), romanHangingPunctuation?: bool (Paragraph panel menu › Roman Hanging Punctuation: quotation marks, hyphens, full stops and commas starting or ending a line hang outside the margin, asterisks, tildes, ellipses, dashes, colons and semicolons by half; off by default), koreanLineBreakAnywhere?: bool (Paragraph panel menu › Korean Line Break Anywhere: a line may break between any two Hangul syllables; off, a word with Hangul in it breaks only at its spaces and punctuation, or where it is wider than the line; new type: false, paragraphs saved before the option: true), kashida?: \"none\"|\"short\"|\"medium\"|\"long\"|\"stylistic\" (Paragraph panel › Insert Kashidas: justified lines of horizontal area type lengthen each Arabic word with a kashida between its last pair of joined letters, at most a quarter, half or whole em long, or whole tatweels up to an em for stylistic, before they widen their word spaces; none by default), composer?: \"singleLine\"|\"everyLine\" (line breaking, Every-line by default), start?: byte, end?: byte} (baselineShift is in document points and hScale includes the object transform; groups include their text descendants; with a range: the character attributes style that range and the paragraph attributes apply to the paragraphs it touches; without: all the text, and graph labels keep the character and paragraph attributes for every label of their kind when the graph is drawn again, the graph still setting each label's alignment)", has_doc, set_format ), @@ -483,6 +483,7 @@ fn set_format(s: &mut Session, p: &Value) -> Result { "hyphenateCapitalized", "romanHangingPunctuation", "koreanLineBreakAnywhere", + "bunriKinshi", ], C, )?; @@ -536,6 +537,7 @@ fn set_format(s: &mut Session, p: &Value) -> Result { "mojikumi", "kinsoku", "kinsokuType", + "bunriKinshi", "direction", "leadingModel", "charAlign", @@ -869,6 +871,9 @@ fn set_format(s: &mut Session, p: &Value) -> Result { if let Some(v) = kinsoku_type { para.kinsoku_type = v; } + if let Some(v) = flag("bunriKinshi") { + para.bunri_kinshi = v; + } if let Some(v) = direction { para.direction = v; } diff --git a/crates/engine/src/cmd/textstyles.rs b/crates/engine/src/cmd/textstyles.rs index 40d8af22ad..13c2e9e05b 100644 --- a/crates/engine/src/cmd/textstyles.rs +++ b/crates/engine/src/cmd/textstyles.rs @@ -243,6 +243,7 @@ pub fn para_attrs(v: &ParaStyle) -> Map { ("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)), diff --git a/crates/engine/src/cmd/typecmd/area_tests.rs b/crates/engine/src/cmd/typecmd/area_tests.rs index 5545e1be94..2c7d61bb0a 100644 --- a/crates/engine/src/cmd/typecmd/area_tests.rs +++ b/crates/engine/src/cmd/typecmd/area_tests.rs @@ -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. diff --git a/crates/engine/src/tests/textedit.rs b/crates/engine/src/tests/textedit.rs index 46d41adaea..030bd93bfe 100644 --- a/crates/engine/src/tests/textedit.rs +++ b/crates/engine/src/tests/textedit.rs @@ -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"), diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index 0ccfc23ca8..7d956d48b0 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -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 = 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(); diff --git a/crates/eps/src/ai_editing/writer/texts.rs b/crates/eps/src/ai_editing/writer/texts.rs index 1d791afadf..1e47ca1564 100644 --- a/crates/eps/src/ai_editing/writer/texts.rs +++ b/crates/eps/src/ai_editing/writer/texts.rs @@ -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 diff --git a/crates/text/src/justify.rs b/crates/text/src/justify.rs index 3a4f561fb7..cb136a8a24 100644 --- a/crates/text/src/justify.rs +++ b/crates/text/src/justify.rs @@ -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. diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rs index 6e02df73cd..d2685ac211 100644 --- a/crates/text/src/layout.rs +++ b/crates/text/src/layout.rs @@ -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, diff --git a/crates/text/src/layout/breaking.rs b/crates/text/src/layout/breaking.rs index 0ac57e0833..30a498257e 100644 --- a/crates/text/src/layout/breaking.rs +++ b/crates/text/src/layout/breaking.rs @@ -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() diff --git a/crates/text/src/layout/flow.rs b/crates/text/src/layout/flow.rs index 79b8f4326b..95ee27184f 100644 --- a/crates/text/src/layout/flow.rs +++ b/crates/text/src/layout/flow.rs @@ -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], index: us fn is_cjk_gap(glyph: usize, held: &[usize], after: &[Option], 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], 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], 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) { diff --git a/crates/text/src/layout/wrapping_tests.rs b/crates/text/src/layout/wrapping_tests.rs index dde3593b9d..7127cacba3 100644 --- a/crates/text/src/layout/wrapping_tests.rs +++ b/crates/text/src/layout/wrapping_tests.rs @@ -34,6 +34,7 @@ fn synthetic_glyphs(specs: &[(usize, usize, f64, char)]) -> Vec { 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 { + 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::>(); + 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); +} diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index 96b51e7b4c..27e8e39424 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -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}; diff --git a/crates/text/src/shape.rs b/crates/text/src/shape.rs index c1e2b9e0f5..bf35156d04 100644 --- a/crates/text/src/shape.rs +++ b/crates/text/src/shape.rs @@ -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, 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, diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index 30713d33aa..345a1af735 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -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::() + }; + let ends = |t: &TextObject| layout(db(), t).lines.iter().map(|l| l.end).collect::>(); + 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] diff --git a/crates/ui-egui/src/dialogs/para_style_options.rs b/crates/ui-egui/src/dialogs/para_style_options.rs index 1d59bdd679..c343e0682c 100644 --- a/crates/ui-egui/src/dialogs/para_style_options.rs +++ b/crates/ui-egui/src/dialogs/para_style_options.rs @@ -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, unit: Unit) -> Map Result, 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); diff --git a/crates/ui-egui/src/dialogs/para_style_options/tests.rs b/crates/ui-egui/src/dialogs/para_style_options/tests.rs index 467b0dc1ae..0890491606 100644 --- a/crates/ui-egui/src/dialogs/para_style_options/tests.rs +++ b/crates/ui-egui/src/dialogs/para_style_options/tests.rs @@ -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 { 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(); diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 4ca1e345f9..003e92c1b3 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -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 Завъртане diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 972414922b..145fa764f4 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -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. diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index ebfbcd26db..d35885b99e 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index f5ea30ac2b..905e3bc798 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -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. diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index fbc690cf7f..80e949b40d 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -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. diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index e776bc1264..250ec8a0e9 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 711bdeb099..fdf2e6d26e 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -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 Περιστροφή diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 2ab24e227f..d7fa20a656 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 650898ae92..56d323d549 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -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. diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 95e9c9e4c2..51ef29d7b1 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 3d9850d4f5..ae236c981d 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -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 घुमाएँ diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 948931ac13..471a6d073e 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 55e2e73bf1..dcee600fc0 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -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. diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 81dffc495f..c5ee46c80c 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 9d8ec83078..2258ffa985 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -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 回転 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 2630b64269..10dc746e15 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -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. აბზაცის ატრიბუტების რედაქტირებისთვის მონიშნეთ ტექსტური ობიექტი. diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 30ac7dfb76..91b4dd37e7 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -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 회전 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 57ca80dc20..234fad3d6d 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -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. diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 4094d29879..56592675af 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -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. diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index a367880be2..83d04f4861 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index e03cc555b1..f424160f84 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -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 Повернуть diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 83a29c8531..e68d6238b1 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index c781b80ebb..d193678b83 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 75e062627c..a9bb61490a 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -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 Повернути diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 7df0386f9e..f123489546 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -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 diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 9b593188b9..9e74c0f4fc 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -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 旋转 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index d2245176dd..c0137a6f68 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -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 旋轉 diff --git a/crates/ui-egui/src/panels/paragraph.rs b/crates/ui-egui/src/panels/paragraph.rs index cabca387ae..7ad184ea99 100644 --- a/crates/ui-egui/src/panels/paragraph.rs +++ b/crates/ui-egui/src/panels/paragraph.rs @@ -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!({})); diff --git a/crates/ui-egui/src/panels/paragraph/tests.rs b/crates/ui-egui/src/panels/paragraph/tests.rs index 517ef1eeab..177ecd08fb 100644 --- a/crates/ui-egui/src/panels/paragraph/tests.rs +++ b/crates/ui-egui/src/panels/paragraph/tests.rs @@ -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"); diff --git a/docs/mcp.md b/docs/mcp.md index 62a4212472..4b5018e3f2 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -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 diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 5ec97e34c1..e046028548 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -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.