diff --git a/crates/typst-library/src/foundations/content.rs b/crates/typst-library/src/foundations/content.rs index 0d17b4578..e10ef7bb6 100644 --- a/crates/typst-library/src/foundations/content.rs +++ b/crates/typst-library/src/foundations/content.rs @@ -15,9 +15,9 @@ use typst_utils::{fat, singleton, LazyHash, SmallBitSet}; use crate::diag::{SourceResult, StrResult}; use crate::engine::Engine; use crate::foundations::{ - elem, func, scope, ty, Context, Dict, Element, Fields, IntoValue, Label, - NativeElement, Recipe, RecipeIndex, Repr, Selector, Str, Style, StyleChain, Styles, - Value, + elem, func, repr, scope, ty, Context, Dict, Element, Field, IntoValue, Label, + NativeElement, Property, Recipe, RecipeIndex, Repr, Selector, SettableProperty, Str, + Style, StyleChain, Styles, Value, }; use crate::introspection::Location; use crate::layout::{AlignElem, Alignment, Axes, Length, MoveElem, PadElem, Rel, Sides}; @@ -372,6 +372,15 @@ impl Content { Self::sequence(std::iter::repeat_with(|| self.clone()).take(count)) } + /// Sets a style property on the content. + pub fn set(self, field: Field, value: E::Type) -> Self + where + E: SettableProperty, + E::Type: Debug + Clone + Hash + Send + Sync + 'static, + { + self.styled(Property::new(field, value)) + } + /// Style this content with a style entry. pub fn styled(mut self, style: impl Into