diff options
-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) |