Skip to content
Browse files

On wrapped text, set the text to the wrapped variant to ensure charac…

…ter length consistency.
  • Loading branch information...
Shinmera committed Jul 11, 2019
1 parent 4689fa4 commit c5c5d930c54dd72059f3a03a984c9210309f38b2
Showing with 5 additions and 3 deletions.
  1. +5 −3 text.lisp
@@ -98,7 +98,7 @@ void main(){
(when (wrap text)
(setf (text text) (text text))))

(defmethod (setf text) :before ((string string) (text text))
(defmethod (setf text) :around ((string string) (text text))
(let ((vao (vertex-array text))
(vbo (slot-value text 'vbo))
(ebo (slot-value text 'ebo))
@@ -109,12 +109,14 @@ void main(){
(if (wrap text)
(multiple-value-bind (string height) (wrap-text font string (* (width text) s))
(setf (height text) (/ height s))
(setf (size vao) (cl-fond:update-text font string (gl-name vbo) (gl-name ebo))))
(setf (size vao) (cl-fond:update-text font string (gl-name vbo) (gl-name ebo)))
(call-next-method string text))
(destructuring-bind (&key l r ((:t u)) b gap) (text-extent font string)
(declare (ignore gap))
(setf (width text) (/ (+ l r) s))
(setf (height text) (/ (- u b) s))
(setf (size vao) (cl-fond:update-text font string (gl-name vbo) (gl-name ebo)))))))))
(setf (size vao) (cl-fond:update-text font string (gl-name vbo) (gl-name ebo)))
(call-next-method string text)))))))

(defmethod extent ((text text))
(text-extent text (text text)))

0 comments on commit c5c5d93

Please sign in to comment.
You can’t perform that action at this time.