712aef6ff9cb

Update BLT, add `(setf font)`
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 04 Jul 2017 17:49:09 +0000
parents 5fca83b35760
children 0b1557603235
branches/tags (none)
files package.lisp src/high-level/bearlibterminal.lisp src/low-level/bearlibterminal.lisp src/low-level/include/BearLibTerminal.h

Changes

--- a/package.lisp	Tue Jul 04 13:30:32 2017 +0000
+++ b/package.lisp	Tue Jul 04 17:49:09 2017 +0000
@@ -27,6 +27,7 @@
     :color-to-rgba
     :composition
     :crop
+    :font
     :has-input-p
     :height
     :hsva
--- a/src/high-level/bearlibterminal.lisp	Tue Jul 04 13:30:32 2017 +0000
+++ b/src/high-level/bearlibterminal.lisp	Tue Jul 04 17:49:09 2017 +0000
@@ -390,6 +390,13 @@
   new-value)
 
 
+(defun (setf font) (new-value)
+  (blt/ll:terminal-font-8 (if (null new-value)
+                            ""
+                            new-value))
+  new-value)
+
+
 (defun mouse-x ()
   (blt/ll:terminal-state blt/ll:+tk-mouse-x+))
 
--- a/src/low-level/bearlibterminal.lisp	Tue Jul 04 13:30:32 2017 +0000
+++ b/src/low-level/bearlibterminal.lisp	Tue Jul 04 17:49:09 2017 +0000
@@ -677,6 +677,21 @@
 
 (cl:export '#.(swig-lispify "terminal_composition" 'function))
 
+(cffi:defcfun ("terminal_font8" #.(swig-lispify "terminal_font8" 'function)) :void
+  (name :string))
+
+(cl:export '#.(swig-lispify "terminal_font8" 'function))
+
+(cffi:defcfun ("terminal_font16" #.(swig-lispify "terminal_font16" 'function)) :void
+  (name :pointer))
+
+(cl:export '#.(swig-lispify "terminal_font16" 'function))
+
+(cffi:defcfun ("terminal_font32" #.(swig-lispify "terminal_font32" 'function)) :void
+  (name :pointer))
+
+(cl:export '#.(swig-lispify "terminal_font32" 'function))
+
 (cffi:defcfun ("terminal_put" #.(swig-lispify "terminal_put" 'function)) :void
   (x :int)
   (y :int)
@@ -902,6 +917,16 @@
 
 (cl:export '#.(swig-lispify "terminal_wsetf" 'function))
 
+(cffi:defcfun ("terminal_font" #.(swig-lispify "terminal_font" 'function)) :void
+  (name :string))
+
+(cl:export '#.(swig-lispify "terminal_font" 'function))
+
+(cffi:defcfun ("terminal_wfont" #.(swig-lispify "terminal_wfont" 'function)) :void
+  (name :pointer))
+
+(cl:export '#.(swig-lispify "terminal_wfont" 'function))
+
 (cffi:defcfun ("terminal_print" #.(swig-lispify "terminal_print" 'function)) #.(swig-lispify "dimensions_t" 'classname)
   (x :int)
   (y :int)
--- a/src/low-level/include/BearLibTerminal.h	Tue Jul 04 13:30:32 2017 +0000
+++ b/src/low-level/include/BearLibTerminal.h	Tue Jul 04 17:49:09 2017 +0000
@@ -260,6 +260,9 @@
 TERMINAL_API void terminal_color(color_t color);
 TERMINAL_API void terminal_bkcolor(color_t color);
 TERMINAL_API void terminal_composition(int mode);
+TERMINAL_API void terminal_font8(const int8_t* name);
+TERMINAL_API void terminal_font16(const int16_t* name);
+TERMINAL_API void terminal_font32(const int32_t* name);
 TERMINAL_API void terminal_put(int x, int y, int code);
 TERMINAL_API void terminal_put_ext(int x, int y, int dx, int dy, int code, color_t* corners);
 TERMINAL_API int terminal_pick(int x, int y, int index);
@@ -441,6 +444,16 @@
 	TERMINAL_FORMATTED_WRAP(int, terminal_wset(terminal_vswprintf(s, args)))
 }
 
+TERMINAL_INLINE void terminal_font(const char* name)
+{
+	terminal_font8((const int8_t*)name);
+}
+
+TERMINAL_INLINE void terminal_wfont(const wchar_t* name)
+{
+	TERMINAL_CAT(terminal_font, TERMINAL_WCHAR_SUFFIX)((const TERMINAL_WCHAR_TYPE*)name);
+}
+
 TERMINAL_INLINE dimensions_t terminal_print(int x, int y, const char* s)
 {
 	dimensions_t ret;
@@ -602,6 +615,11 @@
 	terminal_bkcolor(color_from_wname(name));
 }
 
+TERMINAL_INLINE void terminal_font(const wchar_t* name)
+{
+	terminal_wfont(name);
+}
+
 TERMINAL_INLINE void terminal_put_ext(int x, int y, int dx, int dy, int code)
 {
 	terminal_put_ext(x, y, dx, dy, code, 0);