summaryrefslogtreecommitdiff
path: root/crates/typst-layout/src/math
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-01-22 14:24:14 +0100
committerGitHub <noreply@github.com>2025-01-22 13:24:14 +0000
commit6fcc4322845482c1810c26ee7f6fc8f6fed20d7d (patch)
tree93f20518774529d90d7f07b6de5122fe64218748 /crates/typst-layout/src/math
parentb45f574703f674c962e8678b4af0aabe081216a1 (diff)
Don't link items if container is already linked (#5732)
Diffstat (limited to 'crates/typst-layout/src/math')
-rw-r--r--crates/typst-layout/src/math/fragment.rs15
-rw-r--r--crates/typst-layout/src/math/stretch.rs3
2 files changed, 8 insertions, 10 deletions
diff --git a/crates/typst-layout/src/math/fragment.rs b/crates/typst-layout/src/math/fragment.rs
index a0453c14..81b726ba 100644
--- a/crates/typst-layout/src/math/fragment.rs
+++ b/crates/typst-layout/src/math/fragment.rs
@@ -1,23 +1,22 @@
use std::fmt::{self, Debug, Formatter};
use rustybuzz::Feature;
-use smallvec::SmallVec;
use ttf_parser::gsub::{AlternateSubstitution, SingleSubstitution, SubstitutionSubtable};
use ttf_parser::opentype_layout::LayoutTable;
use ttf_parser::{GlyphId, Rect};
use typst_library::foundations::StyleChain;
use typst_library::introspection::Tag;
use typst_library::layout::{
- Abs, Axis, Corner, Em, Frame, FrameItem, HideElem, Point, Size, VAlignment,
+ Abs, Axis, Corner, Em, Frame, FrameItem, Point, Size, VAlignment,
};
use typst_library::math::{EquationElem, MathSize};
-use typst_library::model::{Destination, LinkElem};
use typst_library::text::{Font, Glyph, Lang, Region, TextElem, TextItem};
use typst_library::visualize::Paint;
use typst_syntax::Span;
use unicode_math_class::MathClass;
use super::{stretch_glyph, MathContext, Scaled};
+use crate::modifiers::{FrameModifiers, FrameModify};
#[derive(Debug, Clone)]
pub enum MathFragment {
@@ -245,8 +244,7 @@ pub struct GlyphFragment {
pub class: MathClass,
pub math_size: MathSize,
pub span: Span,
- pub dests: SmallVec<[Destination; 1]>,
- pub hidden: bool,
+ pub modifiers: FrameModifiers,
pub limits: Limits,
pub extended_shape: bool,
}
@@ -302,8 +300,7 @@ impl GlyphFragment {
accent_attach: Abs::zero(),
class,
span,
- dests: LinkElem::dests_in(styles),
- hidden: HideElem::hidden_in(styles),
+ modifiers: FrameModifiers::get_in(styles),
extended_shape: false,
};
fragment.set_id(ctx, id);
@@ -390,7 +387,7 @@ impl GlyphFragment {
let mut frame = Frame::soft(size);
frame.set_baseline(self.ascent);
frame.push(Point::with_y(self.ascent + self.shift), FrameItem::Text(item));
- frame.post_process_raw(self.dests, self.hidden);
+ frame.modify(&self.modifiers);
frame
}
@@ -516,7 +513,7 @@ impl FrameFragment {
let base_ascent = frame.ascent();
let accent_attach = frame.width() / 2.0;
Self {
- frame: frame.post_processed(styles),
+ frame: frame.modified(&FrameModifiers::get_in(styles)),
font_size: TextElem::size_in(styles),
class: EquationElem::class_in(styles).unwrap_or(MathClass::Normal),
math_size: EquationElem::size_in(styles),
diff --git a/crates/typst-layout/src/math/stretch.rs b/crates/typst-layout/src/math/stretch.rs
index 6379bdb2..dafa8cbe 100644
--- a/crates/typst-layout/src/math/stretch.rs
+++ b/crates/typst-layout/src/math/stretch.rs
@@ -10,6 +10,7 @@ use super::{
delimiter_alignment, GlyphFragment, MathContext, MathFragment, Scaled,
VariantFragment,
};
+use crate::modifiers::FrameModify;
/// Maximum number of times extenders can be repeated.
const MAX_REPEATS: usize = 1024;
@@ -265,7 +266,7 @@ fn assemble(
let mut frame = Frame::soft(size);
let mut offset = Abs::zero();
frame.set_baseline(baseline);
- frame.post_process_raw(base.dests, base.hidden);
+ frame.modify(&base.modifiers);
for (fragment, advance) in selected {
let pos = match axis {