mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Fix line alignment
Fixes #1398. How this works for the other shapes is a hack, but the line was missing from that hack.
This commit is contained in:
parent
4e5cc61599
commit
10ae0a2c2b
@ -6,7 +6,8 @@ use super::{
|
||||
use crate::meta::{FootnoteElem, FootnoteEntry};
|
||||
use crate::prelude::*;
|
||||
use crate::visualize::{
|
||||
CircleElem, EllipseElem, ImageElem, PathElem, PolygonElem, RectElem, SquareElem,
|
||||
CircleElem, EllipseElem, ImageElem, LineElem, PathElem, PolygonElem, RectElem,
|
||||
SquareElem,
|
||||
};
|
||||
|
||||
/// Arrange spacing, paragraphs and block-level elements into a flow.
|
||||
@ -45,7 +46,8 @@ impl Layout for FlowElem {
|
||||
layouter.layout_spacing(vt, elem, styles)?;
|
||||
} else if let Some(elem) = child.to::<ParElem>() {
|
||||
layouter.layout_par(vt, elem, styles)?;
|
||||
} else if child.is::<RectElem>()
|
||||
} else if child.is::<LineElem>()
|
||||
|| child.is::<RectElem>()
|
||||
|| child.is::<SquareElem>()
|
||||
|| child.is::<EllipseElem>()
|
||||
|| child.is::<CircleElem>()
|
||||
|
@ -58,7 +58,8 @@ use crate::prelude::*;
|
||||
use crate::shared::BehavedBuilder;
|
||||
use crate::text::{LinebreakElem, SmartQuoteElem, SpaceElem, TextElem};
|
||||
use crate::visualize::{
|
||||
CircleElem, EllipseElem, ImageElem, PathElem, PolygonElem, RectElem, SquareElem,
|
||||
CircleElem, EllipseElem, ImageElem, LineElem, PathElem, PolygonElem, RectElem,
|
||||
SquareElem,
|
||||
};
|
||||
|
||||
/// Hook up all layout definitions.
|
||||
@ -248,6 +249,7 @@ fn realize_block<'a>(
|
||||
styles: StyleChain<'a>,
|
||||
) -> SourceResult<(Content, StyleChain<'a>)> {
|
||||
if content.can::<dyn Layout>()
|
||||
&& !content.is::<LineElem>()
|
||||
&& !content.is::<RectElem>()
|
||||
&& !content.is::<SquareElem>()
|
||||
&& !content.is::<EllipseElem>()
|
||||
|
BIN
tests/ref/bugs/line-align.png
Normal file
BIN
tests/ref/bugs/line-align.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 137 B |
5
tests/typ/bugs/line-align.typ
Normal file
5
tests/typ/bugs/line-align.typ
Normal file
@ -0,0 +1,5 @@
|
||||
// Test right-aligning a line and a rectangle.
|
||||
|
||||
---
|
||||
#align(right, line(length: 30%))
|
||||
#align(right, rect())
|
Loading…
x
Reference in New Issue
Block a user