From 2bf0b685cd5b41e4538abf8d8df8f592531f8d42 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 25 Mar 2022 23:50:26 +0800 Subject: [PATCH 1/5] add a response code for dictionary not found --- services/pddb/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/services/pddb/src/lib.rs b/services/pddb/src/lib.rs index 1ef098e70..983d31ef4 100644 --- a/services/pddb/src/lib.rs +++ b/services/pddb/src/lib.rs @@ -444,6 +444,7 @@ impl Pddb { let response = buf.to_original::().unwrap(); let count = match response.code { PddbRequestCode::NoErr => response.index, + PddbRequestCode::NotFound => return Err(Error::new(ErrorKind::NotFound, "dictionary not found")), _ => return Err(Error::new(ErrorKind::Other, "Internal error")), }; // very non-optimal, slow way of doing this, but let's just get it working first and optimize later. From c79afd4220c662bc4eb8736e9b39225349b6771b Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 28 Mar 2022 04:09:19 +0800 Subject: [PATCH 2/5] make sure the directory is not deleted --- tools/pddb-images/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tools/pddb-images/.keep diff --git a/tools/pddb-images/.keep b/tools/pddb-images/.keep new file mode 100644 index 000000000..e69de29bb From 290188f36b642d521ac9ad7f67688d7d50c8a38c Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 28 Mar 2022 15:49:22 +0800 Subject: [PATCH 3/5] try to fix the gh automation --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b94b35111..efc16e769 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,9 @@ jobs: - name: Install RISC-V toolkit run: cargo xtask install-toolkit --force - + + - name: Clean out old target directory (in case of libstd change) + run: rm -rf target/* + - name: Build hosted-ci run: cargo xtask ${{ matrix.task }} From 287aea90b6fc847e6a318bb483a790cd82e7babe Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 28 Mar 2022 17:48:38 +0800 Subject: [PATCH 4/5] bump to latest version of minifb --- Cargo.lock | 60 +++++++++++++++++++---------- services/graphics-server/Cargo.toml | 4 +- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e75750994..04c332d22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -689,6 +689,12 @@ dependencies = [ "cipher", ] +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + [[package]] name = "curl" version = "0.4.35" @@ -1593,9 +1599,9 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memoffset" -version = "0.6.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] @@ -1624,12 +1630,14 @@ dependencies = [ [[package]] name = "minifb" -version = "0.19.3" -source = "git+https://github.com/betrusted-io/rust_minifb.git?rev=1717ec60830c1f9592b77ce875e492afef1aa533#1717ec60830c1f9592b77ce875e492afef1aa533" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e52abe7ff0cb18cd88a6e9d7a91ca1ff74876587e7b6b1f30d1aeee9aa89aed" dependencies = [ "cc", + "libc", "orbclient", - "raw-window-handle", + "raw-window-handle 0.4.2", "tempfile", "wayland-client", "wayland-cursor", @@ -1698,14 +1706,15 @@ dependencies = [ [[package]] name = "nix" -version = "0.20.0" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a" +checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" dependencies = [ "bitflags", "cc", "cfg-if 1.0.0", "libc", + "memoffset", ] [[package]] @@ -1827,7 +1836,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee68c3c79e81d82127e0870f94479675774d34c7ad5b55eecb9c320ef9701187" dependencies = [ "libc", - "raw-window-handle", + "raw-window-handle 0.3.3", "redox_syscall", "sdl2", "sdl2-sys", @@ -2104,6 +2113,15 @@ dependencies = [ "libc", ] +[[package]] +name = "raw-window-handle" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba75eee94a9d5273a68c9e1e105d9cffe1ef700532325788389e5a83e2522b7" +dependencies = [ + "cty", +] + [[package]] name = "rayon" version = "1.5.1" @@ -2416,7 +2434,7 @@ dependencies = [ "bitflags", "lazy_static", "libc", - "raw-window-handle", + "raw-window-handle 0.3.3", "sdl2-sys", ] @@ -3225,9 +3243,9 @@ checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" [[package]] name = "wayland-client" -version = "0.28.6" +version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ab332350e502f159382201394a78e3cc12d0f04db863429260164ea40e0355" +checksum = "91223460e73257f697d9e23d401279123d36039a3f7a449e983f123292d4458f" dependencies = [ "bitflags", "downcast-rs", @@ -3240,9 +3258,9 @@ dependencies = [ [[package]] name = "wayland-commons" -version = "0.28.6" +version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21817947c7011bbd0a27e11b17b337bfd022e8544b071a2641232047966fbda" +checksum = "94f6e5e340d7c13490eca867898c4cec5af56c27a5ffe5c80c6fc4708e22d33e" dependencies = [ "nix", "once_cell", @@ -3252,9 +3270,9 @@ dependencies = [ [[package]] name = "wayland-cursor" -version = "0.28.6" +version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be610084edd1586d45e7bdd275fe345c7c1873598caa464c4fb835dee70fa65a" +checksum = "c52758f13d5e7861fc83d942d3d99bf270c83269575e52ac29e5b73cb956a6bd" dependencies = [ "nix", "wayland-client", @@ -3263,9 +3281,9 @@ dependencies = [ [[package]] name = "wayland-protocols" -version = "0.28.6" +version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "286620ea4d803bacf61fa087a4242ee316693099ee5a140796aaba02b29f861f" +checksum = "60147ae23303402e41fe034f74fb2c35ad0780ee88a1c40ac09a3be1e7465741" dependencies = [ "bitflags", "wayland-client", @@ -3275,9 +3293,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.28.6" +version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce923eb2deb61de332d1f356ec7b6bf37094dc5573952e1c8936db03b54c03f1" +checksum = "39a1ed3143f7a143187156a2ab52742e89dac33245ba505c17224df48939f9e0" dependencies = [ "proc-macro2", "quote", @@ -3286,9 +3304,9 @@ dependencies = [ [[package]] name = "wayland-sys" -version = "0.28.6" +version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d841fca9aed7febf9bed2e9796c49bf58d4152ceda8ac949ebe00868d8f0feb8" +checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4" dependencies = [ "pkg-config", ] diff --git a/services/graphics-server/Cargo.toml b/services/graphics-server/Cargo.toml index 7f564d1d7..ea825c34b 100644 --- a/services/graphics-server/Cargo.toml +++ b/services/graphics-server/Cargo.toml @@ -25,9 +25,7 @@ rkyv = {version = "0.4.3", default-features = false, features = ["const_generics utralib = {path = "../../utralib"} [target.'cfg(any(windows,unix))'.dependencies] -# this is forked from minifb because the `set_key_state` callback was dropped in later versions of minifb (or maybe it was never there?) -# the working branch is thus `set-key-state-cb` -minifb = {version = "0.19.2", git = "https://github.com/betrusted-io/rust_minifb.git", rev = "1717ec60830c1f9592b77ce875e492afef1aa533"} +minifb = "0.22.0" [features] debugprint = [] From 5452fae33c0baeff82dfb056dee433bab2ef687d Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 28 Mar 2022 23:17:18 +0800 Subject: [PATCH 5/5] harmonize blitstr2 and graphics-server to an i16 pixel representation previously blitstr2 is using usize for x/y coords, which means that for layout purposes points could not go to the top or left boundary without causing arithmetic overflow. Of course, you want to render everything on-screen, but, as we have multi-line text with overflow possibility, it's reasonable to be able to use negative coordinates to locate text boxes that flow into the visible region. This of course means that occassionally you can come out with things like "negative widths", but even then, there can be reasonable uses for this as an intermediate in calculations that ultimately arrive at a positive result. --- services/graphics-server/src/api.rs | 4 +- services/graphics-server/src/api/blitstr2.rs | 4 +- .../src/api/blitstr2/cliprect.rs | 2 +- .../src/api/blitstr2/cursor.rs | 6 +-- .../graphics-server/src/api/blitstr2/pt.rs | 6 +-- .../graphics-server/src/backend/minifb.rs | 18 ++++----- services/graphics-server/src/blitstr2.rs | 6 +-- .../graphics-server/src/blitstr2/cliprect.rs | 2 +- services/graphics-server/src/main.rs | 10 ++--- services/graphics-server/src/wordwrap.rs | 40 +++++++++---------- 10 files changed, 49 insertions(+), 49 deletions(-) diff --git a/services/graphics-server/src/api.rs b/services/graphics-server/src/api.rs index 2bee41ed2..f9d3c1490 100644 --- a/services/graphics-server/src/api.rs +++ b/services/graphics-server/src/api.rs @@ -29,8 +29,8 @@ pub use blitstr2::*; use std::hash::{Hash, Hasher}; -pub const LINES: usize = 536; -pub const WIDTH: usize = 336; +pub const LINES: i16 = 536; +pub const WIDTH: i16 = 336; //////////////// IPC APIs #[derive(Debug, Copy, Clone, PartialEq, Eq, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] diff --git a/services/graphics-server/src/api/blitstr2.rs b/services/graphics-server/src/api/blitstr2.rs index 84aa9b75f..c1f6a69cb 100644 --- a/services/graphics-server/src/api/blitstr2.rs +++ b/services/graphics-server/src/api/blitstr2.rs @@ -42,9 +42,9 @@ pub(crate) struct TypesetWord { /// top left origin point for rendering of the glyphs pub origin: Pt, /// width of the word - pub width: usize, + pub width: i16, /// overall height for the word - pub height: usize, + pub height: i16, /// set if this `word` is not drawable, e.g. a newline placeholder. /// *however* the Vec should still be checked for an insertion point, so that /// successive newlines properly get their insertion point drawn diff --git a/services/graphics-server/src/api/blitstr2/cliprect.rs b/services/graphics-server/src/api/blitstr2/cliprect.rs index e159f77b7..2712285f4 100644 --- a/services/graphics-server/src/api/blitstr2/cliprect.rs +++ b/services/graphics-server/src/api/blitstr2/cliprect.rs @@ -17,7 +17,7 @@ pub struct ClipRect { #[allow(dead_code)] impl ClipRect { /// Initialize a rectangle using automatic min/max fixup for corner points - pub fn new(min_x: usize, min_y: usize, max_x: usize, max_y: usize) -> ClipRect { + pub fn new(min_x: i16, min_y: i16, max_x: i16, max_y: i16) -> ClipRect { // Make sure min_x <= max_x && min_y <= max_y let mut min = Pt { x: min_x, y: min_y }; let mut max = Pt { x: max_x, y: max_y }; diff --git a/services/graphics-server/src/api/blitstr2/cursor.rs b/services/graphics-server/src/api/blitstr2/cursor.rs index 3249af2f2..00f8c1230 100644 --- a/services/graphics-server/src/api/blitstr2/cursor.rs +++ b/services/graphics-server/src/api/blitstr2/cursor.rs @@ -17,7 +17,7 @@ pub struct Cursor { #[allow(dead_code)] impl Cursor { // Make a new Cursor. When in doubt, set line_height = 0. - pub fn new(x: usize, y: usize, line_height: usize) -> Cursor { + pub fn new(x: i16, y: i16, line_height: usize) -> Cursor { Cursor { pt: Pt { x, y }, line_height, @@ -33,13 +33,13 @@ impl Cursor { } pub fn update_glyph(&mut self, glyph: &GlyphSprite) { - self.pt.x += glyph.wide as usize; + self.pt.x += glyph.wide as i16; self.line_height = self.line_height.max(glyph.high as usize); } pub(crate) fn update_word(&mut self, word: &TypesetWord) { self.pt.x += word.width; - self.line_height = self.line_height.max(word.height); + self.line_height = self.line_height.max(word.height as usize); } pub fn add(&self, other: Cursor) -> Cursor { diff --git a/services/graphics-server/src/api/blitstr2/pt.rs b/services/graphics-server/src/api/blitstr2/pt.rs index fb9dab8a8..ee226bb70 100644 --- a/services/graphics-server/src/api/blitstr2/pt.rs +++ b/services/graphics-server/src/api/blitstr2/pt.rs @@ -5,13 +5,13 @@ /// Point specifies a pixel coordinate #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub struct Pt { - pub x: usize, - pub y: usize, + pub x: i16, + pub y: i16, } impl Pt { /// Make a new point - pub fn new(x: usize, y: usize) -> Pt { + pub fn new(x: i16, y: i16) -> Pt { Pt { x, y } } } diff --git a/services/graphics-server/src/backend/minifb.rs b/services/graphics-server/src/backend/minifb.rs index c437c8c27..96b121964 100644 --- a/services/graphics-server/src/backend/minifb.rs +++ b/services/graphics-server/src/backend/minifb.rs @@ -4,14 +4,14 @@ use crate::api::Point; use minifb::{Key, Window, WindowOptions}; use crate::api::{LINES, WIDTH}; -const HEIGHT: usize = LINES; +const HEIGHT: i16 = LINES; /// Width of the screen in 32-bit words const WIDTH_WORDS: usize = 11; pub const FB_WIDTH_WORDS: usize = WIDTH_WORDS; -pub const FB_WIDTH_PIXELS: usize = WIDTH; -pub const FB_LINES: usize = HEIGHT; -pub const FB_SIZE: usize = WIDTH_WORDS * HEIGHT; // 44 bytes by 536 lines +pub const FB_WIDTH_PIXELS: usize = WIDTH as usize; +pub const FB_LINES: usize = HEIGHT as usize; +pub const FB_SIZE: usize = WIDTH_WORDS * HEIGHT as usize; // 44 bytes by 536 lines const MAX_FPS: u64 = 60; const DARK_COLOUR: u32 = 0xB5B5AD; @@ -34,8 +34,8 @@ impl XousDisplay { pub fn new() -> XousDisplay { let mut window = Window::new( "Precursor", - WIDTH, - HEIGHT, + WIDTH as usize, + HEIGHT as usize, WindowOptions { scale_mode: minifb::ScaleMode::AspectRatioStretch, resize: true, @@ -51,9 +51,9 @@ impl XousDisplay { // 1000 * 1000 / MAX_FPS, // ))); - let native_buffer = vec![DARK_COLOUR; WIDTH * HEIGHT]; + let native_buffer = vec![DARK_COLOUR; WIDTH as usize * HEIGHT as usize]; window - .update_with_buffer(&native_buffer, WIDTH, HEIGHT) + .update_with_buffer(&native_buffer, WIDTH as usize, HEIGHT as usize) .unwrap(); let xns = xous_names::XousNames::new().unwrap(); @@ -102,7 +102,7 @@ impl XousDisplay { pub fn redraw(&mut self) { self.emulated_to_native(); self.window - .update_with_buffer(&self.native_buffer, WIDTH, HEIGHT) + .update_with_buffer(&self.native_buffer, WIDTH as usize, HEIGHT as usize) .unwrap(); } diff --git a/services/graphics-server/src/blitstr2.rs b/services/graphics-server/src/blitstr2.rs index c34d5cf40..ccffdbc30 100644 --- a/services/graphics-server/src/blitstr2.rs +++ b/services/graphics-server/src/blitstr2.rs @@ -5,10 +5,10 @@ pub use cliprect::*; pub(crate) mod fonts; pub(crate) use fonts::*; -const LINES: usize = crate::backend::FB_LINES; -const WIDTH: usize = crate::backend::FB_WIDTH_PIXELS; +const LINES: i16 = crate::backend::FB_LINES as i16; +const WIDTH: i16 = crate::backend::FB_WIDTH_PIXELS as i16; const WORDS_PER_LINE: usize = crate::backend::FB_WIDTH_WORDS; -pub type FrBuf = [u32; WORDS_PER_LINE * LINES]; +pub type FrBuf = [u32; WORDS_PER_LINE * LINES as usize]; // add more fonts (an example): // https://github.com/samblenny/blitstr2/commit/bb7d4ab6a2d8913dcb520895a3c242c933413aae \ No newline at end of file diff --git a/services/graphics-server/src/blitstr2/cliprect.rs b/services/graphics-server/src/blitstr2/cliprect.rs index beef38933..08083771c 100644 --- a/services/graphics-server/src/blitstr2/cliprect.rs +++ b/services/graphics-server/src/blitstr2/cliprect.rs @@ -17,7 +17,7 @@ pub struct ClipRect { #[allow(dead_code)] impl ClipRect { /// Initialize a rectangle using automatic min/max fixup for corner points - pub fn new(min_x: usize, min_y: usize, max_x: usize, max_y: usize) -> ClipRect { + pub fn new(min_x: i16, min_y: i16, max_x: i16, max_y: i16) -> ClipRect { // Make sure min_x <= max_x && min_y <= max_y let mut min = Pt { x: min_x, y: min_y }; let mut max = Pt { x: max_x, y: max_y }; diff --git a/services/graphics-server/src/main.rs b/services/graphics-server/src/main.rs index 6f0be4059..150c450c4 100644 --- a/services/graphics-server/src/main.rs +++ b/services/graphics-server/src/main.rs @@ -230,15 +230,15 @@ fn xmain() -> ! { let typeset_extent = match tv.bounds_hint { TextBounds::BoundingBox(r) => - Pt::new((r.br().x - r.tl().x - tv.margin.x * 2) as usize, (r.br().y - r.tl().y - tv.margin.y * 2) as usize), + Pt::new(r.br().x - r.tl().x - tv.margin.x * 2, r.br().y - r.tl().y - tv.margin.y * 2), TextBounds::GrowableFromBr(br, width) => - Pt::new(width as usize - tv.margin.x as usize * 2, br.y as usize - tv.margin.y as usize * 2), + Pt::new(width as i16 - tv.margin.x * 2, br.y - tv.margin.y * 2), TextBounds::GrowableFromBl(bl, width) => - Pt::new(width as usize - tv.margin.x as usize * 2, bl.y as usize - tv.margin.y as usize * 2), + Pt::new(width as i16 - tv.margin.x * 2, bl.y - tv.margin.y * 2), TextBounds::GrowableFromTl(tl, width) => - Pt::new(width as usize - tv.margin.x as usize * 2, (clip_rect.br().y - clip_rect.tl().y - tl.y) as usize - tv.margin.y as usize * 2), + Pt::new(width as i16 - tv.margin.x * 2, (clip_rect.br().y - clip_rect.tl().y - tl.y) - tv.margin.y * 2), TextBounds::GrowableFromTr(tr, width) => - Pt::new(width as usize - tv.margin.x as usize * 2, (clip_rect.br().y - clip_rect.tl().y - tr.y) as usize - tv.margin.y as usize * 2), + Pt::new(width as i16 - tv.margin.x * 2, (clip_rect.br().y - clip_rect.tl().y - tr.y) - tv.margin.y * 2), }; let mut typesetter = Typesetter::setup( tv.to_str(), diff --git a/services/graphics-server/src/wordwrap.rs b/services/graphics-server/src/wordwrap.rs index ebe7916ae..db89e4105 100644 --- a/services/graphics-server/src/wordwrap.rs +++ b/services/graphics-server/src/wordwrap.rs @@ -46,21 +46,21 @@ impl TypesetWord { TypesetWord { gs: vec![gs], origin, - width: gs.wide as usize, - height: gs.high as usize, + width: gs.wide as i16, + height: gs.high as i16, non_drawable: false, strpos, } } pub fn push(&mut self, gs: GlyphSprite) { - self.width += (gs.wide + gs.kern) as usize; - self.height = self.height.max(gs.high as usize); + self.width += (gs.wide + gs.kern) as i16; + self.height = self.height.max(gs.high as i16); self.gs.push(gs); } /// if the pop is invalid, we'll return an invalid character. Just...don't do that. k? pub fn pop(&mut self) -> GlyphSprite { let gs = self.gs.pop().unwrap_or(NULL_GLYPH_SPRITE); - self.width -= (gs.wide + gs.kern) as usize; + self.width -= (gs.wide + gs.kern) as i16; // we can't undo any height transformations, unfortunately, because we don't know what the previous state was // but it's fairly minor if text is set funny on a line because text overflowed and had e.g. emoji buried amongst // small font text... @@ -102,10 +102,10 @@ impl ComposedType { cursor, } } - pub fn bb_width(&self) -> usize { + pub fn bb_width(&self) -> i16 { self.bounding_box.max.x - self.bounding_box.min.x } - pub fn bb_height(&self) -> usize { + pub fn bb_height(&self) -> i16 { self.bounding_box.max.y - self.bounding_box.min.y } /// Note: it is up to the caller to ensure that clip_rect is within the renderable screen area. We do no @@ -132,14 +132,14 @@ impl ComposedType { log::trace!("not renderable maybe_y: {}, {:?}", maybe_y, clip_rect); renderable = false; } - point.x += (glyph.wide + glyph.kern) as usize; // keep scorekeeping on this, because it could eventually become renderable + point.x += (glyph.wide + glyph.kern) as i16; // keep scorekeeping on this, because it could eventually become renderable if !renderable { // quickly short circuit over any text that is definitely outside of our clipping rectangle continue; } else { let cr = ClipRect::new( - clip_rect.tl().x as usize, clip_rect.tl().y as usize, - clip_rect.br().x as usize, clip_rect.br().y as usize + clip_rect.tl().x, clip_rect.tl().y, + clip_rect.br().x, clip_rect.br().y ); if !glyph.double { blitstr2::xor_glyph( @@ -211,7 +211,7 @@ pub(crate) struct Typesetter { s: String, base_style: GlyphStyle, overflow: bool, - max_width: usize, + max_width: i16, last_line_height: usize, // scorecarding for the very last line on the loop exit } impl Typesetter { @@ -261,7 +261,7 @@ impl Typesetter { // going out of scope at the end of the call. let mut composition = Vec::::new(); - if self.bb.max.x - self.bb.min.y < glyph_to_height_hint(GlyphStyle::Regular) { + if self.bb.max.x - self.bb.min.y < glyph_to_height_hint(GlyphStyle::Regular) as i16 { // we flag this because the typesetter algorithm may never converge if it can't set any characters // because the region is just too narrow. log::error!("Words cannot be typset because the width of the typset region is too narrow."); @@ -420,7 +420,7 @@ impl Typesetter { let ret = ComposedType::new(composition, ClipRect::new( self.bb.min.x, self.bb.min.y, - self.max_width, self.cursor.pt.y + self.last_line_height, + self.max_width as i16, self.cursor.pt.y + self.last_line_height as i16, ), self.cursor ); @@ -439,12 +439,12 @@ impl Typesetter { fn is_newline_available(&self) -> bool { // repeated, bare newlines will have a candidate height of 0, as it contains no glyphs. correct for that. let corrected_height = if self.candidate.height == 0 { - self.cursor.line_height + self.cursor.line_height as i16 } else { self.candidate.height }; - log::trace!("{} < {}", corrected_height + self.cursor.pt.y + self.cursor.line_height, self.bb.max.y); - corrected_height + self.cursor.pt.y + self.cursor.line_height < self.bb.max.y + log::trace!("{} < {}", corrected_height + self.cursor.pt.y + self.cursor.line_height as i16, self.bb.max.y); + corrected_height + self.cursor.pt.y + (self.cursor.line_height as i16) < self.bb.max.y } fn does_word_fit_on_line(&self) -> bool { self.candidate.width + self.cursor.pt.x < self.bb.max.x @@ -467,7 +467,7 @@ impl Typesetter { if !self.candidate.non_drawable { // this is mainly for "non-drawable spaces" at the beginning of a line self.max_width = self.max_width.max(self.candidate.width + self.candidate.origin.x); self.cursor.pt.x += self.candidate.width; - self.cursor.line_height = self.cursor.line_height.max(self.candidate.height); + self.cursor.line_height = self.cursor.line_height.max(self.candidate.height as usize); self.last_line_height = self.cursor.line_height; } if false {tsw_debug(&self.candidate)}; @@ -493,9 +493,9 @@ impl Typesetter { fn move_candidate_to_newline(&mut self) { // advance the rendering line, without inserting a newline placeholder self.last_line_height = self.cursor.line_height; - self.cursor.pt.y += self.cursor.line_height; + self.cursor.pt.y += self.cursor.line_height as i16; self.cursor.pt.x = self.bb.min.x; - self.cursor.line_height = self.candidate.height; + self.cursor.line_height = self.candidate.height as usize; // now set the current candidate word's origin to the beginning of this new line self.candidate.origin = self.cursor.pt; } @@ -524,7 +524,7 @@ impl Typesetter { /// set to our space point, because the caller will have already stashed the previously formed word fn try_append_space(&mut self, composition: &mut Vec::) -> bool { assert!(self.candidate.gs.len() == 0, "self.candidate was not set to a new state prior to this call"); - if (self.cursor.pt.x + self.space.wide as usize) < self.bb.max.x { + if (self.cursor.pt.x + self.space.wide as i16) < self.bb.max.x { // our candidate word is "just as space" let mut candidate_space = self.space.clone(); if self.is_insert_point() {