X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela_ttf.lisp;fp=gacela_ttf.lisp;h=f0e21a26babfcd9d8f3e7de6a034cae287f19c2e;hb=313f0f55db1767306751807b41bf3ca125909ea0;hp=3cb84932e975b4303fcd72dbb52cd85e69897eff;hpb=fdfb434956fca60457a18b4ab5cb0df067ec9a8b;p=gacela.git diff --git a/gacela_ttf.lisp b/gacela_ttf.lisp index 3cb8493..f0e21a2 100644 --- a/gacela_ttf.lisp +++ b/gacela_ttf.lisp @@ -16,23 +16,27 @@ (in-package :gacela) -(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) +(defun load-font (font-file &key (size 40) (encoding ft_encoding_unicode) static) + (let* ((key (make-resource-font :filename font-file :encoding encoding)) + (res (get-resource key))) + (cond (res (ftglSetFontFaceSize (getf res :id-font) size 72) + 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)) + (let ((key (make-resource-font :filename font-file :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 () (true-load-font font-file encoding static)) (lambda () (ftglDestroyFont font)) :static static) key)))) -(defun render-text (text font) - (ftglRenderFont (getf (get-resource font) :id-font) text FTGL_RENDER_ALL)) +(defun render-text (text font &key size) + (let ((id-font (getf (get-resource font) :id-font))) + (cond (size (ftglSetFontFaceSize id-font size 72))) + (ftglRenderFont id-font text FTGL_RENDER_ALL)))