From bd12b03e0c2391327f3562b2c54c4473bd649cc5 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Sat, 18 Mar 2023 09:01:31 +0100 Subject: [PATCH] Preserve cached font id in Font roblox datatype --- packages/lib-roblox/src/datatypes/types/font.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/lib-roblox/src/datatypes/types/font.rs b/packages/lib-roblox/src/datatypes/types/font.rs index 07d8e99..651bc9d 100644 --- a/packages/lib-roblox/src/datatypes/types/font.rs +++ b/packages/lib-roblox/src/datatypes/types/font.rs @@ -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, } 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 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 for RbxFont { family: v.family, weight: v.weight.into(), style: v.style.into(), - cached_face_id: None, + cached_face_id: v.cached_id, } } }