diff options
author | David Thompson <dthompson2@worcester.edu> | 2022-10-18 21:04:29 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2022-10-18 21:04:49 -0400 |
commit | 5fbcae53d524f5e902b76292e418048e541d28c5 (patch) | |
tree | 8556d3a01cf7ae2d382defe6ce9d93d52ee79542 | |
parent | 2cddd1a22f12b27fe41454e9b71de63d22741c17 (diff) |
graphics: text: Fix page size calculation.
-rw-r--r-- | chickadee/graphics/text.scm | 14 |
1 files 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) |