From 70f9ca44057ce87e7d84a39f46a4877fc5f3d095 Mon Sep 17 00:00:00 2001 From: mars Date: Mon, 5 Dec 2022 20:20:33 -0700 Subject: [PATCH] Add configurable textwrap scale and line height --- crates/textwrap/src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/textwrap/src/lib.rs b/crates/textwrap/src/lib.rs index 28ab6fe..6e602a2 100644 --- a/crates/textwrap/src/lib.rs +++ b/crates/textwrap/src/lib.rs @@ -163,12 +163,11 @@ pub struct Layout { } impl Layout { - pub fn draw(&self, cache: &TextCache, ctx: &DrawContext) { - let line_height = 12.0; + pub fn draw(&self, cache: &TextCache, ctx: &DrawContext, scale: f32, line_height: f32) { let mut cursor = Vec2::ZERO; for line in self.lines.iter() { let ctx = ctx.with_offset(cursor); - line.draw(cache, &ctx); + line.draw(cache, &ctx, scale); cursor.y += line_height; } } @@ -209,8 +208,7 @@ impl Line { Self { fragments } } - pub fn draw(&self, cache: &TextCache, ctx: &DrawContext) { - let scale = 10.0; + pub fn draw(&self, cache: &TextCache, ctx: &DrawContext, scale: f32) { let mut cursor = Vec2::ZERO; for fragment in self.fragments.iter() { if !fragment.hidden {