summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-01-11 08:43:12 -0500
committerDavid Thompson <dthompson2@worcester.edu>2016-01-12 08:38:51 -0500
commit39841de819a9c92ac5622a7caab66fd6fa31b533 (patch)
tree5ed01e411f2ddd7da2ec192280d8e62e42559021
parent15c54d58064d825cf71507baa05269d03a21caa3 (diff)
render: font: Add support for non-blended font rendering.
* sly/render/font.scm (render-text): Add 'blended?' argument. (make-label): Add #:blended? keyword argument.
-rw-r--r--sly/render/font.scm12
1 files changed, 8 insertions, 4 deletions
diff --git a/sly/render/font.scm b/sly/render/font.scm
index f9d1a91..1312168 100644
--- a/sly/render/font.scm
+++ b/sly/render/font.scm
@@ -69,15 +69,19 @@ argument with a default value of 12."
(define %sdl-white (sdl2:make-color 255 255 255 255))
-(define (render-text font text)
+(define (render-text font text blended?)
"Return a new texture with TEXT rendered using FONT."
;; An empty string will result in a surface value of #f, in which
;; case we want to abort the texture creation process.
- (let ((surface (sdl2:render-font-blended (font-ttf font) text %sdl-white)))
+ (let ((surface ((if blended?
+ sdl2:render-font-blended
+ sdl2:render-font-solid)
+ (font-ttf font)
+ text %sdl-white)))
((@@ (sly render texture) surface->texture) surface 'linear 'linear)))
-(define* (make-label font text #:key (anchor 'top-left))
+(define* (make-label font text #:key (anchor 'top-left) (blended? #t))
"Create a sprite that displays TEXT rendered using FONT. ANCHOR
defines the sprite's origin, which is 'top-left' by default."
- (let ((texture (render-text font text)))
+ (let ((texture (render-text font text blended?)))
(make-sprite texture #:anchor anchor)))