Skip to content

Commit 0603b04

Browse files
committed
GLGUI: fix typo and backward compatible dispatch prefering new code
1 parent 5b2fe7b commit 0603b04

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

modules/ln_glgui/primitives.scm

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,31 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
216216
;;; Reducing the computational complexity of font operations improves
217217
;;; rendering time.
218218

219+
(define-type ln-ttf:glyph
220+
macros: prefix: macro-
221+
desc ;; for now legacy: (key (texcoord1..4) X Y Z)
222+
width
223+
height
224+
texture
225+
texcoords ;; generic 4 element vector of flownums
226+
rect-texcoords ;; 4x2 element f32vector
227+
;; order is sorta important here
228+
offsetx
229+
advancex
230+
offsety
231+
)
232+
233+
(define (ttf:glyph? obj) (macro-ln-ttf:glyph? obj))
234+
(define (ttf:glyph-desc obj) (macro-ln-ttf:glyph-desc obj))
235+
(define (ttf:glyph-width obj) (macro-ln-ttf:glyph-width obj))
236+
(define (ttf:glyph-height obj) (macro-ln-ttf:glyph-height obj))
237+
(define (ttf:glyph-image obj) (macro-ln-ttf:glyph-texture obj))
238+
(define (ttf:glyph-texcoords obj) (macro-ln-ttf:glyph-texcoords obj))
239+
(define (ttf:glyph-rect-texcoords obj) (macro-ln-ttf:glyph-rect-texcoords obj))
240+
(define (ttf:glyph-offsetx obj) (macro-ln-ttf:glyph-offsetx obj))
241+
(define (ttf:glyph-advancex obj) (macro-ln-ttf:glyph-advancex obj))
242+
(define (ttf:glyph-offsety obj) (macro-ln-ttf:glyph-offsety obj))
243+
219244
(define-type ln-ttf:font
220245
macros: prefix: macro-
221246
desc ;; for now the legacy description of a font as a assoc-list
@@ -298,10 +323,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
298323
(loop (fl+ x0 gax) (cdr cs))))))
299324

300325
(define (glgui:fontheight fnt)
301-
(let* ((g (assoc 0 fnt))
302-
(i (if g (glgui:glyph-image g) #f))
303-
(h (if i (glgui:image-h i)
304-
(cadr (cadr (car fnt)))))) h))
326+
(cond
327+
((macro-ln-ttf:font? fnt) (ttf:glyph-height (MATURITY+1:ln-ttf:font-ref fnt 0)))
328+
((find-font fnt) => glgui:fontheight)
329+
(else ;; MATURITY -1 backward compatible, the old code
330+
(let* ((g (assoc 0 fnt))
331+
(i (if g (glgui:glyph-image g) #f))
332+
(h (if i (glgui:image-h i)
333+
(cadr (cadr (car fnt)))))) h))))
305334

306335
(define (glgui:stringheight txt fnt)
307336
(define font (find-font fnt))

0 commit comments

Comments
 (0)