summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/doc.rs b/src/doc.rs
index 9e98ec88..d4ad2d93 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -7,7 +7,8 @@ use std::sync::Arc;
use crate::font::Font;
use crate::geom::{
- Abs, Align, Axes, Dir, Em, Numeric, Paint, Point, Shape, Size, Transform,
+ self, Abs, Align, Axes, Color, Dir, Em, Geometry, Numeric, Paint, Point, RgbaColor,
+ Shape, Size, Stroke, Transform,
};
use crate::image::Image;
use crate::model::{
@@ -160,7 +161,7 @@ impl Frame {
self.size.y
}
- /// The baseline of the frame.
+ /// The vertical position of the frame's baseline.
pub fn baseline(&self) -> Abs {
self.baseline.unwrap_or(self.size.y)
}
@@ -170,6 +171,19 @@ impl Frame {
self.baseline = Some(baseline);
}
+ /// The distance from the baseline to the top of the frame.
+ ///
+ /// This is the same as `baseline()`, but more in line with the terminology
+ /// used in math layout.
+ pub fn ascent(&self) -> Abs {
+ self.baseline()
+ }
+
+ /// The distance from the baseline to the bottom of the frame.
+ pub fn descent(&self) -> Abs {
+ self.size.y - self.baseline()
+ }
+
/// An iterator over the elements inside this frame alongside their
/// positions relative to the top-left of the frame.
pub fn elements(&self) -> std::slice::Iter<'_, (Point, Element)> {