summaryrefslogtreecommitdiff
path: root/src/layout/text.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-10-16 22:32:40 +0200
committerLaurenz <laurmaedje@gmail.com>2019-10-16 22:32:40 +0200
commite87a34a4d0bf967427e2443f9f48026d09ccd5db (patch)
treed1163980613526f9b211c710a9bb52b2893f0839 /src/layout/text.rs
parent58693486f97ddbb34595efa1a81a4e7b1d3204c9 (diff)
Rearrange layouting contexts ♻
Diffstat (limited to 'src/layout/text.rs')
-rw-r--r--src/layout/text.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/layout/text.rs b/src/layout/text.rs
index 3a064df4..79ace040 100644
--- a/src/layout/text.rs
+++ b/src/layout/text.rs
@@ -5,14 +5,24 @@ use super::*;
use crate::size::{Size, Size2D};
/// The context for text layouting.
+///
+/// See [`LayoutContext`] for details about the fields.
#[derive(Copy, Clone)]
pub struct TextContext<'a, 'p> {
- /// Loads fonts matching queries.
pub loader: &'a SharedFontLoader<'p>,
- /// Base style to set text with.
pub style: &'a TextStyle,
}
+impl<'a, 'p> TextContext<'a, 'p> {
+ /// Create a text context from a generic layout context.
+ pub fn from_layout_ctx(ctx: LayoutContext<'a, 'p>) -> TextContext<'a, 'p> {
+ TextContext {
+ loader: ctx.loader,
+ style: ctx.style,
+ }
+ }
+}
+
/// Layouts text into a box.
///
/// There is no complex layout involved. The text is simply laid out left-