From cde9c3485fa47e09fe3f647750cfccf183a09125 Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sat, 2 Mar 2024 22:21:48 +0100 Subject: [PATCH] Save modified characters in project data --- canvas.py | 29 ++++++++++++++++++++++++++++- main.py | 2 -- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/canvas.py b/canvas.py index f1380e5..9ade050 100644 --- a/canvas.py +++ b/canvas.py @@ -68,10 +68,36 @@ class EditorCanvas(tkinter.Canvas): def save_char(self): - pass + if not self.current_char_modified: + return + + empty=True + for x in range(len(self.current_char_pixels)): + if self.current_char_pixels[x]>0: + empty=False + break + if empty: + if self.project.does_char_exist(self.current_char): + del(self.project.chars[chr(self.current_char)]) + return + + packed_data=[] + bit_counter=0 + current_value=0 + for pixel in self.current_char_pixels: + current_value|=pixel + if bit_counter==8: + packed_data.append(current_value) + bit_counter=0 + current_value=0 + current_value<<=1 + bit_counter+=1 + + self.project.chars[chr(self.current_char)]=base64.b64encode(bytes(packed_data)).decode("ascii") def prev_glyph(self): + self.save_char() self.current_char-=1 self.keep_current_char_in_bounds() self.load_char() @@ -79,6 +105,7 @@ class EditorCanvas(tkinter.Canvas): def next_glyph(self): + self.save_char() self.current_char+=1 self.keep_current_char_in_bounds() self.load_char() diff --git a/main.py b/main.py index 184476d..b2eec11 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,4 @@ import os -import numpy as np -import cli_ui import unicodedata from exporter import export