From 5fbcae53d524f5e902b76292e418048e541d28c5 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 18 Oct 2022 21:04:29 -0400 Subject: graphics: text: Fix page size calculation. --- chickadee/graphics/text.scm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/chickadee/graphics/text.scm b/chickadee/graphics/text.scm index 42c6fa5..8235242 100644 --- a/chickadee/graphics/text.scm +++ b/chickadee/graphics/text.scm @@ -644,17 +644,25 @@ is not represented in FONT." (position (composited-glyph-position cglyph)) (offset (glyph-offset glyph)) (dimensions (glyph-dimensions glyph)) + (advance (glyph-advance glyph)) (texture (glyph-texture-region glyph)) + (x (vec2-x position)) + (y (- (vec2-y size) (vec2-y position))) ;; Not all glyphs have a visual representation, such as ;; the space character. (batch (and texture (page-batch page (texture-parent texture))))) - (set-rect-x! rect (+ (vec2-x position) (vec2-x offset))) - (set-rect-y! rect (+ (- (vec2-y size) (vec2-y position)) (vec2-y offset))) - (set-rect-width! rect (vec2-x dimensions)) + ;; Setup bounding box. + (set-rect-x! rect x) + (set-rect-y! rect y) + (set-rect-width! rect (vec2-x advance)) (set-rect-height! rect (vec2-y dimensions)) (rect-union! bb rect) ; expand bounding box to include this char (when batch + ;; Reuse rect for sprite dimensions. + (set-rect-x! rect (+ x (vec2-x offset))) + (set-rect-y! rect (+ y (vec2-y offset))) + (set-rect-width! rect (vec2-x dimensions)) (sprite-batch-add* batch rect (or (composited-glyph-matrix cglyph) %identity-matrix) -- cgit v1.2.3