Merge pull request #3408

This commit is contained in:
autocraft-bot[bot] committed 2026-12-02 18:02:20 +00:00
commit dc4d910376
3 files changed
+16 -3

No files matched your search

Generated
+1
View File
@@ -2347,6 +2347,7 @@ dependencies = [
"regex",
"unicode-bidi",
"unicode-bidi-mirroring",
"unicode-properties",
"unicode-script",
"unicode-segmentation",
]
+1
View File
@@ -13,6 +13,7 @@ unicode-bidi = { workspace = true }
unicode-segmentation = { workspace = true }
unicode-bidi-mirroring = { workspace = true }
unicode-script = { workspace = true }
unicode-properties = { version = "0.1.4", default-features = false, features = ["general-category"] }
designcraft-geom = { workspace = true }
designcraft-color = { workspace = true }
designcraft-doc = { workspace = true }
+14 -3
View File
@@ -9,6 +9,8 @@
//! ([`TIER_COST`]), so the composer prefers word-space changes, then hyphenation, then letter
//! spacing, then glyph scaling.
use unicode_properties::{GeneralCategoryGroup, UnicodeGeneralCategory};
use crate::shape::{Glyph, SOFT_HYPHEN};
/// One line chosen by a breaker: glyphs `start..end` are visible; `next` is where the next line starts.
@@ -407,10 +409,8 @@ pub(super) fn dot_break(text: &str, glyphs: &[Glyph], i: usize) -> bool {
fn has_dot_letters(chars: impl Iterator<Item = char>, minimum: usize) -> bool {
// Some combining marks have the Unicode Alphabetic property as well.
static MARK: std::sync::LazyLock<Option<regex::Regex>> = std::sync::LazyLock::new(|| regex::Regex::new(r"\A\p{M}\z").ok());
let Some(mark) = MARK.as_ref() else { return false };
chars
.filter(|&c| c.is_ascii() || !mark.is_match(c.encode_utf8(&mut [0; 4])))
.filter(|&c| c.is_ascii() || c.general_category_group() != GeneralCategoryGroup::Mark)
.take_while(|&c| c.is_alphabetic() && !is_cjk(c))
.take(minimum)
.count()
@@ -1187,6 +1187,17 @@ pub fn balanced(text: &str, glyphs: &[Glyph], hyph_after: &[bool], sp: &Spacing,
mod tests {
use super::*;
#[test]
fn alphabetic_and_extended_marks_do_not_add_dot_break_letters() {
assert!('\u{0345}'.is_alphabetic());
assert!('\u{093E}'.is_alphabetic());
// Nonspacing, spacing, enclosing, and extended combining marks.
for mark in ['\u{0345}', '\u{093E}', '\u{20DD}', '\u{1AB0}'] {
assert!(!has_dot_letters(['P', 'e', mark].into_iter(), 3), "{mark:?}");
assert!(has_dot_letters(['P', 'e', mark, 'r'].into_iter(), 3), "{mark:?}");
}
}
#[test]
fn tiers_are_used_in_order() {
// Word stretch alone.