Preserve cached font id in Font roblox datatype

This commit is contained in:
Filip Tibell 2023-03-18 09:01:31 +01:00
parent 6a797945d5
commit bd12b03e0c
No known key found for this signature in database

View file

@ -15,9 +15,10 @@ use super::{super::*, EnumItem};
*/
#[derive(Debug, Clone, PartialEq)]
pub struct Font {
family: String,
weight: FontWeight,
style: FontStyle,
pub(crate) family: String,
pub(crate) weight: FontWeight,
pub(crate) style: FontStyle,
pub(crate) cached_id: Option<String>,
}
impl Font {
@ -30,6 +31,7 @@ impl Font {
family: props.0.to_string(),
weight: props.1,
style: props.2,
cached_id: None,
})
}
@ -42,6 +44,7 @@ impl Font {
family,
weight: weight.unwrap_or_default(),
style: style.unwrap_or_default(),
cached_id: None,
})
},
)?,
@ -73,6 +76,7 @@ impl Font {
family: format!("rbxasset://fonts/families/{}.json", file),
weight: weight.unwrap_or_default(),
style: style.unwrap_or_default(),
cached_id: None,
})
},
)?,
@ -85,6 +89,7 @@ impl Font {
family: format!("rbxassetid://{}", id),
weight: weight.unwrap_or_default(),
style: style.unwrap_or_default(),
cached_id: None,
})
},
)?,
@ -136,6 +141,7 @@ impl From<RbxFont> for Font {
family: v.family,
weight: v.weight.into(),
style: v.style.into(),
cached_id: v.cached_face_id,
}
}
}
@ -146,7 +152,7 @@ impl From<Font> for RbxFont {
family: v.family,
weight: v.weight.into(),
style: v.style.into(),
cached_face_id: None,
cached_face_id: v.cached_id,
}
}
}