Make anchoring explicit and improve reusability of text pipelines

This commit is contained in:
Héctor Ramón Jiménez 2025-05-04 03:54:42 +02:00
parent d643bd5ba2
commit 6bf709e03e
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
13 changed files with 423 additions and 325 deletions

View file

@ -1,8 +1,10 @@
//! Draw paragraphs.
use crate::core;
use crate::core::alignment;
use crate::core::text::{Alignment, Hit, Shaping, Span, Text, Wrapping};
use crate::core::{Font, Point, Rectangle, Size};
use crate::core::text::{
Alignment, Hit, LineHeight, Shaping, Span, Text, Wrapping,
};
use crate::core::{Font, Pixels, Point, Rectangle, Size};
use crate::text;
use std::fmt;
@ -220,6 +222,18 @@ impl core::text::Paragraph for Paragraph {
}
}
fn size(&self) -> Pixels {
Pixels(self.0.buffer.metrics().font_size)
}
fn font(&self) -> Font {
self.0.font
}
fn line_height(&self) -> LineHeight {
LineHeight::Absolute(Pixels(self.0.buffer.metrics().line_height))
}
fn align_x(&self) -> Alignment {
self.internal().align_x
}
@ -228,6 +242,18 @@ impl core::text::Paragraph for Paragraph {
self.internal().align_y
}
fn wrapping(&self) -> Wrapping {
self.0.wrapping
}
fn shaping(&self) -> Shaping {
self.0.shaping
}
fn bounds(&self) -> Size {
self.0.bounds
}
fn min_bounds(&self) -> Size {
self.internal().min_bounds
}