Resolve fill and stroke paints when filling and stroking text.

Makes text respect global alpha.
This commit is contained in:
Patrick Walton 2020-04-14 10:08:11 -07:00
parent 667a6c7c43
commit b9b1472b6c
1 changed files with 4 additions and 2 deletions

View File

@ -27,12 +27,14 @@ use std::sync::Arc;
impl CanvasRenderingContext2D {
pub fn fill_text(&mut self, string: &str, position: Vector2F) {
let paint_id = self.canvas.scene.push_paint(&self.current_state.fill_paint);
let paint = self.current_state.resolve_paint(&self.current_state.fill_paint);
let paint_id = self.canvas.scene.push_paint(&paint);
self.fill_or_stroke_text(string, position, paint_id, TextRenderMode::Fill);
}
pub fn stroke_text(&mut self, string: &str, position: Vector2F) {
let paint_id = self.canvas.scene.push_paint(&self.current_state.stroke_paint);
let paint = self.current_state.resolve_paint(&self.current_state.stroke_paint);
let paint_id = self.canvas.scene.push_paint(&paint);
let render_mode = TextRenderMode::Stroke(self.current_state.resolve_stroke_style());
self.fill_or_stroke_text(string, position, paint_id, render_mode);
}