Restructure gcore/text module and fix memory leak (#3221)

* Restructure gcore/text module and fix memory leak

* Remove unused import

* Fix default font fallback causing wrong caching and rename to TextContext

* Upgrade demo art
This commit is contained in:
Dennis Kobert
2025-09-25 15:29:07 +02:00
committed by GitHub
parent d595089bb0
commit 4e47b5db93
14 changed files with 381 additions and 342 deletions

View File

@@ -1,8 +1,11 @@
mod font_cache;
mod path_builder;
mod text_context;
mod to_path;
use dyn_any::DynAny;
pub use font_cache::*;
pub use text_context::TextContext;
pub use to_path::*;
/// Alignment of lines of type within a text block.
@@ -29,3 +32,28 @@ impl From<TextAlign> for parley::Alignment {
}
}
}
#[derive(PartialEq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize)]
pub struct TypesettingConfig {
pub font_size: f64,
pub line_height_ratio: f64,
pub character_spacing: f64,
pub max_width: Option<f64>,
pub max_height: Option<f64>,
pub tilt: f64,
pub align: TextAlign,
}
impl Default for TypesettingConfig {
fn default() -> Self {
Self {
font_size: 24.,
line_height_ratio: 1.2,
character_spacing: 0.,
max_width: None,
max_height: None,
tilt: 0.,
align: TextAlign::default(),
}
}
}