olleheugene / u8glib

Automatically exported from code.google.com/p/u8glib
Other
0 stars 0 forks source link

Int overflow in getStrWidth and getStrPixelWidth #142

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Take string "A B C D E F G H I J K L M O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 
7 8 9" for example, use u8g.getStrWidth(s) on it.
2. Width is 99? say what??? ok so the width is more than 255 and this doesn't 
work very well with the 8 bit ints used un u8glib
3. font = u8g_font_5x7

What is the expected output? What do you see instead?
99+255 I see 99. if you take A B C D E F G H I J K L M O P Q R S T U V W X Y Z 
0 1 2 3 4 5 6 7 8 9

What version of the product are you using? On what operating system?
1.10, Windows, Arduino Mega 2560

Please provide any additional information below.
Well I think an upgrade to the standard ints (16-bit) is in order. (I can do 
this myself but I think it should also be done with the functions in the 
library)

Original issue reported on code.google.com by erwin.de...@outlook.com on 7 Feb 2013 at 9:52

GoogleCodeExporter commented 9 years ago
> Well I think an upgrade to the standard ints (16-bit) is in order. (I can do 
this
> myself but I think it should also be done with the functions in the library)
yes, i am sure you can uncomment line 39 in
http://code.google.com/p/u8glib/source/browse/csrc/u8g.h

Expect some larger size of your program.

Will this solve your problem?

Oliver

Original comment by olikr...@gmail.com on 7 Feb 2013 at 10:19

GoogleCodeExporter commented 9 years ago
Well I did. The Arduino IDE still gives 1 for
<code>
#if defined(U8G_16BIT)
   Serial.println("16BIT");
  #endif
  Serial.println(sizeof(u8g_uint_t));
</code>
and 16BIT doesn't get printed.
But if I compile & upload the project in Visual Studio it does work, so i guess 
it fixed the problem.

And by the way how thoughtful a 16 bit switch! Kudos!

Original comment by erwin.de...@outlook.com on 7 Feb 2013 at 10:44

GoogleCodeExporter commented 9 years ago

Original comment by olikr...@gmail.com on 16 Feb 2013 at 1:14