Skip to content

Commit acde7ea

Browse files
committed
Implement Frame::stroke_text in canvas API
1 parent 8f3bca2 commit acde7ea

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

graphics/src/geometry/frame.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ pub trait Backend: Sized {
217217
size: Size,
218218
stroke: impl Into<Stroke<'a>>,
219219
);
220+
fn stroke_text<'a>(
221+
&mut self,
222+
text: impl Into<Text>,
223+
stroke: impl Into<Stroke<'a>>,
224+
);
220225

221226
fn fill(&mut self, path: &Path, fill: impl Into<Fill>);
222227
fn fill_text(&mut self, text: impl Into<Text>);
@@ -272,6 +277,12 @@ impl Backend for () {
272277
_stroke: impl Into<Stroke<'a>>,
273278
) {
274279
}
280+
fn stroke_text<'a>(
281+
&mut self,
282+
_text: impl Into<Text>,
283+
_stroke: impl Into<Stroke<'a>>,
284+
) {
285+
}
275286

276287
fn fill(&mut self, _path: &Path, _fill: impl Into<Fill>) {}
277288
fn fill_text(&mut self, _text: impl Into<Text>) {}

renderer/src/fallback.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,14 @@ mod geometry {
537537
);
538538
}
539539

540+
fn stroke_text<'a>(
541+
&mut self,
542+
text: impl Into<Text>,
543+
stroke: impl Into<Stroke<'a>>,
544+
) {
545+
delegate!(self, frame, frame.stroke_text(text, stroke));
546+
}
547+
540548
fn fill_text(&mut self, text: impl Into<Text>) {
541549
delegate!(self, frame, frame.fill_text(text));
542550
}

tiny_skia/src/geometry.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ impl geometry::frame::Backend for Frame {
245245
}
246246
}
247247

248+
fn stroke_text<'a>(
249+
&mut self,
250+
text: impl Into<geometry::Text>,
251+
stroke: impl Into<Stroke<'a>>,
252+
) {
253+
let text = text.into();
254+
let stroke = stroke.into();
255+
256+
text.draw_with(|path, _color| self.stroke(&path, stroke));
257+
}
258+
248259
fn push_transform(&mut self) {
249260
self.stack.push(self.transform);
250261
}

wgpu/src/geometry.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,17 @@ impl geometry::frame::Backend for Frame {
291291
.expect("Stroke rectangle");
292292
}
293293

294+
fn stroke_text<'a>(
295+
&mut self,
296+
text: impl Into<geometry::Text>,
297+
stroke: impl Into<Stroke<'a>>,
298+
) {
299+
let text = text.into();
300+
let stroke = stroke.into();
301+
302+
text.draw_with(|glyph, _color| self.stroke(&glyph, stroke));
303+
}
304+
294305
fn fill_text(&mut self, text: impl Into<geometry::Text>) {
295306
let text = text.into();
296307

0 commit comments

Comments
 (0)