summaryrefslogtreecommitdiff
path: root/library/src/layout/measure.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-07-02 19:59:52 +0200
committerLaurenz <laurmaedje@gmail.com>2023-07-02 20:07:43 +0200
commitebfdb1dafa430786db10dad2ef7d5467c1bdbed1 (patch)
tree2bbc24ddb4124c4bb14dec0e536129d4de37b056 /library/src/layout/measure.rs
parent3ab19185093d7709f824b95b979060ce125389d8 (diff)
Move everything into `crates/` directory
Diffstat (limited to 'library/src/layout/measure.rs')
-rw-r--r--library/src/layout/measure.rs56
1 files changed, 0 insertions, 56 deletions
diff --git a/library/src/layout/measure.rs b/library/src/layout/measure.rs
deleted file mode 100644
index eb8e509e..00000000
--- a/library/src/layout/measure.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-use crate::prelude::*;
-
-/// Measures the layouted size of content.
-///
-/// The `measure` function lets you determine the layouted size of content.
-/// Note that an infinite space is assumed, therefore the measured height/width
-/// may not necessarily match the final height/width of the measured content.
-/// If you want to measure in the current layout dimensions, you can combined
-/// `measure` and [`layout`]($func/layout).
-///
-/// # Example { #example }
-/// The same content can have a different size depending on the styles that
-/// are active when it is layouted. For example, in the example below
-/// `[#content]` is of course bigger when we increase the font size.
-///
-/// ```example
-/// #let content = [Hello!]
-/// #content
-/// #set text(14pt)
-/// #content
-/// ```
-///
-/// To do a meaningful measurement, you therefore first need to retrieve the
-/// active styles with the [`style`]($func/style) function. You can then pass
-/// them to the `measure` function.
-///
-/// ```example
-/// #let thing(body) = style(styles => {
-/// let size = measure(body, styles)
-/// [Width of "#body" is #size.width]
-/// })
-///
-/// #thing[Hey] \
-/// #thing[Welcome]
-/// ```
-///
-/// The measure function returns a dictionary with the entries `width` and
-/// `height`, both of type [`length`]($type/length).
-///
-/// Display: Measure
-/// Category: layout
-#[func]
-pub fn measure(
- /// The content whose size to measure.
- content: Content,
- /// The styles with which to layout the content.
- styles: Styles,
- /// The virtual machine.
- vm: &mut Vm,
-) -> SourceResult<Dict> {
- let pod = Regions::one(Axes::splat(Abs::inf()), Axes::splat(false));
- let styles = StyleChain::new(&styles);
- let frame = content.measure(&mut vm.vt, styles, pod)?.into_frame();
- let Size { x, y } = frame.size();
- Ok(dict! { "width" => x, "height" => y })
-}