mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
* Restructure node-graph folder * Fix wasm compilation * Move node definitions out of *-types crates * Cleanup * Fix warnings * Fix warnings * Start adding migrations * Add migrations and move memo nodes to gcore * Move nodes/gsvg-render -> rendering * Replace some hard coded identifiers and fix automatic conversion * Fix Vec2Value node migration * Fix formatting * Add more migrations * Cleanup features * Fix core_types::raster import * Update demo artwork (to make profile ci work) * Move *-types to node-graph/libraries folder * Add missing node migrations * Migrate more nodes * Remove impure memo node * More fixes and remove warning * Migrate context and add a few missing migrations --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
43 lines
964 B
Rust
43 lines
964 B
Rust
use core_types::{Ctx, table::Table};
|
|
use graph_craft::wasm_application_io::WasmEditorApi;
|
|
use graphic_types::Vector;
|
|
pub use text_nodes::*;
|
|
|
|
#[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,
|
|
};
|
|
|
|
to_path(&text, &font_name, &editor.font_cache, typesetting, per_glyph_instances)
|
|
}
|