from app.display.fonts.fonts_utils import align_font, font_height, char_width, screen_text
from app.display.neopixel_64x64 import NeoPixel_64x64
import app.utils as utils
from app.utils import colors


def font_pretty(font):
	pretty_font = align_font(font, debug=False)
	print(pretty_font)


def fonts_check(display: NeoPixel_64x64, font, pretty=False) -> None:
	display.clear()
	display.set_font(font)

	height = font_height(font)

	alphanum: str = ''.join(sorted(font.keys()))

	text_left = alphanum
	while text_left:
		# Text entsprechend des Display splitten
		scr_txt_dict = screen_text(text=text_left, screen_width=display.MATRIX_WIDTH, screen_height=display.MATRIX_HEIGHT, font=font)
		print(f'scr_txt: {scr_txt_dict}')

		display.clear()
		for idx, row_text in enumerate(scr_txt_dict['visible']):
			ypos = height * idx
			# display.clear_row(ypos)
			display.write_text(row_text, 0, ypos, colors.RAINBOW[idx % 6])

		text_left = scr_txt_dict['invisible']

	if pretty:
		font_pretty(font)
