summaryrefslogtreecommitdiff
path: root/src/shaping.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-11 22:38:30 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-11 22:38:30 +0200
commitd3bc4ec07349a96c3863ddce63c2e52b5e7e9f2f (patch)
tree09c582973b58f05f9248d88f0020bf1dda262aa5 /src/shaping.rs
parentf04ad0ffa5f34bb7fd97e5c94c7547f96904220c (diff)
Refactor layouting base 🪁
Diffstat (limited to 'src/shaping.rs')
-rw-r--r--src/shaping.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/shaping.rs b/src/shaping.rs
index bc6fb6b7..5c718acb 100644
--- a/src/shaping.rs
+++ b/src/shaping.rs
@@ -22,11 +22,11 @@ pub struct Shaped {
pub face: FaceId,
/// The shaped glyphs.
pub glyphs: Vec<GlyphId>,
- /// The horizontal offsets of the glyphs. This is indexed parallel to `glyphs`.
- /// Vertical offets are not yet supported.
+ /// The horizontal offsets of the glyphs. This is indexed parallel to
+ /// `glyphs`. Vertical offets are not yet supported.
pub offsets: Vec<Length>,
/// The font size.
- pub size: Length,
+ pub font_size: Length,
}
impl Shaped {
@@ -37,7 +37,7 @@ impl Shaped {
face,
glyphs: vec![],
offsets: vec![],
- size,
+ font_size: size,
}
}
@@ -62,15 +62,15 @@ impl Debug for Shaped {
///
/// [`Shaped`]: struct.Shaped.html
pub async fn shape(
+ loader: &mut FontLoader,
text: &str,
- size: Length,
+ font_size: Length,
dir: Dir,
- loader: &mut FontLoader,
fallback: &FallbackTree,
variant: FontVariant,
) -> BoxLayout {
- let mut layout = BoxLayout::new(Size::new(Length::ZERO, size));
- let mut shaped = Shaped::new(FaceId::MAX, size);
+ let mut layout = BoxLayout::new(Size::new(Length::ZERO, font_size));
+ let mut shaped = Shaped::new(FaceId::MAX, font_size);
let mut offset = Length::ZERO;
// Create an iterator with conditional direction.
@@ -86,7 +86,7 @@ pub async fn shape(
let query = FaceQuery { fallback: fallback.iter(), variant, c };
if let Some((id, owned_face)) = loader.query(query).await {
let face = owned_face.get();
- let (glyph, width) = match lookup_glyph(face, c, size) {
+ let (glyph, width) = match lookup_glyph(face, c, font_size) {
Some(v) => v,
None => continue,
};
@@ -96,7 +96,7 @@ pub async fn shape(
let pos = Point::new(layout.size.width, Length::ZERO);
layout.push(pos, LayoutElement::Text(shaped));
layout.size.width += offset;
- shaped = Shaped::new(FaceId::MAX, size);
+ shaped = Shaped::new(FaceId::MAX, font_size);
offset = Length::ZERO;
}