summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2d/font.scm25
-rw-r--r--examples/font.scm2
2 files changed, 17 insertions, 10 deletions
diff --git a/2d/font.scm b/2d/font.scm
index 4e9d401..5cdc9cf 100644
--- a/2d/font.scm
+++ b/2d/font.scm
@@ -36,7 +36,8 @@
#:use-module (2d vector2)
#:use-module (2d window)
#:use-module (2d wrappers gl)
- #:export (load-font
+ #:export (enable-fonts
+ load-font
load-default-font
font?
font-point-size
@@ -48,12 +49,23 @@
label-color
draw-label))
-(SDL:ttf-init)
-
;;;
;;; Font
;;;
+(define font-shader #f)
+
+(define (enable-fonts)
+ (SDL:ttf-init)
+ (set! font-shader
+ (make-shader-program
+ (load-vertex-shader
+ (string-append %pkgdatadir
+ "/shaders/font-vertex.glsl"))
+ (load-fragment-shader
+ (string-append %pkgdatadir
+ "/shaders/font-fragment.glsl")))))
+
(define-record-type <font>
(make-font ttf point-size)
font?
@@ -131,13 +143,6 @@ white and ANCHOR with a default of 'top-left."
(anchor (anchor-texture texture anchor)))
(%make-label font text position anchor color texture vertices)))
-(define font-shader
- (make-shader-program
- (load-vertex-shader (string-append %pkgdatadir
- "/shaders/font-vertex.glsl"))
- (load-fragment-shader (string-append %pkgdatadir
- "/shaders/font-fragment.glsl"))))
-
(define (draw-label label)
"Draw LABEL on the screen."
(with-shader-program font-shader
diff --git a/examples/font.scm b/examples/font.scm
index a5167fa..a48bc37 100644
--- a/examples/font.scm
+++ b/examples/font.scm
@@ -27,6 +27,8 @@
(load "common.scm")
+(enable-fonts)
+
(define font (load-default-font 18))
(define label
(make-label font "The quick brown fox jumped over the lazy dog."