Save modified characters in project data

This commit is contained in:
mrkubax10 2024-03-02 22:21:48 +01:00
parent 0a3be7ef55
commit cde9c3485f
2 changed files with 28 additions and 3 deletions

View File

@ -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()

View File

@ -1,6 +1,4 @@
import os
import numpy as np
import cli_ui
import unicodedata
from exporter import export