🎉 Store custom fonts (ttfs) and use them to write texts (wasm) (#6050)

This commit is contained in:
Belén Albeza 2025-03-14 12:45:15 +01:00 committed by GitHub
parent e4c9b736f7
commit eb6d2fb0eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 386 additions and 140 deletions

View file

@ -9,6 +9,7 @@ mod blurs;
mod bools;
mod corners;
mod fills;
mod fonts;
mod frames;
mod groups;
mod layouts;
@ -25,6 +26,7 @@ pub use blurs::*;
pub use bools::*;
pub use corners::*;
pub use fills::*;
pub use fonts::*;
pub use frames::*;
pub use groups::*;
pub use layouts::*;
@ -588,10 +590,15 @@ impl Shape {
}
}
pub fn add_text_leaf(&mut self, text_str: &str) -> Result<(), String> {
pub fn add_text_leaf(
&mut self,
text_str: String,
font_family: FontFamily,
font_size: f32,
) -> Result<(), String> {
match self.shape_type {
Type::Text(ref mut text) => {
text.add_leaf(text_str)?;
text.add_leaf(text_str, font_family, font_size)?;
Ok(())
}
_ => Err("Shape is not a text".to_string()),