#![doc(
html_logo_url = "https://raw.githubusercontent.com/canvist/canvist/main/assets/brand/web/icon.svg",
html_favicon_url = "https://raw.githubusercontent.com/canvist/canvist/main/assets/brand/web/favicon.svg"
)]
mod breaks;
mod font;
mod geometry;
mod measure;
mod style;
mod text;
mod theme;
mod display;
mod document;
#[cfg(feature = "editor")]
mod editor;
mod navigate;
mod render;
pub use breaks::chromium_breaks;
use canvist_model::BlockId;
use canvist_model::Point;
pub use display::DecorationKind;
pub use display::DisplayItem;
pub use display::DisplayList;
pub use display::DisplayOptions;
pub use display::RectKind;
pub use display::SlotKind;
pub use display::TextRun;
pub use document::Adornment;
pub use document::Damage;
pub use document::DocumentLayout;
pub use document::FontInvalidation;
pub use document::LayoutOptions;
pub use document::Provisional;
pub use document::ViewportUpdate;
pub use font::FontBook;
pub use font::FontId;
pub use font::FontMetrics;
pub use font::FontSpec;
pub use font::LineBox;
pub use geometry::Color;
pub use geometry::Insets;
pub use geometry::Rect;
pub use measure::FixedMeasurer;
pub use measure::FontCacheStats;
pub use measure::MeasureBatch;
pub use measure::MeasureOutput;
pub use measure::MeasureStats;
#[cfg(feature = "parley")]
pub use measure::ParleyMeasurer;
pub use measure::SegmentRequest;
pub use measure::TextMeasurer;
pub use navigate::LayoutNavigator;
pub use navigate::LineEdge;
pub use navigate::VerticalDirection;
pub use navigate::VerticalMotion;
pub use render::HtmlDocument;
pub use render::HtmlOptions;
pub use render::css_number;
pub use render::to_html;
pub use render::to_svg;
pub use style::BlockStyle;
pub use theme::AttrBinding;
pub use theme::BlockPatch;
pub use theme::BlockRule;
pub use theme::Border;
pub use theme::Chrome;
pub use theme::ColorScheme;
pub use theme::Decorations;
pub use theme::EmbedRule;
pub use theme::EmbedStyle;
pub use theme::FontSize;
pub use theme::INK_WIDTH;
pub use theme::LeafStyle;
pub use theme::MarkRule;
pub use theme::MarkerKind;
pub use theme::MarkerStyle;
pub use theme::Motion;
pub use theme::StarterKitOptions;
pub use theme::TableRole;
pub use theme::TextPatch;
pub use theme::TextStyle;
pub use theme::Theme;
pub use theme::ThemeBuilder;
pub type BreakOverride = fn(Option<char>, char, char) -> Option<bool>;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Affinity {
Upstream,
#[default]
Downstream,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Caret {
pub point: Point,
pub affinity: Affinity,
}
impl Caret {
#[must_use]
pub const fn new(point: Point) -> Self {
Self {
point,
affinity: Affinity::Downstream,
}
}
#[must_use]
pub const fn with_affinity(point: Point, affinity: Affinity) -> Self {
Self { point, affinity }
}
}
#[derive(Clone, Debug, PartialEq, thiserror::Error)]
pub enum LayoutError {
#[error(
"the measurer returned {} font metrics and {} advances, but {} and {} were requested",
returned[0], returned[1], requested[0], requested[1]
)]
MeasurerContract {
requested: [u32; 2],
returned: [u32; 2],
},
#[error(
"the measurer returned {returned} line boxes, but {requested} (or none) were requested"
)]
LineBoxContract {
requested: u32,
returned: u32,
},
#[error("a text measurement was missing after measuring")]
MissingMeasurement,
#[error("block {0} is out of sync with the document; apply every commit to the layout")]
OutOfSync(BlockId),
}