ThingPulse / minigrafx

ESP8266 graphics library
MIT License
220 stars 46 forks source link

Big fonts for old eyes? #6

Closed jumblies closed 5 years ago

jumblies commented 7 years ago

Thank you for the new library. All your hard work is appreciated.

Is it possible to get fonts around 72pt to work with this library?

I created a 72pt Roboto Black font using http://oleddisplay.squix.ch/#/home but it ended up only displaying the left hand side of the numerals.

44pt works great. 50 has some issues at the margins(time in the pic below) but is passable but 72 is mostly incomplete (the temp in the pic below.

I suspect it has something to do with this compiler warning which I don't get with regular size fonts.

src\roboto_black_72.h:458:1: warning: large integer implicitly truncated to unsigned type [-Woverflow] src\roboto_black_72.h:458:1: warning: narrowing conversion of '405' from 'int' to 'const char' inside { } [-Wnarrowing]

_20170726_151744

roboto black big fonts.zip

wawibu commented 7 years ago

I'm running into the same issue that fonts in this side not shown correct. Getting the same error message and the same output on the screen. Would be great if there is a way to get this fixed :)

skx commented 6 years ago

The problem is the generated code is creating numbers that are too large for the type.

If you look at the output of the generating site you'll see this:

 const char Dialog_plain_78[] PROGMEM = {
0x4E, // Width: 78
0x5C, // Height: 92
0x20, // First Char: 32
0xE0, // Numbers of Chars: 224

// Jump Table:
0xFF, 0xFF, 0x00, 0x19,  // 32:65535
0x00, 0x00, 0xEE, 0x1F,  // 33:0
0x00, 0xEE, 0x13D, 0x24,  // 34:238
    ... more

So you see it is creating an array of char. A char will hold values 0-0xFF (0-255). But the values in the list are bigger than that. e.g. 0x13D is bigger than 0xFF.

To fix this you need to do two things:

In the generated output change const char Dialog_plain_78[] PROGMEM = { to:

  const int Dialog_plain_78[] PROGMEM = {

That will ensure those values are correct. Of course the next step is seeing if what consumes the fonts will work with int rather than char. You'll either get lucky, or not. If it fails to compile you'll soon spot the problem and I suspect it should be as simple as updating the types appropriately. (i.e. Carrying on changing char to int as you see error-messages about truncation, or mis-matched types.)

Aljrob commented 6 years ago

So I'm a bit new to c/c++ but followed skx's explanation above (thanks btw) and have updated my font type to int.

Unfortunately the Minigrafx library itself does seem to be struggling to consume the int font data, with the compiler erroring out with the following in a few places in my code.

no matching function for call to 'MiniGrafx::setFont(const int [64671])'

Attempting to update the Minigrafx library is probably beyond my current skill level without guidance at the moment - has anyone managed to successfully update Minigrafx to show large fonts?

xriser commented 5 years ago

Same issue, please fix it, who can. Thank you in advance

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.