Introduce RawText to Primitive in iced_graphics
This should allow users to directly render a `cosmic_text::Buffer`.
This commit is contained in:
parent
fc285d3e46
commit
603832e66c
8 changed files with 131 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue