cl-rw

Layered streams for Common Lisp
git clone https://logand.com/git/cl-rw.git/
Log | Files | Refs

commit 7eaac7306d96b79b44e3b41f106d82aa56d922e1
parent 91891d4730ba570540d106be1f44f11d867780ad
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun,  6 Dec 2015 09:23:50 +0100

unicode-bitmaps in framebuffer

Diffstat:
Mfb.lisp | 36++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/fb.lisp b/fb.lisp @@ -41,17 +41,31 @@ ;; rgba 8/16,8/8,8/0,0/0 ;; endmode +(defun unicode-bitmaps (psf2) + (let* ((bitmaps (rw.psf::psf2-bitmaps psf2)) + (unicode (rw.psf::psf2-unicode psf2)) + (z (make-hash-table))) + (assert (= 256 (length bitmaps) (length unicode))) + (dotimes (i 256 z) + (dolist (c (rw:till (rw:peek-reader + (rw:utf8-reader (rw:reader (pop unicode)))))) + (setf (gethash (code-char c) z) + (aref bitmaps i)))))) + +;;(unicode-bitmaps (rw.psf::load-font "/nix/store/3jzf1724gfkg942i8dbg0ixdncsv0qhf-kbd-2.0.3/share/consolefonts/Lat2-Terminus16.psfu.gz")) + (defun make-canvas (stream screen-width screen-height) (declare (type fixnum screen-width screen-height)) - (let ((buffer (make-array (* 4 screen-width screen-height) - :element-type '(unsigned-byte 8) - :initial-element 0)) - (font (rw.psf::load-font - ;;"/nix/store/sxrgxk6bw27c516zdvjh2mr6nk4hl9ni-terminus-font-4.39/share/consolefonts/ter-g28n.psf.gz" - ;;"/nix/store/sxrgxk6bw27c516zdvjh2mr6nk4hl9ni-terminus-font-4.39/share/consolefonts/ter-g28b.psf.gz" - ;;"/nix/store/3jzf1724gfkg942i8dbg0ixdncsv0qhf-kbd-2.0.3/share/consolefonts/default8x16.psfu.gz" - "/nix/store/3jzf1724gfkg942i8dbg0ixdncsv0qhf-kbd-2.0.3/share/consolefonts/Lat2-Terminus16.psfu.gz" - ))) + (let* ((buffer (make-array (* 4 screen-width screen-height) + :element-type '(unsigned-byte 8) + :initial-element 0)) + (font (rw.psf::load-font + ;;"/nix/store/sxrgxk6bw27c516zdvjh2mr6nk4hl9ni-terminus-font-4.39/share/consolefonts/ter-g28n.psf.gz" + ;;"/nix/store/sxrgxk6bw27c516zdvjh2mr6nk4hl9ni-terminus-font-4.39/share/consolefonts/ter-g28b.psf.gz" + ;;"/nix/store/3jzf1724gfkg942i8dbg0ixdncsv0qhf-kbd-2.0.3/share/consolefonts/default8x16.psfu.gz" + "/nix/store/3jzf1724gfkg942i8dbg0ixdncsv0qhf-kbd-2.0.3/share/consolefonts/Lat2-Terminus16.psfu.gz" + )) + (unicode-bitmaps (unicode-bitmaps font))) (lambda (form) (let ((*x* 0) (*y* 0) @@ -105,6 +119,8 @@ (pixel x y *ba* *br* *bg* *bb*) (pixel x y *fa* *fr* *fg* *fb*))))) (chara (c) + (bitmap (gethash c unicode-bitmaps)) + #+nil (let ((n (char-code c))) (if (<= 1 n #x7f) (bitmap (aref (rw.psf::psf2-bitmaps font) n)) @@ -240,6 +256,7 @@ *y* y) (mapc #'rec b)))))))) (rec form))) + (file-position stream 0) (write-sequence buffer stream)))) (defun test (&key (device "/dev/fb0") (width 1376 #+nil 1366) (height 768)) @@ -270,7 +287,6 @@ ((:text :x 250 :y 150 :font-family "Verdana" :font-size 55) "This is a SVG text element.") (:font-preview))))) - (file-position s 0) (funcall fb "hi"))) (values))