From 9a2690d9dfe91604f67f2de09d4f3b316f7db6f4 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 27 Dec 2022 15:53:46 -0500 Subject: graphics: text: Add #:smooth? keyword argument to make-texture. --- chickadee/graphics/text.scm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chickadee/graphics/text.scm b/chickadee/graphics/text.scm index 8235242..ca33cb7 100644 --- a/chickadee/graphics/text.scm +++ b/chickadee/graphics/text.scm @@ -136,9 +136,12 @@ (define freetype-handle (delay (init-freetype))) -(define* (load-font file-name point-size #:key (char-set char-set:ascii)) +(define* (load-font file-name point-size #:key (char-set char-set:ascii) (smooth? #t)) "Load all the glyphs in CHAR-SET from the font in FILE-NAME and -display it at POINT-SIZE. By default, the ASCII character is used." +display it at POINT-SIZE. By default, the ASCII character is used. +If SMOOTH? is #t (the default), text rendered with this font will have +a smoother appearance when text is rotated or scaled, otherwise +non-smooth scaling will be used." (unless (file-exists? file-name) (error "no such file" file-name)) (let ((face (load-face (force freetype-handle) file-name)) @@ -193,8 +196,11 @@ display it at POINT-SIZE. By default, the ASCII character is used." prev))))))) '() char-set)) + (texture-filter (if smooth? 'linear 'nearest)) ;; TODO: Use multiple textures if needed. - (texture (make-texture pixels texture-size texture-size))) + (texture (make-texture pixels texture-size texture-size + #:min-filter texture-filter + #:mag-filter texture-filter))) ;; Process kernings. (char-set-for-each (lambda (left) -- cgit v1.2.3