Closed lehrerhans closed 4 years ago
The font_to_py utility is not capable of rotating the glyph bitmap.
I am puzzled that you're using the device driver's set_frame_memory method to render the glyph. I suggest using the Writer class to render the glyph to the framebuf, then writing the underlying buffer to the device, as you do for your "Testing fonts" line. This is the way I use frame buffers and fonts.
Hello,
thanks for the fast answer. I did some programming to find a solution to rotate the fonts. I programmed with pygame a little program which displays the fonts generated from "font_to_py". And so i found out that the -x Mapping brings the correct rotated glyph, but only if i generate a single character ("arial48x.py"). I did these test with the character "A". If i generate and use the whole font "arial48x_all.py" it seems so, that the glyph data differs, getting with
glyph, char_height, char_width = arial48x_all.get_ch("A")
glyph1, char_height1, char_width1 = arial48x.get_ch("A")
So glyph <> glyph1. "glyph1" gives the correct grafical representation. "glyph gives the chaotic grafical representation.
I attached my test-program "Glyph_Drawing_V4" and two "font-to-py" files. The Programs shows the character "A" grapfically and prints the Glyph data in the REPL.
font_to_py.py -x -s 65 -l 65 ARIALUNI.TTF 48 arial48x.py font_to_py.py -x ARIALUNI.TTF 48 arial48x_all.py
arial48x.py with the single "A" in its works fine. arial48x_all.py with all characters doesnt work.
So "font-to-py" seems to deliver the correct data for the mapping needed for E-Ink 1.54", but only for a "single generated" character
best regards Christoph Roters
Did you try the approach I suggested above? If so, what was the outcome?
Hello,
i try to approach like you suggested. But that didnt makes a difference.
The problem seems to be somewhere in the "font-to-py.py"
The picture shows the result on the E-ink.
if i create a file with only one char with font_to_py.py -x -s 65 -l 65 ARIALUNI.TTF 48 arial48x.py its working perfect.
if i create the font-to-py file with font_to_py.py -x ARIALUNI.TTF 48 arial48x_all.py it shows pixel-garbage.
the 2 glyps are put to the framebuffer with identical code
fb.text('arial48x.py :',0,38,black)
glyph, char_height, char_width = arial48x.get_ch("A")
fb_char = framebuf.FrameBuffer(bytearray(glyph), 48, 48, framebuf.MONO_HLSB)
fb.blit(fb_char,0,48)
fb.text('arial48x_all.py :',0,118,black)
glyph, char_height, char_width = arial48x_all.get_ch("A")
fb_char = framebuf.FrameBuffer(bytearray(glyph), 48, 48, framebuf.MONO_HLSB)
fb.blit(fb_char,0,128)
e.set_frame_memory(buf, x, y, w, h)
e.display_frame()
i attached the code: font-to-py-problem3.zip
My suggestion was to use the Writer class. This is the preferred way to write text to a framebuf.
Hallo Peter, i made a font with your nice font-to-py tool. unfortunately the font is displayed not correct on my 1.54 Waveshare Epaper display. the controller is a ESP32. i tryed 4 fonts , with the 4 possible combination of hmap and reverse. See Picture. Unfortunately the font is displayed 90 degree rotated. I attached the whole source.
I would be happy, if you could help.
regards christoph (germany)