mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
* Instances -> Table * instances.rs -> table.rs * Rename occurrances of the word "instances" * .instance -> .element * Instance* -> TableRow* * Rename Table and TableRow methods to not say "instance" * Remove presumed unused serde defaults now that tables default to length 0 not 1 * Rename occurences of the word "instance" * Un-alias the RasterDataTable<Storage>, VectorDataTable, GraphicGroupTable, ArtboardGroupTable typedefs * Move artboard type and node code out of graphic_element.rs to a new artboard.rs * Organize the TaggedValues * Fix tests * Fix prior regression with Image Value node not upgrading
49 lines
1.0 KiB
Rust
49 lines
1.0 KiB
Rust
use graph_craft::wasm_application_io::WasmEditorApi;
|
|
pub use graphene_core::text::*;
|
|
use graphene_core::{Ctx, table::Table, vector::VectorData};
|
|
|
|
#[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")]
|
|
#[default(None)]
|
|
max_width: Option<f64>,
|
|
#[unit(" px")]
|
|
#[default(None)]
|
|
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 data.
|
|
#[default(false)]
|
|
per_glyph_instances: bool,
|
|
) -> Table<VectorData> {
|
|
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)
|
|
}
|