Move the downstream-typed attribute markers to their value types' crates

This commit is contained in:
Dennis Kobert
2026-08-22 09:34:17 +00:00
parent 49c592013c
commit a8d257e7d6
17 changed files with 132 additions and 39 deletions

View File

@@ -1,6 +1,7 @@
pub mod fallback;
mod font;
pub mod json;
pub mod markers;
mod path_builder;
pub mod regex;
mod text_context;
@@ -20,6 +21,7 @@ use unicode_segmentation::UnicodeSegmentation;
pub use core_types as gcore;
pub use fallback::FALLBACK_FONT_RESOURCE;
pub use font::*;
pub use markers::{ATTR_FONT, ATTR_TEXT_ALIGN};
pub use text_context::{TextContext, for_each_styled_glyph_run};
pub use to_path::*;
pub use vector_types;

View File

@@ -0,0 +1,32 @@
//! Attribute markers whose value types live in this crate, with their name
//! constants for the string-keyed legacy readers and writers.
use core_types::attribute::Attribute;
core_types::attribute! {
/// Text item's font, as a resource of the loaded font file.
pub Font("font"): &graphene_resource::Resource;
/// Text item's horizontal alignment of lines within the block.
pub TextAlign("text_align"): crate::TextAlign;
}
pub const ATTR_FONT: &str = Font::NAME;
pub const ATTR_TEXT_ALIGN: &str = TextAlign::NAME;
#[cfg(test)]
mod tests {
use super::*;
use core_types::attribute::info;
use std::any::TypeId;
#[test]
fn the_census_carries_this_crates_names() {
assert_eq!(info("font").unwrap().value_type, TypeId::of::<&'static graphene_resource::Resource>());
assert_eq!(info("text_align").unwrap().value_type, TypeId::of::<crate::TextAlign>());
}
#[test]
fn the_font_default_is_the_empty_resource() {
assert!(<Font as Attribute>::default().is_empty());
}
}

View File

@@ -1,5 +1,5 @@
use core_types::list::{Item, List};
use core_types::{ATTR_EDITOR_CLICK_TARGET, ATTR_EDITOR_TEXT_FRAME, ATTR_TRANSFORM};
use core_types::{ATTR_EDITOR_TEXT_FRAME, ATTR_TRANSFORM};
use glam::{DAffine2, DVec2};
use parley::GlyphRun;
use skrifa::GlyphId;
@@ -7,6 +7,7 @@ use skrifa::instance::{LocationRef, NormalizedCoord, Size};
use skrifa::outline::{DrawSettings, OutlinePen};
use skrifa::raw::FontRef as ReadFontsRef;
use skrifa::{MetadataProvider, OutlineGlyph};
use vector_types::ATTR_EDITOR_CLICK_TARGET;
use vector_types::subpath::{ManipulatorGroup, Subpath};
use vector_types::vector::{PointId, Vector};

View File

@@ -3,9 +3,9 @@ use super::text_context::TextContext;
use core_types::blending::BlendMode;
use core_types::list::List;
use core_types::uuid::NodeId;
use crate::markers::{ATTR_FONT, ATTR_TEXT_ALIGN};
use core_types::{
ATTR_BLEND_MODE, ATTR_EDITOR_LAYER_PATH, ATTR_FONT, ATTR_FONT_SIZE, ATTR_LETTER_SPACING, ATTR_LETTER_TILT, ATTR_LINE_HEIGHT, ATTR_MAX_HEIGHT, ATTR_MAX_WIDTH, ATTR_OPACITY, ATTR_OPACITY_FILL,
ATTR_TEXT_ALIGN, ATTR_TRANSFORM,
ATTR_BLEND_MODE, ATTR_EDITOR_LAYER_PATH, ATTR_FONT_SIZE, ATTR_LETTER_SPACING, ATTR_LETTER_TILT, ATTR_LINE_HEIGHT, ATTR_MAX_HEIGHT, ATTR_MAX_WIDTH, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_TRANSFORM,
};
use glam::{DAffine2, DVec2};
use graphene_resource::Resource;