summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-01-12 06:45:40 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-12 06:45:40 +0100
commita5ae442819227b3cd55116028e6d6c96caa6fda9 (patch)
tree111e7b424a2c7044f8d98612015540282bf2ca8a /tiny_skia/src/text.rs
parent89fc4f54bdbf62a29fcd06bc2e77926180143413 (diff)
parent603832e66c710ea39a95009ddc905de20c6856bd (diff)
downloadiced-a5ae442819227b3cd55116028e6d6c96caa6fda9.tar.gz
iced-a5ae442819227b3cd55116028e6d6c96caa6fda9.tar.bz2
iced-a5ae442819227b3cd55116028e6d6c96caa6fda9.zip
Merge pull request #2158 from iced-rs/feature/raw-text-primitive
Introduce `RawText` to `Primitive` in `iced_graphics`
Diffstat (limited to 'tiny_skia/src/text.rs')
-rw-r--r--tiny_skia/src/text.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs
index 70e95d01..a5a0a1b6 100644
--- a/tiny_skia/src/text.rs
+++ b/tiny_skia/src/text.rs
@@ -1,6 +1,6 @@
use crate::core::alignment;
use crate::core::text::{LineHeight, Shaping};
-use crate::core::{Color, Font, Pixels, Point, Rectangle};
+use crate::core::{Color, Font, Pixels, Point, Rectangle, Size};
use crate::graphics::color;
use crate::graphics::text::cache::{self, Cache};
use crate::graphics::text::editor;
@@ -149,6 +149,33 @@ impl Pipeline {
);
}
+ pub fn draw_raw(
+ &mut self,
+ buffer: &cosmic_text::Buffer,
+ position: Point,
+ color: Color,
+ scale_factor: f32,
+ pixels: &mut tiny_skia::PixmapMut<'_>,
+ clip_mask: Option<&tiny_skia::Mask>,
+ ) {
+ let mut font_system = font_system().write().expect("Write font system");
+
+ let (width, height) = buffer.size();
+
+ draw(
+ font_system.raw(),
+ &mut self.glyph_cache,
+ buffer,
+ Rectangle::new(position, Size::new(width, height)),
+ color,
+ alignment::Horizontal::Left,
+ alignment::Vertical::Top,
+ scale_factor,
+ pixels,
+ clip_mask,
+ );
+ }
+
pub fn trim_cache(&mut self) {
self.cache.get_mut().trim();
self.glyph_cache.trim();