Skip to content

Commit 561e6e5

Browse files
committed
Allow fonts to be specified in attribute
1 parent 47c70ad commit 561e6e5

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

frontends/sdl2/text-buffer.lisp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@
358358
(defun char-type (char)
359359
(guess-font-type *display* (char-code char)))
360360

361+
(defun get-font (&key attribute type bold)
362+
(or (alexandria:if-let (attribute (and attribute (lem:ensure-attribute attribute)))
363+
(lem:attribute-value attribute 'font))
364+
(get-display-font *display* :type type :bold bold)))
365+
361366
(defun split-string-by-character-type (string)
362367
(loop :with pos := 0 :and items := '()
363368
:while (< pos (length string))
@@ -375,9 +380,9 @@
375380
(bold (and attribute (lem:attribute-bold attribute)))
376381
(foreground (attribute-foreground-with-reverse attribute))
377382
(surface
378-
(sdl2-ttf:render-utf8-blended (get-display-font *display*
379-
:type type
380-
:bold bold)
383+
(sdl2-ttf:render-utf8-blended (get-font :attribute attribute
384+
:type type
385+
:bold bold)
381386
c-string
382387
(lem:color-red foreground)
383388
(lem:color-green foreground)
@@ -436,9 +441,9 @@
436441
(cffi:with-foreign-string (c-string (string character))
437442
(let ((surface
438443
(sdl2-ttf:render-utf8-blended
439-
(get-display-font *display*
440-
:type (char-type character)
441-
:bold bold)
444+
(get-font :attribute attribute
445+
:type (char-type character)
446+
:bold bold)
442447
c-string
443448
(lem:color-red foreground)
444449
(lem:color-green foreground)

0 commit comments

Comments
 (0)