aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/canvas
diff options
context:
space:
mode:
authorChocolate Pie <106949016+chocolate-pie@users.noreply.github.com>2024-07-18 04:20:18 +0900
committerGitHub <noreply@github.com>2024-07-17 19:20:18 +0000
commit122333554768d69789a08df25c0bcde3ddd1aa4c (patch)
tree7fc6eeead1345171f7d62f39ae8cd2f36695ff44 /components/shared/canvas
parentd82232d549a880aaa1b5613e22ca4f7ec9593d74 (diff)
downloadservo-122333554768d69789a08df25c0bcde3ddd1aa4c.tar.gz
servo-122333554768d69789a08df25c0bcde3ddd1aa4c.zip
enhance: Implement `CanvasRenderingContext2D.measureText` (#32704)
Signed-off-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/shared/canvas')
-rw-r--r--components/shared/canvas/canvas.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/components/shared/canvas/canvas.rs b/components/shared/canvas/canvas.rs
index 43d21fd58fe..d1f59ebea3b 100644
--- a/components/shared/canvas/canvas.rs
+++ b/components/shared/canvas/canvas.rs
@@ -58,6 +58,7 @@ pub enum Canvas2dMsg {
IsPointInPath(f64, f64, FillRule, IpcSender<bool>),
LineTo(Point2D<f32>),
MoveTo(Point2D<f32>),
+ MeasureText(String, IpcSender<TextMetrics>),
PutImageData(Rect<u64>, IpcBytesReceiver),
QuadraticCurveTo(Point2D<f32>, Point2D<f32>),
Rect(Rect<f32>),
@@ -474,3 +475,19 @@ impl FromStr for Direction {
}
}
}
+
+#[derive(Clone, Debug, Default, Deserialize, MallocSizeOf, Serialize)]
+pub struct TextMetrics {
+ pub width: f32,
+ pub actual_boundingbox_left: f32,
+ pub actual_boundingbox_right: f32,
+ pub actual_boundingbox_ascent: f32,
+ pub actual_boundingbox_descent: f32,
+ pub font_boundingbox_ascent: f32,
+ pub font_boundingbox_descent: f32,
+ pub em_height_ascent: f32,
+ pub em_height_descent: f32,
+ pub hanging_baseline: f32,
+ pub alphabetic_baseline: f32,
+ pub ideographic_baseline: f32,
+}