Add line height and character spacing to the Text node (#2016)

This commit is contained in:
Keavon Chambers 2024-10-01 12:28:27 -07:00 committed by GitHub
parent 904cf09c79
commit 2d86fb24ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 127 additions and 34 deletions

View file

@ -3,7 +3,15 @@ use graph_craft::wasm_application_io::WasmEditorApi;
pub use graphene_core::text::{bounding_box, load_face, to_path, Font, FontCache};
#[node_macro::node(category(""))]
fn text<'i: 'n>(_: (), editor: &'i WasmEditorApi, text: String, font_name: Font, #[default(24)] font_size: f64) -> crate::vector::VectorData {
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,
) -> crate::vector::VectorData {
let buzz_face = editor.font_cache.get(&font_name).map(|data| load_face(data));
crate::vector::VectorData::from_subpaths(to_path(&text, buzz_face, font_size, None), false)
crate::vector::VectorData::from_subpaths(to_path(&text, buzz_face, font_size, line_height_ratio, character_spacing, None), false)
}