Fix CJ-Latin space at manual line breaks (#6700)
Co-authored-by: Laurenz Mädje <laurmaedje@gmail.com>
This commit is contained in:
parent
560e49b67c
commit
c340c27924
|
|
@ -149,6 +149,7 @@ pub fn line<'a>(
|
|||
|
||||
// Trim the line at the end, if necessary for this breakpoint.
|
||||
let trim = range.start + breakpoint.trim(full).len();
|
||||
let trimmed_range = range.start..trim;
|
||||
|
||||
// Collect the items for the line.
|
||||
let mut items = Items::new();
|
||||
|
|
@ -179,7 +180,8 @@ pub fn line<'a>(
|
|||
trim_weak_spacing(&mut items);
|
||||
|
||||
// Deal with CJ characters at line boundaries.
|
||||
adjust_cj_at_line_boundaries(p, full, &mut items);
|
||||
// Use the trimmed range for robust boundary checks.
|
||||
adjust_cj_at_line_boundaries(p, trimmed_range, &mut items);
|
||||
|
||||
// Compute the line's width.
|
||||
let width = items.iter().map(Item::natural_width).sum();
|
||||
|
|
@ -319,7 +321,11 @@ fn collect_range<'a>(
|
|||
///
|
||||
/// See Requirements for Chinese Text Layout, Section 3.1.6.3 Compression of
|
||||
/// punctuation marks at line start or line end.
|
||||
fn adjust_cj_at_line_boundaries(p: &Preparation, text: &str, items: &mut Items) {
|
||||
///
|
||||
/// The `range` should only contain regular texts, with linebreaks trimmed.
|
||||
fn adjust_cj_at_line_boundaries(p: &Preparation, range: Range, items: &mut Items) {
|
||||
let text = &p.text[range];
|
||||
|
||||
if text.starts_with(BEGIN_PUNCT_PAT)
|
||||
|| (p.config.cjk_latin_spacing && text.starts_with(is_of_cj_script))
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
|
|
@ -84,6 +84,19 @@ abc字#linebreak()
|
|||
abc字\
|
||||
母
|
||||
|
||||
--- issue-6539-cjk-latin-spacing-at-manual-linebreak ---
|
||||
// Issue #6539
|
||||
#set text(cjk-latin-spacing: auto)
|
||||
#set box(width: 2.3em, stroke: (x: green))
|
||||
|
||||
#box(align(end)[甲国\ T国])
|
||||
|
||||
#box(align(end)[乙国 \ T国])
|
||||
|
||||
#box(align(end)[丙国 T国])
|
||||
|
||||
#box(align(end)[丁国T国])
|
||||
|
||||
--- issue-2650-cjk-latin-spacing-meta ---
|
||||
测a试
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue