diff --git a/canvas/Cargo.toml b/canvas/Cargo.toml index b247fcd6b..d7272e5b4 100644 --- a/canvas/Cargo.toml +++ b/canvas/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["pathfinder", "canvas", "vector", "graphics", "gpu"] crate-type = ["rlib", "staticlib"] [dependencies] -font-kit = { version = "0.6", optional = true } +font-kit = { version = "0.10", optional = true } [dependencies.pathfinder_color] path = "../color" diff --git a/canvas/src/lib.rs b/canvas/src/lib.rs index 46791dab3..a1a4b84a2 100644 --- a/canvas/src/lib.rs +++ b/canvas/src/lib.rs @@ -164,6 +164,11 @@ impl CanvasRenderingContext2D { } // Extensions + pub fn reset(&mut self) { + self.saved_states = vec![]; + self.current_state.reset(); + self.clear(); + } /// Clears the current canvas. pub fn clear(&mut self) { @@ -679,6 +684,10 @@ impl State { } } + fn reset(&mut self) { + *self = State::default(self.font_collection.clone()); + } + fn resolve_paint<'a>(&self, paint: &'a Paint) -> Cow<'a, Paint> { let mut must_copy = !self.transform.is_identity() || self.global_alpha < 1.0; if !must_copy { diff --git a/examples/canvas_text/Cargo.toml b/examples/canvas_text/Cargo.toml index dad3dbec8..6b551c772 100644 --- a/examples/canvas_text/Cargo.toml +++ b/examples/canvas_text/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Patrick Walton "] edition = "2018" [dependencies] -font-kit = "0.6" +font-kit = "0.10" gl = "0.14" sdl2 = "0.33" sdl2-sys = "0.33" diff --git a/text/Cargo.toml b/text/Cargo.toml index adcdfb842..8d97d3689 100644 --- a/text/Cargo.toml +++ b/text/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/servo/pathfinder" homepage = "https://github.com/servo/pathfinder" [dependencies] -font-kit = "0.6" +font-kit = "0.10" [dependencies.pathfinder_content] path = "../content"