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:
Laurenz 2023-06-08 10:20:24 +02:00
parent 4e5cc61599
commit 10ae0a2c2b
4 changed files with 12 additions and 3 deletions

View File

@ -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>()

View File

@ -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>()

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

View File

@ -0,0 +1,5 @@
// Test right-aligning a line and a rectangle.
---
#align(right, line(length: 30%))
#align(right, rect())