Files
Graphite/node-graph/gstd/src/text.rs
Firestar99 95ef8a5343 Change Table<Color> node inputs to Color where only one value is used so GPU nodes work (#3096)
* graster-nodes: change `Table<Color>` params to `Color` where only one value is used

* Re-add support for Color and Option<Color>

* Add warning when a default value isn't parsed

---------

Co-authored-by: hypercube <0hypercube@gmail.com>
2025-08-28 15:16:56 +02:00

45 lines
1019 B
Rust

use graph_craft::wasm_application_io::WasmEditorApi;
pub use graphene_core::text::*;
use graphene_core::{Ctx, table::Table, vector::Vector};
#[node_macro::node(category(""))]
fn text<'i: 'n>(
_: impl Ctx,
editor: &'i WasmEditorApi,
text: String,
font_name: Font,
#[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")] max_width: Option<f64>,
#[unit(" px")] max_height: Option<f64>,
/// Faux italic.
#[unit("°")]
#[default(0.)]
tilt: f64,
align: TextAlign,
/// Splits each text glyph into its own row in the table of vector geometry.
#[default(false)]
per_glyph_instances: bool,
) -> Table<Vector> {
let typesetting = TypesettingConfig {
font_size,
line_height_ratio,
character_spacing,
max_width,
max_height,
tilt,
align,
};
let font_data = editor.font_cache.get(&font_name).map(|f| load_font(f));
to_path(&text, font_data, typesetting, per_glyph_instances)
}