tgx icon indicating copy to clipboard operation
tgx copied to clipboard

Converted AA ttf font is displayed semi-transparent instead of white

Open klaasdc opened this issue 1 year ago • 3 comments

I want to add a custom font (Digital7Mono TTF) to my application, using the scripts from https://github.com/projectitis/packedbdf With Fontforge and bdf_to_h.py I converted it to a 4bit anti-aliased packed BDF, with point size 48. When I display the font in the RGB565_White color, the font appear as gray. When I draw a rectangle behind it, it clearly looks like all characters were drawn transparantly instead of full white.

c->drawText(buf, {120, 200}, tgx::RGB565_White, Digital7Mono48_Italic, false);

What could be the issue? Could the font be converted incorrectly or I am perhaps using the drawText function incorrectly?

The packed BDF .h looks like this (only put first part):

#ifndef _PACKEDBDF_DIGITAL7MONO48_ITALIC_
#define _PACKEDBDF_DIGITAL7MONO48_ITALIC_

#include <Fonts.h>

static const unsigned char Digital7Mono48_Italic_data[] = {
0x04,0x0c,0x92,0xc0,0x57,0x72,0x57,0x72,0x57,0x72,
0x14,0x84,0x1e,0xc0,0x02,0x47,0x77,0x77,0x77,0x77,
0x77,0x75,0x14,0x00,0x04,0x77,0x77,0x77,0x77,0x77,
0x77,0x70,0x77,0x70,0x14,0x77,0x77,0x77,0x77,0x77,
0x77,0x73,0x57,0x60,0x23,0x42,0x77,0x77,0x77,0x77,
0x77,0x54,0x77,0x71,0x47,0x57,0x10,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x74,0x10,0x00,0x00,0x00,
0x00,0x02,0x67,0x71,0x47,0x41,0x00,0x00,0x00,0x00,
0x00,0x00,0x36,0x71,0x07,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x70,0x47,0x52,0x00,0x00,0x00,0x00,
0x00,0x00,0x36,0x71,0x47,0x75,0x10,0x00,0x00,0x00,
0x00,0x02,0x67,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x77,0x40,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x47,0x35,0x00,0x00,0x00,0x00,
0x00,0x06,0x77,0x71,0x13,0x73,0x77,0x77,0x77,0x77,
0x77,0x54,0x77,0x71,0x17,0x77,0x77,0x77,0x77,0x77,
0x77,0x75,0x57,0x60,0x04,0x57,0x77,0x77,0x77,0x77,
0x77,0x74,0x77,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x14,0x00,0x05,0x7d,0x02,0xc0,0x04,0x32,
0x00,0x27,0x40,0x17,0x77,0x16,0x77,0x71,0x67,0x77,
0x16,0x77,0x71,0x67,0x77,0x16,0x77,0x71,0x67,0x77,
0x16,0x77,0x71,0x67,0x77,0x16,0x77,0x71,0x57,0x77,
0x10,0x17,0x71,0x00,0x15,0x00,0x00,0x20,0x00,0x05,
0x00,0x17,0x71,0x57,0x77,0x16,0x77,0x71,0x67,0x77,
0x16,0x77,0x71,0x67,0x77,0x16,0x77,0x71,0x67,0x77,
0x16,0x77,0x71,0x67,0x77,0x16,0x77,0x71,0x17,0x77,
0x10,0x27,0x40,0x04,0x32,0x00,0x14,0x80,0x12,0xc0,
0x02,0x47,0x77,0x77,0x77,0x77,0x77,0x75,0x14,0x00,
0x04,0x77,0x77,0x77,0x77,0x77,0x77,0x70,0x77,0x70,
0x14,0x77,0x77,0x77,0x77,0x77,0x77,0x73,0x57,0x60,
0x00,0x42,0x77,0x77,0x77,0x77,0x77,0x54,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x77,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x67,0x71,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x71,
0x00,0x06,0x77,0x77,0x77,0x77,0x77,0x76,0x43,0x70,
0x00,0x37,0x77,0x77,0x77,0x77,0x77,0x77,0x61,0x00,
0x01,0x26,0x77,0x77,0x77,0x77,0x77,0x76,0x40,0x00,
0x47,0x52,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x47,0x75,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
...

klaasdc avatar Feb 26 '24 18:02 klaasdc

I figured out that it had to do with the font generation scripts by projectitis. A pull request was made for a fix to the bpp calculation (https://github.com/projectitis/packedbdf/commit/f320d2fadd4c2574215128514e7bbc7f53a96ffd) but never merged.

klaasdc avatar Feb 27 '24 23:02 klaasdc

Hi,

Yes indeed, I remember that there was a bug in projectitis code but it should be fixed in this python script

vindar avatar Feb 29 '24 09:02 vindar

Thanks, your script works fine! I did have to include the space-character (32) in my fonts. Is there a reason that it explicitly needs it? Just curious.

klaasdc avatar Mar 04 '24 12:03 klaasdc