summaryrefslogtreecommitdiff
path: root/src/library/text
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-07 14:32:35 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-07 16:19:51 +0200
commit1192132dc0a9e991953fd29e93f87c8437a53ea0 (patch)
tree67061e75a5a15c7997a3ac2de349b5e9ce234434 /src/library/text
parenteb22eed31b08874fbbbee68d2ae59f0d02f9e95d (diff)
Rename length-related types
`Fractional` => `Fraction` `Relative` => `Ratio` `Linear` => `Relative`
Diffstat (limited to 'src/library/text')
-rw-r--r--src/library/text/deco.rs12
-rw-r--r--src/library/text/mod.rs22
-rw-r--r--src/library/text/par.rs16
3 files changed, 25 insertions, 25 deletions
diff --git a/src/library/text/deco.rs b/src/library/text/deco.rs
index a6375e4e..a81f0374 100644
--- a/src/library/text/deco.rs
+++ b/src/library/text/deco.rs
@@ -26,13 +26,13 @@ impl<const L: DecoLine> DecoNode<L> {
/// Thickness of the line's strokes (dependent on scaled font size), read
/// from the font tables if `None`.
#[property(shorthand)]
- pub const THICKNESS: Option<Linear> = None;
+ pub const THICKNESS: Option<Relative> = 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<Linear> = None;
+ pub const OFFSET: Option<Relative> = 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();
+ pub const EXTENT: Relative = Relative::zero();
/// Whether the line skips sections in which it would collide
/// with the glyphs. Does not apply to strikethrough.
pub const EVADE: bool = true;
@@ -66,9 +66,9 @@ impl<const L: DecoLine> Show for DecoNode<L> {
pub struct Decoration {
pub line: DecoLine,
pub stroke: Option<Paint>,
- pub thickness: Option<Linear>,
- pub offset: Option<Linear>,
- pub extent: Linear,
+ pub thickness: Option<Relative>,
+ pub offset: Option<Relative>,
+ pub extent: Relative,
pub evade: bool,
}
diff --git a/src/library/text/mod.rs b/src/library/text/mod.rs
index 64994136..975a4805 100644
--- a/src/library/text/mod.rs
+++ b/src/library/text/mod.rs
@@ -49,7 +49,7 @@ impl TextNode {
/// The amount of space that should be added between characters.
pub const TRACKING: Em = Em::zero();
/// The ratio by which spaces should be stretched.
- pub const SPACING: Relative = Relative::one();
+ pub const SPACING: Ratio = Ratio::one();
/// Whether glyphs can hang over into the margin.
pub const OVERHANG: bool = true;
/// The top end of the text bounding box.
@@ -182,13 +182,13 @@ castable! {
castable! {
FontStretch,
- Expected: "relative",
- Value::Relative(v) => Self::from_ratio(v.get() as f32),
+ Expected: "ratio",
+ Value::Ratio(v) => Self::from_ratio(v.get() as f32),
}
/// The size of text.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
-pub struct FontSize(pub Linear);
+pub struct FontSize(pub Relative);
impl Fold for FontSize {
type Output = Length;
@@ -200,10 +200,10 @@ impl Fold for FontSize {
castable! {
FontSize,
- Expected: "linear",
+ Expected: "relative length",
Value::Length(v) => Self(v.into()),
- Value::Relative(v) => Self(v.into()),
- Value::Linear(v) => Self(v),
+ Value::Ratio(v) => Self(v.into()),
+ Value::Relative(v) => Self(v),
}
castable! {
@@ -214,10 +214,10 @@ castable! {
castable! {
VerticalFontMetric,
- Expected: "linear or string",
- Value::Length(v) => Self::Linear(v.into()),
- Value::Relative(v) => Self::Linear(v.into()),
- Value::Linear(v) => Self::Linear(v),
+ Expected: "string or relative length",
+ Value::Length(v) => Self::Relative(v.into()),
+ Value::Ratio(v) => Self::Relative(v.into()),
+ Value::Relative(v) => Self::Relative(v),
Value::Str(string) => match string.as_str() {
"ascender" => Self::Ascender,
"cap-height" => Self::CapHeight,
diff --git a/src/library/text/par.rs b/src/library/text/par.rs
index 1695e010..a05aff44 100644
--- a/src/library/text/par.rs
+++ b/src/library/text/par.rs
@@ -42,11 +42,11 @@ impl ParNode {
/// will will be hyphenated if and only if justification is enabled.
pub const HYPHENATE: Smart<bool> = Smart::Auto;
/// The spacing between lines (dependent on scaled font size).
- pub const LEADING: Linear = Relative::new(0.65).into();
+ pub const LEADING: Relative = Ratio::new(0.65).into();
/// The extra spacing between paragraphs (dependent on scaled font size).
- pub const SPACING: Linear = Relative::new(0.55).into();
+ pub const SPACING: Relative = Ratio::new(0.55).into();
/// The indent the first line of a consecutive paragraph should have.
- pub const INDENT: Linear = Linear::zero();
+ pub const INDENT: Relative = Relative::zero();
fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> {
// The paragraph constructor is special: It doesn't create a paragraph
@@ -249,7 +249,7 @@ enum ParItem<'a> {
/// Absolute spacing between other items.
Absolute(Length),
/// Fractional spacing between other items.
- Fractional(Fractional),
+ Fractional(Fraction),
/// A shaped text run with consistent direction.
Text(ShapedText<'a>),
/// A layouted child node.
@@ -285,8 +285,8 @@ struct Line<'a> {
size: Size,
/// The baseline of the line.
baseline: Length,
- /// The sum of fractional ratios in the line.
- fr: Fractional,
+ /// The sum of fractions in the line.
+ fr: Fraction,
/// Whether the line ends at a mandatory break.
mandatory: bool,
/// Whether the line ends with a hyphen or dash, either naturally or through
@@ -370,7 +370,7 @@ fn prepare<'a>(
}
}
ParChild::Spacing(spacing) => match *spacing {
- Spacing::Linear(v) => {
+ Spacing::Relative(v) => {
let resolved = v.resolve(regions.base.x);
items.push(ParItem::Absolute(resolved));
ranges.push(range);
@@ -731,7 +731,7 @@ fn line<'a>(
let mut width = Length::zero();
let mut top = Length::zero();
let mut bottom = Length::zero();
- let mut fr = Fractional::zero();
+ let mut fr = Fraction::zero();
// Measure the size of the line.
for item in first.iter().chain(items).chain(&last) {