From 58bbae89c2ef37232bc9a2aa2b1e21f1bde8e156 Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Thu, 2 Apr 2020 22:59:51 +0200
Subject: [PATCH] fix some bugs

---
 pwnagotchi/plugins/default/webcfg.py |  3 +--
 pwnagotchi/ui/fonts.py               | 14 +++++++-------
 pwnagotchi/ui/hw/papirus.py          |  2 +-
 pwnagotchi/ui/hw/waveshare1.py       |  4 ++--
 pwnagotchi/ui/hw/waveshare154inch.py |  2 +-
 pwnagotchi/ui/hw/waveshare2.py       |  4 ++--
 pwnagotchi/ui/hw/waveshare213bc.py   |  2 +-
 pwnagotchi/ui/hw/waveshare213d.py    |  2 +-
 pwnagotchi/ui/hw/waveshare27inch.py  |  2 +-
 pwnagotchi/ui/hw/waveshare29inch.py  |  2 +-
 10 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/pwnagotchi/plugins/default/webcfg.py b/pwnagotchi/plugins/default/webcfg.py
index c8f1e04..3907283 100644
--- a/pwnagotchi/plugins/default/webcfg.py
+++ b/pwnagotchi/plugins/default/webcfg.py
@@ -499,8 +499,7 @@ class WebConfig(plugins.Plugin):
         elif request.method == "POST":
             if path == "save-config":
                 try:
-                    parsed_toml = json.loads(request.get_json())
-                    save_config(parsed_toml, '/etc/pwnagotchi/config.toml')
+                    save_config(request.get_json(), '/etc/pwnagotchi/config.toml')
                     _thread.start_new_thread(restart, (self.mode,))
                     return "success"
                 except Exception as ex:
diff --git a/pwnagotchi/ui/fonts.py b/pwnagotchi/ui/fonts.py
index 52263b2..36f35ea 100644
--- a/pwnagotchi/ui/fonts.py
+++ b/pwnagotchi/ui/fonts.py
@@ -24,15 +24,15 @@ def init(config):
 
 def status_font(old_font):
     global STATUS_FONT_NAME, SIZE_OFFSET
-    return old_font.font_variant(font=STATUS_FONT_NAME, size=old_font.size + SIZE_OFFSET)
+    return ImageFont.truetype(STATUS_FONT_NAME, size=old_font.size + SIZE_OFFSET)
 
 
 def setup(bold, bold_small, medium, huge, bold_big, small):
     global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FONT_NAME
 
-    Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small)
-    Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium)
-    BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small)
-    Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold)
-    BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big)
-    Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge)
+    Small = ImageFont.truetype(FONT_NAME, small)
+    Medium = ImageFont.truetype(FONT_NAME, medium)
+    BoldSmall = ImageFont.truetype("%s-Bold" % FONT_NAME, bold_small)
+    Bold = ImageFont.truetype("%s-Bold" % FONT_NAME, bold)
+    BoldBig = ImageFont.truetype("%s-Bold" % FONT_NAME, bold_big)
+    Huge = ImageFont.truetype("%s-Bold" % FONT_NAME, huge)
diff --git a/pwnagotchi/ui/hw/papirus.py b/pwnagotchi/ui/hw/papirus.py
index 02004fe..44d0500 100644
--- a/pwnagotchi/ui/hw/papirus.py
+++ b/pwnagotchi/ui/hw/papirus.py
@@ -27,7 +27,7 @@ class Papirus(DisplayImpl):
         self._layout['mode'] = (175, 86)
         self._layout['status'] = {
             'pos': (85, 14),
-            'font': fonts.status_font(fonts.Medium)
+            'font': fonts.status_font(fonts.Medium),
             'max': 16
         }
         return self._layout
diff --git a/pwnagotchi/ui/hw/waveshare1.py b/pwnagotchi/ui/hw/waveshare1.py
index e1f64b9..4716fc4 100644
--- a/pwnagotchi/ui/hw/waveshare1.py
+++ b/pwnagotchi/ui/hw/waveshare1.py
@@ -27,7 +27,7 @@ class WaveshareV1(DisplayImpl):
             self._layout['mode'] = (225, 109)
             self._layout['status'] = {
                 'pos': (125, 20),
-                'font': fonts.status_font(fonts.Medium)
+                'font': fonts.status_font(fonts.Medium),
                 'max': 20
             }
         else:
