diff options
| author | 2023-09-19 22:28:28 +0200 | |
|---|---|---|
| committer | 2023-09-19 22:28:28 +0200 | |
| commit | 9af0a27e675b71164f32f8d82eb4cde9cdd459f3 (patch) | |
| tree | 395743af28922900d8d0cb6b5f71be61880990fd /tiny_skia/src | |
| parent | a9ee8f62fdd0f74976947c21199684829aa8a496 (diff) | |
| download | iced-9af0a27e675b71164f32f8d82eb4cde9cdd459f3.tar.gz iced-9af0a27e675b71164f32f8d82eb4cde9cdd459f3.tar.bz2 iced-9af0a27e675b71164f32f8d82eb4cde9cdd459f3.zip | |
Draw colored glyphs in `iced_tiny_skia`
Diffstat (limited to '')
| -rw-r--r-- | tiny_skia/src/text.rs | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs index 96cfbf32..d1b33293 100644 --- a/tiny_skia/src/text.rs +++ b/tiny_skia/src/text.rs @@ -188,7 +188,7 @@ fn draw(              if let Some((buffer, placement)) = glyph_cache.allocate(                  physical_glyph.cache_key, -                color, +                glyph.color_opt.map(from_color).unwrap_or(color),                  font_system,                  &mut swash,              ) { @@ -213,6 +213,12 @@ fn draw(      }  } +fn from_color(color: cosmic_text::Color) -> Color { +    let [r, g, b, a] = color.as_rgba(); + +    Color::from_rgba8(r, g, b, a as f32 / 255.0) +} +  #[derive(Debug, Clone, Default)]  struct GlyphCache {      entries: FxHashMap< | 
