Skip to content

Commit

Permalink
Match the size of emoji with normal text
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Aug 2, 2023
1 parent 777d0d6 commit 33c0528
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions frontends/sdl2/text-buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@
(defclass text-object (drawing-object)
((surface :initarg :surface :reader text-object-surface)
(string :initarg :string :reader text-object-string)
(attribute :initarg :attribute :reader text-object-attribute)))
(attribute :initarg :attribute :reader text-object-attribute)
(type :initarg :type :reader text-object-type)))

(defclass eol-cursor-object (drawing-object)
((color :initarg :color
Expand Down Expand Up @@ -370,7 +371,9 @@
0)

(defmethod object-width ((drawing-object text-object))
(sdl2:surface-width (text-object-surface drawing-object)))
(if (eq :emoji (text-object-type drawing-object))
(* (char-width) 2 (length (text-object-string drawing-object)))
(sdl2:surface-width (text-object-surface drawing-object))))

(defmethod object-width ((drawing-object eol-cursor-object))
0)
Expand All @@ -390,7 +393,9 @@
(char-height))

(defmethod object-height ((drawing-object text-object))
(sdl2:surface-height (text-object-surface drawing-object)))
(if (eq :emoji (text-object-type drawing-object))
(char-height)
(sdl2:surface-height (text-object-surface drawing-object))))

(defmethod object-height ((drawing-object eol-cursor-object))
(char-height))
Expand Down Expand Up @@ -451,7 +456,8 @@
:offset (line-end-item-offset item)
:surface surface
:string string
:attribute attribute)))))
:attribute attribute
:type type)))))
(t
(let ((string (item-string item))
(attribute (item-attribute item)))
Expand All @@ -471,7 +477,8 @@
(make-instance 'text-object
:surface surface
:string string
:attribute attribute)))))))))
:attribute attribute
:type type)))))))))

(defun clear-to-end-of-line (window x y height)
(sdl2:with-rects ((rect x y (- (view-width-by-pixel window) x) height))
Expand All @@ -488,12 +495,13 @@

(defun make-letter-object (character attribute)
(let* ((bold (and attribute (lem:attribute-bold attribute)))
(foreground (attribute-foreground-with-reverse attribute)))
(foreground (attribute-foreground-with-reverse attribute))
(type (char-type character)))
(cffi:with-foreign-string (c-string (string character))
(let ((surface
(sdl2-ttf:render-utf8-blended
(get-font :attribute attribute
:type (char-type character)
:type type
:bold bold)
c-string
(lem:color-red foreground)
Expand All @@ -503,7 +511,8 @@
(make-instance 'text-object
:surface surface
:string (string character)
:attribute attribute)))))
:attribute attribute
:type type)))))


(defun explode-object (text-object)
Expand Down

0 comments on commit 33c0528

Please sign in to comment.