-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext.lisp
More file actions
28 lines (23 loc) · 1.61 KB
/
text.lisp
File metadata and controls
28 lines (23 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(in-package :lambda)
;;; FFI
(cffi:defcfun ("lambda_text_create" make-text) :uint32 (font-size :number))
(cffi:defcfun ("lambda_text_destroy" text-destroy) :void (id :uint32))
(cffi:defcfun ("lambda_text_set" %text-set) :void (id :uint32) (ptr :pointer) (len :uint32))
(cffi:defcfun ("lambda_text_position" text-position) :void (id :uint32) (x :number) (y :number))
(cffi:defcfun ("lambda_text_bounds" text-bounds) :void (id :uint32) (left :int32) (top :int32) (right :int32) (bottom :int32))
(cffi:defcfun ("lambda_text_color" text-color) :void (id :uint32) (rgba :uint32))
(cffi:defcfun ("lambda_text_metrics" text-metrics) :void (id :uint32) (font-size :number) (line-height :number))
(cffi:defcfun ("lambda_text_weight" text-weight) :void (id :uint32) (weight :uint32))
(cffi:defcfun ("lambda_text_family" %text-family) :void (id :uint32) (ptr :pointer) (len :uint32))
(cffi:defcfun ("lambda_text_font_size" text-font-size) :void (id :uint32) (font-size :number))
(cffi:defcfun ("lambda_text_width" text-width) :float (id :uint32))
(cffi:defcfun ("lambda_text_height" text-height) :float (id :uint32))
(defparameter *default-font* "Inter")
(defun text-set (id string)
(let ((octets (sb-ext:string-to-octets string :external-format :utf-8)))
(sb-sys:with-pinned-objects (octets)
(%text-set id (sb-sys:vector-sap octets) (length octets)))))
(defun text-family (id family)
(let ((octets (sb-ext:string-to-octets family :external-format :utf-8)))
(sb-sys:with-pinned-objects (octets)
(%text-family id (sb-sys:vector-sap octets) (length octets)))))