summaryrefslogtreecommitdiff
path: root/crates/typst-layout/src
diff options
context:
space:
mode:
authorMax <me@mkor.je>2024-11-27 11:11:49 +0000
committerGitHub <noreply@github.com>2024-11-27 11:11:49 +0000
commitf29fbea2fcabed9ed6fc3c19d585edc6fe45370b (patch)
treed5e3005cbedde714105794b8fc48da83e4db8049 /crates/typst-layout/src
parent6bf1350b16b90ae915836f94dff440da671ebd45 (diff)
Use extended shape information for glyph `text_like`-ness (#5483)
Diffstat (limited to 'crates/typst-layout/src')
-rw-r--r--crates/typst-layout/src/math/fragment.rs11
-rw-r--r--crates/typst-layout/src/math/stretch.rs1
2 files changed, 10 insertions, 2 deletions
diff --git a/crates/typst-layout/src/math/fragment.rs b/crates/typst-layout/src/math/fragment.rs
index 691a97f7..ac894668 100644
--- a/crates/typst-layout/src/math/fragment.rs
+++ b/crates/typst-layout/src/math/fragment.rs
@@ -148,7 +148,8 @@ impl MathFragment {
pub fn is_text_like(&self) -> bool {
match self {
- Self::Glyph(_) | Self::Variant(_) => self.class() != MathClass::Large,
+ Self::Glyph(glyph) => !glyph.extended_shape,
+ Self::Variant(variant) => !variant.extended_shape,
MathFragment::Frame(frame) => frame.text_like,
_ => false,
}
@@ -247,6 +248,7 @@ pub struct GlyphFragment {
pub dests: SmallVec<[Destination; 1]>,
pub hidden: bool,
pub limits: Limits,
+ pub extended_shape: bool,
}
impl GlyphFragment {
@@ -302,6 +304,7 @@ impl GlyphFragment {
span,
dests: LinkElem::dests_in(styles),
hidden: HideElem::hidden_in(styles),
+ extended_shape: false,
};
fragment.set_id(ctx, id);
fragment
@@ -332,7 +335,8 @@ impl GlyphFragment {
let accent_attach =
accent_attach(ctx, id, self.font_size).unwrap_or((width + italics) / 2.0);
- if !is_extended_shape(ctx, id) {
+ let extended_shape = is_extended_shape(ctx, id);
+ if !extended_shape {
width += italics;
}
@@ -342,6 +346,7 @@ impl GlyphFragment {
self.descent = -bbox.y_min.scaled(ctx, self.font_size);
self.italics_correction = italics;
self.accent_attach = accent_attach;
+ self.extended_shape = extended_shape;
}
pub fn height(&self) -> Abs {
@@ -358,6 +363,7 @@ impl GlyphFragment {
math_size: self.math_size,
span: self.span,
limits: self.limits,
+ extended_shape: self.extended_shape,
frame: self.into_frame(),
mid_stretched: None,
}
@@ -465,6 +471,7 @@ pub struct VariantFragment {
pub span: Span,
pub limits: Limits,
pub mid_stretched: Option<bool>,
+ pub extended_shape: bool,
}
impl VariantFragment {
diff --git a/crates/typst-layout/src/math/stretch.rs b/crates/typst-layout/src/math/stretch.rs
index 9b5cd47a..3d7c88cf 100644
--- a/crates/typst-layout/src/math/stretch.rs
+++ b/crates/typst-layout/src/math/stretch.rs
@@ -295,6 +295,7 @@ fn assemble(
span: base.span,
limits: base.limits,
mid_stretched: None,
+ extended_shape: true,
}
}