summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render/font.scm12
-rw-r--r--doc/api.texi4
2 files changed, 12 insertions, 4 deletions
diff --git a/chickadee/render/font.scm b/chickadee/render/font.scm
index 3654a13..d5995a2 100644
--- a/chickadee/render/font.scm
+++ b/chickadee/render/font.scm
@@ -311,7 +311,8 @@ extension must be either .xml or .fnt."
(define draw-text*
(let ((cursor (vec2 0.0 0.0))
(rect (make-rect 0.0 0.0 0.0 0.0)))
- (lambda* (font text matrix #:key (blend-mode 'alpha))
+ (lambda* (font text matrix #:key (blend-mode 'alpha)
+ (start 0) (end (string-length text)))
;; TODO: Respect kerning.
(define (render-char c)
;; TODO: What if "?" isn't in the font?
@@ -331,7 +332,7 @@ extension must be either .xml or .fnt."
(font-char-advance char))))))
(set-vec2-x! cursor 0.0)
(set-vec2-y! cursor 0.0)
- (string-for-each render-char text))))
+ (string-for-each render-char text start end))))
(define %default-scale (vec2 1.0 1.0))
(define %null-vec2 (vec2 0.0 0.0))
@@ -345,7 +346,9 @@ extension must be either .xml or .fnt."
(origin %null-vec2)
(rotation 0)
(scale %default-scale)
- (blend-mode 'alpha))
+ (blend-mode 'alpha)
+ (start 0)
+ (end (string-length text)))
"Draw the string TEXT with the first character starting at
POSITION using FONT."
(matrix4-2d-transform! matrix
@@ -353,4 +356,5 @@ POSITION using FONT."
#:position position
#:rotation rotation
#:scale scale)
- (draw-text* font text matrix #:blend-mode blend-mode))))
+ (draw-text* font text matrix #:blend-mode blend-mode
+ #:start start #:end end))))
diff --git a/doc/api.texi b/doc/api.texi
index 82cde8f..8295b38 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -892,6 +892,7 @@ Return @code{#t} if @var{font} is an italicized font.
@deffn {Procedure} draw-text @var{font} @var{text} @var{position}
[#:origin] [#:scale] [#:rotation] [#:blend-mode]
+ [#:start 0] [#:end @code{(string-length text)}]
Draw the string @var{text} with the first character starting at
@var{position} using @var{font}.
@@ -900,6 +901,9 @@ Draw the string @var{text} with the first character starting at
(draw-text font "Hello, world!" (vec2 128.0 128.0))
@end example
+To render a substring of @var{text}, use the @var{start} and @var{end}
+arguments.
+
Refer to @code{draw-sprite} (@pxref{Sprites}) for information about
the other arguments.
@end deffn