use std::sync::Arc; use either::Either; use unicode_bidi::{BidiInfo, Level}; use xi_unicode::LineBreakIterator; use super::{shape, ShapedText, TextNode}; use crate::font::FontStore; use crate::library::layout::SpacingKind; use crate::library::prelude::*; use crate::util::{ArcExt, EcoString, RangeExt, SliceExt}; /// Arrange text, spacing and inline-level nodes into a paragraph. #[derive(Hash)] pub struct ParNode(pub StyleVec); /// A uniformly styled atomic piece of a paragraph. #[derive(Hash)] pub enum ParChild { /// A chunk of text. Text(EcoString), /// Horizontal spacing between other children. Spacing(SpacingKind), /// An arbitrary inline-level node. Node(LayoutNode), } #[class] impl ParNode { /// An ISO 639-1 language code. pub const LANG: Option = None; /// The direction for text and inline objects. pub const DIR: Dir = Dir::LTR; /// How to align text and inline objects in their line. pub const ALIGN: Align = Align::Left; /// Whether to justify text in its line. pub const JUSTIFY: bool = false; /// Whether to hyphenate text to improve line breaking. When `auto`, words /// will will be hyphenated if and only if justification is enabled. pub const HYPHENATE: Smart = Smart::Auto; /// The spacing between lines (dependent on scaled font size). pub const LEADING: Linear = Relative::new(0.65).into(); /// The extra spacing between paragraphs (dependent on scaled font size). pub const SPACING: Linear = Relative::new(0.55).into(); /// The indent the first line of a consecutive paragraph should have. pub const INDENT: Linear = Linear::zero(); fn construct(_: &mut Context, args: &mut Args) -> TypResult