add CanvasRenderingContext2D::fill_layout – a method to draw layouts directly, without using skribo
This commit is contained in:
parent
0012f09eeb
commit
2a129b7bbd
|
@ -102,6 +102,16 @@ impl CanvasRenderingContext2D {
|
|||
TextMetrics { width: self.layout_text(string).width() }
|
||||
}
|
||||
|
||||
pub fn fill_layout(&mut self, layout: &Layout, transform: Transform2DF) {
|
||||
let paint_id = self.scene.push_paint(&self.current_state.fill_paint);
|
||||
drop(self.scene.push_layout(&layout,
|
||||
&TextStyle { size: self.current_state.font_size },
|
||||
&transform.post_mul(&self.current_state.transform),
|
||||
TextRenderMode::Fill,
|
||||
HintingOptions::None,
|
||||
paint_id));
|
||||
}
|
||||
|
||||
fn fill_or_stroke_text(&mut self,
|
||||
string: &str,
|
||||
mut position: Vector2F,
|
||||
|
@ -127,7 +137,7 @@ impl CanvasRenderingContext2D {
|
|||
paint_id));
|
||||
}
|
||||
|
||||
fn layout_text(&self, string: &str) -> Layout {
|
||||
pub fn layout_text(&self, string: &str) -> Layout {
|
||||
skribo::layout(&TextStyle { size: self.current_state.font_size },
|
||||
&self.current_state.font_collection,
|
||||
string)
|
||||
|
|
Loading…
Reference in New Issue