Browse files

Oversample fonts by 2, add text-extent method.

  • Loading branch information...
Shinmera committed Dec 17, 2017
1 parent 3351bbb commit 51c97c59d06de31d73ff6bf8f002565745423cf9
Showing with 11 additions and 3 deletions.
  1. +10 −3 assets/font.lisp
  2. +1 −0 package.lisp
@@ -35,9 +35,13 @@
(setf (resource asset)
(cl-fond:make-font (first (coerced-inputs asset))
(charset asset)
:size (size asset)))
:size (size asset)
:oversample 2))
(v:debug :trial.asset "Loaded font ~a" (first (coerced-inputs asset))))
(defmethod text-extent ((font font) text)
(cl-fond:compute-extent (resource font) text))
(define-shader-entity text (asset located-entity)
((font :initarg :font :accessor font)
(text :initarg :text :accessor text)
@@ -125,7 +129,10 @@ void main(){
(defmethod extent ((entity text))
(if (resource (font entity))
(cl-fond:compute-extent (resource (font entity))
(text entity))
(text-extent entity (text entity))
'(:l 0 :r 0 :t 0 :b 0 :gap 0)))
(defmethod text-extent ((entity text) text)
(destructuring-bind (&key l r ((:t u)) b gap) (text-extent (font entity) text)
(let ((s (/ (size entity) (size (font entity)))))
(list :l (* l s) :r (* r s) :t (* u s) :b (* b s) :gap (* gap s)))))
@@ -589,6 +589,7 @@

0 comments on commit 51c97c5

Please sign in to comment.