mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-31 22:06:49 -06:00
Convert text decoration colour in colour profile conversion (#1247)
Found while testing crates/doc/src/colors.rs:30 (TextStyle::for_each_color_mut, used by TextData, Style and Document::map_colors / set_color_profile) Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
43a255fe16
commit
3a1ddf339c
@@ -35,6 +35,9 @@ impl Effect {
|
||||
impl TextStyle {
|
||||
pub fn for_each_color_mut(&mut self, f: &mut ColorVisitor) {
|
||||
self.fills.iter_mut().flatten().for_each(|p| p.for_each_color_mut(f));
|
||||
if let Some(c) = self.decoration_look.as_deref_mut().and_then(|l| l.color.as_mut()) {
|
||||
f(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,3 +134,11 @@ fn profile_and_presets_serialize_only_when_set() {
|
||||
assert_eq!(back.color_profile, ColorProfile::DisplayP3);
|
||||
assert_eq!(back.image_presets, d.image_presets);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_decoration_colour_is_visited() {
|
||||
let mut s = TextStyle::default();
|
||||
s.set_look(|l| l.color = Some(RED));
|
||||
s.for_each_color_mut(&mut |c| *c = Color::BLACK);
|
||||
assert_eq!(s.look().color, Some(Color::BLACK), "decoration colour not visited");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user