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-13 18:06:41 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent c5800aa96e
commit 166eb00c9c
6 changed files with 62 additions and 30 deletions
@@ -1222,6 +1222,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
NodeInput::value(TaggedValue::OptionalF64(TypesettingConfig::default().max_width), false),
NodeInput::value(TaggedValue::OptionalF64(TypesettingConfig::default().max_height), false),
NodeInput::value(TaggedValue::F64(TypesettingConfig::default().tilt), false),
NodeInput::value(TaggedValue::Bool(false), false),
],
..Default::default()
},
@@ -1281,7 +1282,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
),
InputMetadata::with_name_description_override(
"Tilt",
"Faux italic",
"Faux italic.",
WidgetOverride::Number(NumberInputSettings {
min: Some(-85.),
max: Some(85.),
@@ -1289,6 +1290,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
..Default::default()
}),
),
("Per-Glyph Instances", "Splits each text glyph into its own instance, i.e. row in the table of vector data.").into(),
],
output_names: vec!["Vector".to_string()],
..Default::default()
@@ -635,7 +635,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
}
// Upgrade Text node to include line height and character spacing, which were previously hardcoded to 1, from https://github.com/GraphiteEditor/Graphite/pull/2016
if reference == "Text" && inputs_count != 9 {
if reference == "Text" && inputs_count != 10 {
let mut template = resolve_document_node_type(reference)?.default_node_template();
document.network_interface.replace_implementation(node_id, network_path, &mut template);
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut template)?;
@@ -689,6 +689,15 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
},
network_path,
);
document.network_interface.set_input(
&InputConnector::node(*node_id, 9),
if inputs_count >= 10 {
old_inputs[9].clone()
} else {
NodeInput::value(TaggedValue::Bool(false), false)
},
network_path,
);
}
// Upgrade Sine, Cosine, and Tangent nodes to include a boolean input for whether the output should be in radians, which was previously the only option but is now not the default