From 3ca5b238238e1128aa7bbfbd5db9e632045d8600 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 28 Feb 2022 15:50:48 +0100 Subject: Reorganize library --- src/library/text/deco.rs | 250 ++++++++++++++++++ src/library/text/link.rs | 64 +++++ src/library/text/mod.rs | 409 +++++++++++++++++++++++++++++ src/library/text/par.rs | 617 ++++++++++++++++++++++++++++++++++++++++++++ src/library/text/raw.rs | 127 +++++++++ src/library/text/shaping.rs | 552 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 2019 insertions(+) create mode 100644 src/library/text/deco.rs create mode 100644 src/library/text/link.rs create mode 100644 src/library/text/mod.rs create mode 100644 src/library/text/par.rs create mode 100644 src/library/text/raw.rs create mode 100644 src/library/text/shaping.rs (limited to 'src/library/text') diff --git a/src/library/text/deco.rs b/src/library/text/deco.rs new file mode 100644 index 00000000..a288c995 --- /dev/null +++ b/src/library/text/deco.rs @@ -0,0 +1,250 @@ +use kurbo::{BezPath, Line, ParamCurve}; +use ttf_parser::{GlyphId, OutlineBuilder}; + +use super::TextNode; +use crate::font::FontStore; +use crate::library::prelude::*; + +/// Typeset underline, stricken-through or overlined text. +#[derive(Debug, Hash)] +pub struct DecoNode(pub Template); + +/// Typeset underlined text. +pub type UnderlineNode = DecoNode; + +/// Typeset stricken-through text. +pub type StrikethroughNode = DecoNode; + +/// Typeset overlined text. +pub type OverlineNode = DecoNode; + +#[class] +impl DecoNode { + /// Stroke color of the line, defaults to the text color if `None`. + #[shorthand] + pub const STROKE: Option = None; + /// Thickness of the line's strokes (dependent on scaled font size), read + /// from the font tables if `None`. + #[shorthand] + pub const THICKNESS: Option = None; + /// Position of the line relative to the baseline (dependent on scaled font + /// size), read from the font tables if `None`. + pub const OFFSET: Option = None; + /// Amount that the line will be longer or shorter than its associated text + /// (dependent on scaled font size). + pub const EXTENT: Linear = Linear::zero(); + /// Whether the line skips sections in which it would collide + /// with the glyphs. Does not apply to strikethrough. + pub const EVADE: bool = true; + + fn construct(_: &mut Context, args: &mut Args) -> TypResult