Separate the Text node's generated glyphs into separate vector table rows (#2821)

* Separate glyphs into Vector data rows

* Fix `String Length` node

- Properly count characters with
`str.chars().count()` instead of bytes `str.len()`
- Change `String Length` node's output to `u32`

* Apply transform on instance instead of applying it when drawing the glyph

* Add checkbox to enable/disable per-glyph instances

* Tooltips

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Salman Abuhaimed
2025-07-14 04:06:41 +03:00
committed by GitHub
parent c5800aa96e
commit 166eb00c9c
6 changed files with 62 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
use crate::vector::{VectorData, VectorDataTable};
use crate::vector::VectorDataTable;
use graph_craft::wasm_application_io::WasmEditorApi;
use graphene_core::Ctx;
pub use graphene_core::text::*;
@@ -24,9 +24,13 @@ fn text<'i: 'n>(
#[unit(" px")]
#[default(None)]
max_height: Option<f64>,
/// Faux italic.
#[unit("°")]
#[default(0.)]
tilt: f64,
/// Splits each text glyph into its own instance, i.e. row in the table of vector data.
#[default(false)]
per_glyph_instances: bool,
) -> VectorDataTable {
let typesetting = TypesettingConfig {
font_size,
@@ -39,7 +43,5 @@ fn text<'i: 'n>(
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)
to_path(&text, font_data, typesetting, per_glyph_instances)
}