diff --git a/CHANGELOG.md b/CHANGELOG.md index 3617eb47..e41a60d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ * Rework patch visualizer with many fixes and improvements ([#726]) * Added support for syncing in `.toml` files ([#633]) * Add `plugin` flag to the `build` command that outputs to the local plugins folder ([#735]) +* Added better support for `Font` properties ([#731]) [#668]: https://github.com/rojo-rbx/rojo/pull/668 [#674]: https://github.com/rojo-rbx/rojo/pull/674 @@ -36,6 +37,7 @@ [#726]: https://github.com/rojo-rbx/rojo/pull/726 [#633]: https://github.com/rojo-rbx/rojo/pull/633 [#735]: https://github.com/rojo-rbx/rojo/pull/735 +[#731]: https://github.com/rojo-rbx/rojo/pull/731 ## [7.3.0] - April 22, 2023 * Added `$attributes` to project format. ([#574]) diff --git a/src/resolution.rs b/src/resolution.rs index 56889145..c667080c 100644 --- a/src/resolution.rs +++ b/src/resolution.rs @@ -2,7 +2,7 @@ use std::borrow::Borrow; use anyhow::{bail, format_err}; use rbx_dom_weak::types::{ - Attributes, CFrame, Color3, Content, Enum, Matrix3, Tags, Variant, VariantType, Vector2, + Attributes, CFrame, Color3, Content, Enum, Font, Matrix3, Tags, Variant, VariantType, Vector2, Vector3, }; use rbx_reflection::{DataType, PropertyDescriptor}; @@ -49,6 +49,7 @@ pub enum AmbiguousValue { Array4([f64; 4]), Array12([f64; 12]), Attributes(Attributes), + Font(Font), } impl AmbiguousValue { @@ -139,6 +140,8 @@ impl AmbiguousValue { (VariantType::Attributes, AmbiguousValue::Attributes(value)) => Ok(value.into()), + (VariantType::Font, AmbiguousValue::Font(value)) => Ok(value.into()), + (_, unresolved) => Err(format_err!( "Wrong type of value for property {}.{}. Expected {:?}, got {}", class_name, @@ -176,6 +179,7 @@ impl AmbiguousValue { AmbiguousValue::Array4(_) => "an array of four numbers", AmbiguousValue::Array12(_) => "an array of twelve numbers", AmbiguousValue::Attributes(_) => "an object containing attributes", + AmbiguousValue::Font(_) => "an object describing a Font", } } } @@ -328,4 +332,23 @@ mod test { Variant::Enum(Enum::from_u32(1)), ); } + + #[test] + fn font() { + use rbx_dom_weak::types::{FontStyle, FontWeight}; + + assert_eq!( + resolve( + "TextLabel", + "FontFace", + r#"{"family": "rbxasset://fonts/families/RobotoMono.json", "weight": "Thin", "style": "Normal"}"# + ), + Variant::Font(Font { + family: "rbxasset://fonts/families/RobotoMono.json".into(), + weight: FontWeight::Thin, + style: FontStyle::Normal, + cached_face_id: None, + }) + ) + } }