From f69ff65715245983e8c4104d50ce3f67f714b372 Mon Sep 17 00:00:00 2001 From: John Mitchell <6656977+StarArawn@users.noreply.github.com> Date: Sat, 29 Apr 2023 21:15:14 -0400 Subject: [PATCH] Fixed text color extraction. --- examples/text.rs | 1 + src/render/font/extract.rs | 4 ++-- src/render_primitive.rs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/text.rs b/examples/text.rs index 2571f03..b789465 100644 --- a/examples/text.rs +++ b/examples/text.rs @@ -18,6 +18,7 @@ fn my_widget_1_render( // Note: We will see two updates because of the mutable change to styles. // Which means when foo changes MyWidget will render twice! *computed_styles = KStyle { + color: Color::RED.into(), render_command: StyleProp::Value(RenderCommand::Text { content: format!("My number is: {}", my_widget.foo), alignment: Alignment::Start, diff --git a/src/render/font/extract.rs b/src/render/font/extract.rs index 1681451..28dcf3e 100644 --- a/src/render/font/extract.rs +++ b/src/render/font/extract.rs @@ -13,7 +13,7 @@ use super::font_mapping::FontMapping; pub fn extract_texts( camera_entity: Entity, - background_color: Color, + color: Color, text_layout: TextLayout, layout: crate::layout::Rect, font: String, @@ -51,7 +51,7 @@ pub fn extract_texts( min: position, max: position + size, }, - color: background_color, + color, char_id: font.get_char_id(glyph_rect.content).unwrap(), z_index: layout.z_index, quad_type: if subpixel || forced { diff --git a/src/render_primitive.rs b/src/render_primitive.rs index 7b5c0e4..5623b4a 100644 --- a/src/render_primitive.rs +++ b/src/render_primitive.rs @@ -117,9 +117,10 @@ impl RenderPrimitive for KStyle { let font = self .font .resolve_or_else(|| String::from(crate::DEFAULT_FONT)); + let color = self.color.resolve_or(Color::WHITE); let text = crate::render::font::extract_texts( camera_entity, - background_color, + color, text_layout, *layout, font, -- GitLab