Replace Rustybuzz with Parley for text layout, and add text tilt parameter (#2739)

* replace rustybuzz with parley for text layout handling

change text input direction based on text direction

* Code review

* change default character spacing to 0

* add shear to text node

this also adds migration code for documents that don't have shear

* shear migration for text node

- add shear property
- set character spacing to 0

* use old max_width and max_height in text migration if available

* Final code review pass

* Add units to the parameters

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Salman Abuhaimed
2025-07-01 12:23:17 +03:00
committed by GitHub
parent d8e15aeb93
commit 83773baa00
18 changed files with 488 additions and 300 deletions

View File

@@ -9,23 +9,37 @@ fn text<'i: 'n>(
editor: &'i WasmEditorApi,
text: String,
font_name: Font,
#[default(24.)] font_size: f64,
#[default(1.2)] line_height_ratio: f64,
#[default(1.)] character_spacing: f64,
#[default(None)] max_width: Option<f64>,
#[default(None)] max_height: Option<f64>,
#[unit(" px")]
#[default(24.)]
font_size: f64,
#[unit("x")]
#[default(1.2)]
line_height_ratio: f64,
#[unit(" px")]
#[default(0.)]
character_spacing: f64,
#[unit(" px")]
#[default(None)]
max_width: Option<f64>,
#[unit(" px")]
#[default(None)]
max_height: Option<f64>,
#[unit("°")]
#[default(0.)]
tilt: f64,
) -> VectorDataTable {
let buzz_face = editor.font_cache.get(&font_name).map(|data| load_face(data));
let typesetting = TypesettingConfig {
font_size,
line_height_ratio,
character_spacing,
max_width,
max_height,
tilt,
};
let result = VectorData::from_subpaths(to_path(&text, buzz_face, typesetting), false);
let font_data = editor.font_cache.get(&font_name).map(|f| load_font(f));
let result = VectorData::from_subpaths(to_path(&text, font_data, typesetting), false);
VectorDataTable::new(result)
}