mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Improved #box baselines in math (#1755)
* Improved #box baselines in math * add a test
This commit is contained in:
parent
c72952b512
commit
51a21403ba
@ -43,7 +43,7 @@ use self::ctx::*;
|
|||||||
use self::fragment::*;
|
use self::fragment::*;
|
||||||
use self::row::*;
|
use self::row::*;
|
||||||
use self::spacing::*;
|
use self::spacing::*;
|
||||||
use crate::layout::{HElem, ParElem, Spacing};
|
use crate::layout::{BoxElem, HElem, ParElem, Spacing};
|
||||||
use crate::meta::Supplement;
|
use crate::meta::Supplement;
|
||||||
use crate::meta::{
|
use crate::meta::{
|
||||||
Count, Counter, CounterUpdate, LocalName, Numbering, Outlinable, Refable,
|
Count, Counter, CounterUpdate, LocalName, Numbering, Outlinable, Refable,
|
||||||
@ -480,8 +480,12 @@ impl LayoutMath for Content {
|
|||||||
|
|
||||||
let mut frame = ctx.layout_content(self)?;
|
let mut frame = ctx.layout_content(self)?;
|
||||||
if !frame.has_baseline() {
|
if !frame.has_baseline() {
|
||||||
let axis = scaled!(ctx, axis_height);
|
if self.is::<BoxElem>() {
|
||||||
frame.set_baseline(frame.height() / 2.0 + axis);
|
frame.set_baseline(frame.height());
|
||||||
|
} else {
|
||||||
|
let axis = scaled!(ctx, axis_height);
|
||||||
|
frame.set_baseline(frame.height() / 2.0 + axis);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ctx.push(FrameFragment::new(ctx, frame).with_spaced(true));
|
ctx.push(FrameFragment::new(ctx, frame).with_spaced(true));
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 10 KiB |
@ -17,3 +17,17 @@ $ x := #table(columns: 2)[x][y]/mat(1, 2, 3)
|
|||||||
// Test font switch.
|
// Test font switch.
|
||||||
#let here = text.with(font: "Noto Sans")
|
#let here = text.with(font: "Noto Sans")
|
||||||
$#here[f] := #here[Hi there]$.
|
$#here[f] := #here[Hi there]$.
|
||||||
|
|
||||||
|
---
|
||||||
|
// Test boxes without a baseline act as if the baseline is at the base
|
||||||
|
#{
|
||||||
|
box(stroke: 0.2pt, $a #box(stroke: 0.2pt, $a$)$)
|
||||||
|
h(12pt)
|
||||||
|
box(stroke: 0.2pt, $a #box(stroke: 0.2pt, $g$)$)
|
||||||
|
h(12pt)
|
||||||
|
box(stroke: 0.2pt, $g #box(stroke: 0.2pt, $g$)$)
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
// Test boxes with a baseline are respected
|
||||||
|
#box(stroke: 0.2pt, $a #box(baseline:0.5em, stroke: 0.2pt, $a$)$)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user