summaryrefslogtreecommitdiff
path: root/crates/typst-layout
diff options
context:
space:
mode:
authorMax <me@mkor.je>2024-11-12 12:54:25 +0000
committerGitHub <noreply@github.com>2024-11-12 12:54:25 +0000
commit8d4f01d2847e116c2156f02a869b526859364953 (patch)
treea8b76afbcb2c162437c8f2f053cca0ac2466d9f1 /crates/typst-layout
parentdadc2176e2a71740f0f8afb252229144cc661652 (diff)
Add support for page references through new `ref.form` property (#4729)
Diffstat (limited to 'crates/typst-layout')
-rw-r--r--crates/typst-layout/src/flow/collect.rs2
-rw-r--r--crates/typst-layout/src/flow/compose.rs2
-rw-r--r--crates/typst-layout/src/flow/distribute.rs2
-rw-r--r--crates/typst-layout/src/inline/shaping.rs2
-rw-r--r--crates/typst-layout/src/pages/finalize.rs3
-rw-r--r--crates/typst-layout/src/pages/run.rs8
6 files changed, 13 insertions, 6 deletions
diff --git a/crates/typst-layout/src/flow/collect.rs b/crates/typst-layout/src/flow/collect.rs
index d3974349..49461e80 100644
--- a/crates/typst-layout/src/flow/collect.rs
+++ b/crates/typst-layout/src/flow/collect.rs
@@ -494,7 +494,7 @@ impl MultiSpill<'_, '_> {
engine: &mut Engine,
regions: Regions,
) -> SourceResult<(Frame, Option<Self>)> {
- // The first region becomes unchangable and committed to our backlog.
+ // The first region becomes unchangeable and committed to our backlog.
self.backlog.push(regions.size.y);
// The remaining regions are ephemeral and may be replaced.
diff --git a/crates/typst-layout/src/flow/compose.rs b/crates/typst-layout/src/flow/compose.rs
index d49c3fc3..343b4783 100644
--- a/crates/typst-layout/src/flow/compose.rs
+++ b/crates/typst-layout/src/flow/compose.rs
@@ -723,7 +723,7 @@ fn layout_line_numbers(
continue;
}
- // Layout the number and record its width in search of the maximium.
+ // Layout the number and record its width in search of the maximum.
let frame = layout_line_number(engine, config, &mut locator, &marker.numbering)?;
// Note that this line.y is larger than the previous due to sorting.
diff --git a/crates/typst-layout/src/flow/distribute.rs b/crates/typst-layout/src/flow/distribute.rs
index 1852f7ca..5b293d35 100644
--- a/crates/typst-layout/src/flow/distribute.rs
+++ b/crates/typst-layout/src/flow/distribute.rs
@@ -35,7 +35,7 @@ pub fn distribute(composer: &mut Composer, regions: Regions) -> FlowResult<Frame
struct Distributor<'a, 'b, 'x, 'y, 'z> {
/// The composer that is used to handle insertions.
composer: &'z mut Composer<'a, 'b, 'x, 'y>,
- /// Regions which are continously shrunk as new items are added.
+ /// Regions which are continuously shrunk as new items are added.
regions: Regions<'z>,
/// Already laid out items, not yet aligned.
items: Vec<Item<'a, 'b>>,
diff --git a/crates/typst-layout/src/inline/shaping.rs b/crates/typst-layout/src/inline/shaping.rs
index bd803b52..c2b892d8 100644
--- a/crates/typst-layout/src/inline/shaping.rs
+++ b/crates/typst-layout/src/inline/shaping.rs
@@ -774,7 +774,7 @@ fn shape_segment<'a>(
buffer.guess_segment_properties();
// By default, Harfbuzz will create zero-width space glyphs for default
- // ignorables. This is probably useful for GUI apps that want noticable
+ // ignorables. This is probably useful for GUI apps that want noticeable
// effects on the cursor for those, but for us it's not useful and hurts
// text extraction.
buffer.set_flags(BufferFlags::REMOVE_DEFAULT_IGNORABLES);
diff --git a/crates/typst-layout/src/pages/finalize.rs b/crates/typst-layout/src/pages/finalize.rs
index 8df6cb16..b16d9569 100644
--- a/crates/typst-layout/src/pages/finalize.rs
+++ b/crates/typst-layout/src/pages/finalize.rs
@@ -23,6 +23,7 @@ pub fn finalize(
foreground,
fill,
numbering,
+ supplement,
}: LayoutedPage,
) -> SourceResult<Page> {
// If two sided, left becomes inside and right becomes outside.
@@ -69,5 +70,5 @@ pub fn finalize(
let number = counter.logical();
counter.step();
- Ok(Page { frame, fill, numbering, number })
+ Ok(Page { frame, fill, numbering, supplement, number })
}
diff --git a/crates/typst-layout/src/pages/run.rs b/crates/typst-layout/src/pages/run.rs
index 15735faa..79ff5ab0 100644
--- a/crates/typst-layout/src/pages/run.rs
+++ b/crates/typst-layout/src/pages/run.rs
@@ -14,7 +14,7 @@ use typst_library::layout::{
};
use typst_library::model::Numbering;
use typst_library::routines::{Pair, Routines};
-use typst_library::text::TextElem;
+use typst_library::text::{LocalName, TextElem};
use typst_library::visualize::Paint;
use typst_library::World;
use typst_utils::Numeric;
@@ -36,6 +36,7 @@ pub struct LayoutedPage {
pub foreground: Option<Frame>,
pub fill: Smart<Option<Paint>>,
pub numbering: Option<Numbering>,
+ pub supplement: Content,
}
/// Layout a single page suitable for parity adjustment.
@@ -128,6 +129,10 @@ fn layout_page_run_impl(
let header_ascent = PageElem::header_ascent_in(styles).relative_to(margin.top);
let footer_descent = PageElem::footer_descent_in(styles).relative_to(margin.bottom);
let numbering = PageElem::numbering_in(styles);
+ let supplement = match PageElem::supplement_in(styles) {
+ Smart::Auto => TextElem::packed(PageElem::local_name_in(styles)),
+ Smart::Custom(content) => content.unwrap_or_default(),
+ };
let number_align = PageElem::number_align_in(styles);
let binding =
PageElem::binding_in(styles).unwrap_or_else(|| match TextElem::dir_in(styles) {
@@ -204,6 +209,7 @@ fn layout_page_run_impl(
inner,
fill: fill.clone(),
numbering: numbering.clone(),
+ supplement: supplement.clone(),
header: layout_marginal(header, header_size, Alignment::BOTTOM)?,
footer: layout_marginal(footer, footer_size, Alignment::TOP)?,
background: layout_marginal(background, full_size, mid)?,