diff options
author | David Thompson <dthompson2@worcester.edu> | 2020-05-12 14:39:20 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2020-05-12 14:39:20 -0400 |
commit | 0cf4e680bb5d72a58df86b989a3b10c1c0ec4d23 (patch) | |
tree | 73dcd99e1271e108f30eff8376c6dc725621b17c /sdl2/ttf.scm | |
parent | dae8466030776f9e3afa851122705baaf09071a9 (diff) |
ttf: Add TTF_GlyphMetrics binding.
Thanks to Gerry Agbobada for requesting this and sending an initial
patch.
Diffstat (limited to 'sdl2/ttf.scm')
-rw-r--r-- | sdl2/ttf.scm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sdl2/ttf.scm b/sdl2/ttf.scm index 4c4d3be..0a73b8a 100644 --- a/sdl2/ttf.scm +++ b/sdl2/ttf.scm @@ -71,6 +71,20 @@ size is POINT-SIZE." "Return the maximum height of FONT." (ffi:ttf-font-height (unwrap-font font))) +(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)" + (let ((bv (make-s32vector 5))) + (if (zero? (ffi:ttf-glyph-metrics (unwrap-font font) + (char->integer char) + (bytevector->pointer bv) + (bytevector->pointer bv 4) + (bytevector->pointer bv 8) + (bytevector->pointer bv 16) + (bytevector->pointer bv 32))) + (s32vector->list bv) + (sdl-error "font-glyph-metrics" "failed to get glyph metrics")))) + (define (render-font-solid font text color) "Render TEXT, a UTF-8 encoded string, using FONT and COLOR, the foreground color, and return a surface containing the results." |