Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Layout: end manual tate-chu-yoko at soft return, and use separator metrics for empty continuation line

Taha-Mahmoodi7511f84d5d09
diff --git a/crates/text/src/layout/flow.rs b/crates/text/src/layout/flow.rs
index 324352060..1680d3acb 100644
--- a/crates/text/src/layout/flow.rs
+++ b/crates/text/src/layout/flow.rs
@@ -392,6 +392,13 @@ fn run_paragraph_lines(cx: &mut Ctx<'_>, pen: &mut Pen<'_>, t: &TextObject, mut
let mut index = 0;
let mut emitted_empty_continuation = false;
loop {
+ let pm = if index >= n
+ && let Some(last) = paragraph.sg.last()
+ {
+ Metrics::of(last)
+ } else {
+ paragraph.pm
+ };
let mut placement = PlacementContext {
para: paragraph.para,
pr: &paragraph.pr,
@@ -399,7 +406,7 @@ fn run_paragraph_lines(cx: &mut Ctx<'_>, pen: &mut Pen<'_>, t: &TextObject, mut
continued: paragraph.continued,
rtl: paragraph.rtl,
mirror: paragraph.mirror,
- pm: paragraph.pm,
+ pm,
composed: &paragraph.composed,
hyphen_run,
hyphen_limit: paragraph.hyphen_limit,
diff --git a/crates/text/src/layout/vertical.rs b/crates/text/src/layout/vertical.rs
index 4ce9f03d8..ebc351511 100644
--- a/crates/text/src/layout/vertical.rs
+++ b/crates/text/src/layout/vertical.rs
@@ -23,7 +23,7 @@ pub(super) fn whole_character_widths(glyphs: &mut [SGlyph]) {
/// before the automatic digit rule.
/// <https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html>
pub(super) fn tate_chu_yoko(g: &mut [SGlyph], style: impl Fn(&SGlyph) -> (f64, bool)) {
- let manual: Vec<bool> = g.iter().map(|gl| style(gl).1).collect();
+ let manual: Vec<bool> = g.iter().map(|gl| gl.ch != '\u{2028}' && style(gl).1).collect();
let digits: Vec<bool> = g.iter().map(|gl| gl.inline.is_none() && gl.ch.is_ascii_digit()).collect();
let mut i = 0;
while i < g.len() {