summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-12-05 13:07:08 -0500
committerDavid Thompson <dthompson2@worcester.edu>2020-12-05 13:07:08 -0500
commit7612713d904aee52c978e560158aa2c8cee949a7 (patch)
tree251c0aa4775dee1bec1f5a16c41861aa4cb34730
parentf4df3a7ac08bb6c50956bf27534d4f51423ec863 (diff)
ttf: Return multiple values instead of a list in font-glyph-metrics.
-rw-r--r--doc/api.texi5
-rw-r--r--sdl2/ttf.scm10
2 files changed, 9 insertions, 6 deletions
diff --git a/doc/api.texi b/doc/api.texi
index 7b19651..1abaa87 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -1569,9 +1569,8 @@ Return the index of the glyph for @var{char} in @var{font}, or
@end deffn
@deffn {Procedure} font-glyph-metrics font char
-Return a 5-element list containing the metrics of @var{char} in
-@var{font} in the following format: @code{(minx maxx miny maxy
-advance)}
+Return values for the metrics of @var{char} in @var{font}: min x, max
+x, min y, max y, and advance.
@end deffn
@deffn font-style font
diff --git a/sdl2/ttf.scm b/sdl2/ttf.scm
index b1345d6..e7eac6d 100644
--- a/sdl2/ttf.scm
+++ b/sdl2/ttf.scm
@@ -111,8 +111,8 @@ not present."
(if (eq? result 0) #f result)))
(define (font-glyph-metrics font char)
- "Return a 5-element list containing the metrics of CHAR in FONT in
-the following format: (minx maxx miny maxy advance)"
+ "Return 5 values for the metrics of CHAR in FONT: min x, max x, min y,
+max y, and advance."
(let ((bv (make-s32vector 5)))
(if (zero? (ffi:ttf-glyph-metrics (unwrap-font font)
(char->integer char)
@@ -121,7 +121,11 @@ the following format: (minx maxx miny maxy advance)"
(bytevector->pointer bv 8)
(bytevector->pointer bv 12)
(bytevector->pointer bv 16)))
- (s32vector->list bv)
+ (values (s32vector-ref bv 0)
+ (s32vector-ref bv 1)
+ (s32vector-ref bv 2)
+ (s32vector-ref bv 3)
+ (s32vector-ref bv 4))
(sdl-error "font-glyph-metrics" "failed to get glyph metrics"))))
(define (font-style font)