@@ -47,7 +47,7 @@ class WaveshareV1(DisplayImpl):
             self._layout['mode'] = (187, 93)
             self._layout['status'] = {
                 'pos': (91, 15),
-                'font': fonts.status_font(fonts.Medium)
+                'font': fonts.status_font(fonts.Medium),
                 'max': 20
             }
         return self._layout
diff --git a/pwnagotchi/ui/hw/waveshare154inch.py b/pwnagotchi/ui/hw/waveshare154inch.py
index 0ff5610..a678121 100644
--- a/pwnagotchi/ui/hw/waveshare154inch.py
+++ b/pwnagotchi/ui/hw/waveshare154inch.py
@@ -26,7 +26,7 @@ class Waveshare154inch(DisplayImpl):
         self._layout['mode'] = (170, 187)
         self._layout['status'] = {
             'pos': (5, 90),
-            'font': fonts.status_font(fonts.Medium)
+            'font': fonts.status_font(fonts.Medium),
             'max': 20
         }
         return self._layout
diff --git a/pwnagotchi/ui/hw/waveshare2.py b/pwnagotchi/ui/hw/waveshare2.py
index 3c2ad27..fa00aaf 100644
--- a/pwnagotchi/ui/hw/waveshare2.py
+++ b/pwnagotchi/ui/hw/waveshare2.py
@@ -27,7 +27,7 @@ class WaveshareV2(DisplayImpl):
             self._layout['mode'] = (225, 109)
             self._layout['status'] = {
                 'pos': (125, 20),
-                'font': fonts.status_font(fonts.Medium)
+                'font': fonts.status_font(fonts.Medium),
                 'max': 20
             }
         else:
@@ -48,7 +48,7 @@ class WaveshareV2(DisplayImpl):
             self._layout['mode'] = (187, 93)
             self._layout['status'] = {
                 'pos': (125, 20),
-                'font': fonts.status_font(fonts.Medium)
+                'font': fonts.status_font(fonts.Medium),
                 'max': 14
             }
         return self._layout
diff --git a/pwnagotchi/ui/hw/waveshare213bc.py b/pwnagotchi/ui/hw/waveshare213bc.py
index d44cac4..f889c9b 100644
--- a/pwnagotchi/ui/hw/waveshare213bc.py
+++ b/pwnagotchi/ui/hw/waveshare213bc.py
@@ -26,7 +26,7 @@ class Waveshare213bc(DisplayImpl):
         self._layout['mode'] = (187, 93)
         self._layout['status'] = {
             'pos': (91, 15),
-            'font': fonts.status_font(fonts.Medium)
+            'font': fonts.status_font(fonts.Medium),
             'max': 20
         }
         return self._layout
diff --git a/pwnagotchi/ui/hw/waveshare213d.py b/pwnagotchi/ui/hw/waveshare213d.py
index a8e5d0f..0313081 100644
--- a/pwnagotchi/ui/hw/waveshare213d.py
+++ b/pwnagotchi/ui/hw/waveshare213d.py
@@ -26,7 +26,7 @@ class Waveshare213d(DisplayImpl):
         self._layout['mode'] = (187, 93)
         self._layout['status'] = {
             'pos': (91, 15),
-            'font': fonts.status_font(fonts.Medium)
+            'font': fonts.status_font(fonts.Medium),
             'max': 20
         }
         return self._layout
diff --git a/pwnagotchi/ui/hw/waveshare27inch.py b/pwnagotchi/ui/hw/waveshare27inch.py
index c3b04c5..29fbbbe 100644
--- a/pwnagotchi/ui/hw/waveshare27inch.py
+++ b/pwnagotchi/ui/hw/waveshare27inch.py
@@ -26,7 +26,7 @@ class Waveshare27inch(DisplayImpl):
         self._layout['mode'] = (239, 163)
         self._layout['status'] = {
             'pos': (38, 93),
-            'font': fonts.status_font(fonts.Medium)
+            'font': fonts.status_font(fonts.Medium),
             'max': 40
         }
         return self._layout
diff --git a/pwnagotchi/ui/hw/waveshare29inch.py b/pwnagotchi/ui/hw/waveshare29inch.py
index c52e047..2ae2b5a 100644
--- a/pwnagotchi/ui/hw/waveshare29inch.py
+++ b/pwnagotchi/ui/hw/waveshare29inch.py
@@ -26,7 +26,7 @@ class Waveshare29inch(DisplayImpl):
         self._layout['mode'] = (268, 114)
         self._layout['status'] = {
             'pos': (130, 25),
-            'font': fonts.status_font(fonts.Medium)
+            'font': fonts.status_font(fonts.Medium),
             'max': 28
         }
         return self._layout