Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sdl2: add scaled-char-{width,height} methods to display
These methods take a raw (x,y) input (in pixels) from sdl2 and multiply
it by the dpi scale (usually 2 for retina screens, otherwise 1) and then
multiply that by the char-{width,height}.
  • Loading branch information
seanfarley committed Jul 7, 2023
commit 280adee73511d6f639f3ac6c084d4e2bca3aa4f2
8 changes: 8 additions & 0 deletions frontends/sdl2/main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@
(display-latin-font display)
(display-cjk-normal-font display)))))

(defmethod scaled-char-width ((display display) x)
(let ((scale-x (round (first (display-scale display)))))
(floor (* scale-x x) (char-width))))

(defmethod scaled-char-height ((display display) y)
(let ((scale-y (round (second (display-scale display)))))
(floor (* scale-y y) (char-height))))

(defmethod update-display ((display display))
(sdl2:render-present (display-renderer display)))

Expand Down