]> git.jsancho.org Git - gacela.git/blobdiff - gacela_ttf.lisp
(no commit message)
[gacela.git] / gacela_ttf.lisp
index 0077ad42aa4c372cb5056bf9e9132c387199e9d6..3cb84932e975b4303fcd72dbb52cd85e69897eff 100644 (file)
 
 (in-package :gacela)
 
-(defun open-font (font-file &key (size 80) (encoding ft_encoding_unicode) static)
+(defun load-font (font-file &key (size 80) (encoding ft_encoding_unicode) static)
   (let ((key (make-resource-font :filename font-file :size size :encoding encoding)))
     (cond ((get-resource key) key)
-         (t
-          (let ((font (ftglCreateTextureFont font-file)))
-            (cond ((/= font 0)
-                   (ftglSetFontFaceSize font size 72)
-                   (ftglSetFontCharMap font encoding)
-                   (set-resource key
-                                 `(:id-font ,font)
-                                 (lambda () (open-font font-file :size size :encoding encoding :static static))
-                                 (lambda () (ftglDestroyFont font))
-                                 :static static)
-                   key)))))))
+         (t (true-load-font font-file size encoding static)))))
+
+(defun true-load-font (font-file size encoding static)
+  (let ((key (make-resource-font :filename font-file :size size :encoding encoding))
+       (font (ftglCreateTextureFont font-file)))
+    (cond ((/= font 0)
+          (ftglSetFontFaceSize font size 72)
+          (ftglSetFontCharMap font encoding)
+          (set-resource key
+                        `(:id-font ,font)
+                        (lambda () (true-load-font font-file size encoding static))
+                        (lambda () (ftglDestroyFont font))
+                        :static static)
+          key))))
 
 (defun render-text (text font)
-  (ftglRenderFont (getf font :id-font) text FTGL_RENDER_ALL))
+  (ftglRenderFont (getf (get-resource font) :id-font) text FTGL_RENDER_ALL))