From 083ef6a80428e094f7b3a879662c14cb11512d1e Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 19 Jan 2022 03:50:40 +0800 Subject: [PATCH] it's not totally lolfailing but needs a lot of cleanup still --- services/graphics-server/src/main.rs | 1 + services/graphics-server/src/wordwrap.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/graphics-server/src/main.rs b/services/graphics-server/src/main.rs index 454ce834b..f3efba908 100644 --- a/services/graphics-server/src/main.rs +++ b/services/graphics-server/src/main.rs @@ -342,6 +342,7 @@ fn xmain() -> ! { line, Some(clear_rect), tv.invert); } } + // log::info!("drawing {:?} at {:?}", glyph, p); blitstr2::xor_glyph(display.native_buffer(), &p, *glyph, tv.invert); p.x += glyph.wide as usize; // words after word-wrapping are guaranteed to be on the same line insert_point += 1; diff --git a/services/graphics-server/src/wordwrap.rs b/services/graphics-server/src/wordwrap.rs index 092a72435..bb0f7b420 100644 --- a/services/graphics-server/src/wordwrap.rs +++ b/services/graphics-server/src/wordwrap.rs @@ -30,6 +30,7 @@ use crate::style_macros::*; /// A TypesetWord is a Word that has beet turned into sprites and placed at a specific location on the canvas, /// defined by its `bb` record. The intention is that this abstract representation can be passed directly to /// a rasterizer for rendering. +#[derive(Debug)] pub struct TypesetWord { pub gs: Vec::, pub origin: Pt, @@ -56,6 +57,7 @@ impl TypesetWord { pub fn push(&mut self, gs: GlyphSprite) { self.width += gs.wide as usize; self.height = self.height.max(gs.high as usize); + self.gs.push(gs); } /// offset has to take an explicit x/y set because Pt is defined as a usize, so we can't do negative offsets pub fn offset(&mut self, x: i16, y: i16) { @@ -141,7 +143,8 @@ pub fn fit_str_to_clip( // the origin point is 0,0, because we will translate it to the correct spot later let mut tsw = TypesetWord::new(Pt::new(0, 0)); for ch in word.chars() { - tsw.push(style_glyph(ch, base_style)); + let gs = style_glyph(ch, base_style); + tsw.push(gs); } // there are five cases from here: // 1. The word fits in the remaining space on the line.