Implement native letterspaced fonts and virtual glyph placement

This commit is contained in:
gloamxun committed 2026-11-21 05:48:44 +08:00
1 parent 6675ab639a
commit f66a5a7e20
13 files changed
+337 -35

No files matched your search

+10
View File
@@ -67,6 +67,15 @@ pub struct NativeFont {
/// outline program are the original font at the original point size.
#[serde(default, skip_serializing_if = "unexpanded")]
pub expansion: i32,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub letter_spacing: Option<LetterspaceProgram>,
}
/// Virtual character packets use the selected font and an encoded right move.
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct LetterspaceProgram {
pub base: Arc<NativeFont>,
pub right: i32,
}
pub(crate) fn unexpanded(amount: &i32) -> bool {
*amount == 0
@@ -91,6 +100,7 @@ impl NativeFont {
|| (self.id == other.id
&& self.name == other.name
&& (Arc::ptr_eq(&self.metrics, &other.metrics) || self.metrics == other.metrics)
&& self.letter_spacing == other.letter_spacing
&& self.resource.version == other.resource.version
&& (Arc::ptr_eq(&self.resource.data, &other.resource.data)
|| self.resource.data == other.resource.data))