New Typography type

This commit is contained in:
Adam
2025-09-07 21:16:05 -07:00
parent 485152bf8d
commit 08b25f689e
13 changed files with 356 additions and 71 deletions

View File

@@ -12,6 +12,7 @@ use graphene_std::gradient::GradientStops;
use graphene_std::memo::IORecord;
use graphene_std::raster_types::{CPU, GPU, Raster};
use graphene_std::table::Table;
use graphene_std::text::Typography;
use graphene_std::vector::Vector;
use graphene_std::vector::style::{Fill, FillChoice};
use graphene_std::{Artboard, Graphic};
@@ -266,6 +267,7 @@ impl TableRowLayout for Graphic {
Self::RasterGPU(table) => table.identifier(),
Self::Color(table) => table.identifier(),
Self::Gradient(table) => table.identifier(),
Self::Typography(table) => table.identifier(),
}
}
// Don't put a breadcrumb for Graphic
@@ -280,6 +282,7 @@ impl TableRowLayout for Graphic {
Self::RasterGPU(table) => table.layout_with_breadcrumb(data),
Self::Color(table) => table.layout_with_breadcrumb(data),
Self::Gradient(table) => table.layout_with_breadcrumb(data),
Self::Typography(table) => table.layout_with_breadcrumb(data),
}
}
}
@@ -504,6 +507,21 @@ impl TableRowLayout for GradientStops {
}
}
impl TableRowLayout for Typography {
fn type_name() -> &'static str {
"Typography"
}
fn identifier(&self) -> String {
"Typography".to_string()
}
fn element_widget(&self, _index: usize) -> WidgetHolder {
TextLabel::new("Not supported").widget_holder()
}
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
vec![LayoutGroup::Row { widgets: Vec::new() }]
}
}
impl TableRowLayout for f64 {
fn type_name() -> &'static str {
"Number (f64)"

View File

@@ -9,6 +9,7 @@ use core::borrow::Borrow;
use core::f64::consts::{FRAC_PI_2, PI, TAU};
use glam::{DAffine2, DVec2};
use graphene_std::Color;
use graphene_std::consts::SOURCE_SANS_FONT_DATA;
use graphene_std::math::quad::Quad;
use graphene_std::subpath::{self, Subpath};
use graphene_std::table::Table;
@@ -1021,10 +1022,7 @@ impl OverlayContextInternal {
align: TextAlign::Left,
};
// Load Source Sans Pro font data
// TODO: Grab this from the node_modules folder (either with `include_bytes!` or ideally at runtime) instead of checking the font file into the repo.
// TODO: And maybe use the WOFF2 version (if it's supported) for its smaller, compressed file size.
const FONT_DATA: &[u8] = include_bytes!("source-sans-pro-regular.ttf");
const FONT_DATA: &[u8] = SOURCE_SANS_FONT_DATA;
let font_blob = Some(load_font(FONT_DATA));
// Convert text to paths and calculate actual bounds
@@ -1048,10 +1046,7 @@ impl OverlayContextInternal {
align: TextAlign::Left, // We'll handle alignment manually via pivot
};
// Load Source Sans Pro font data
// TODO: Grab this from the node_modules folder (either with `include_bytes!` or ideally at runtime) instead of checking the font file into the repo.
// TODO: And maybe use the WOFF2 version (if it's supported) for its smaller, compressed file size.
const FONT_DATA: &[u8] = include_bytes!("source-sans-pro-regular.ttf");
const FONT_DATA: &[u8] = SOURCE_SANS_FONT_DATA;
let font_blob = Some(load_font(FONT_DATA));
// Convert text to vector paths using the existing text system