Open snapedumbledore opened 6 years ago
This is more a C/C++ question, not a u8g2 related question. Nevertheless, the bytewidth can be calculated with "sizeof(int)"
Unless of course he means get the width of a numeric character in a font given the number as an int
Emmmm.Thanks. I want to calculate the 'x' width which is int。(int x = 0,and x will be increased or decreased) I know i can get a string width through u8g.getStrWidth @olikraus
There is no other option: You have to convert the number (int) to a string. During this conversion you have to decide whether to include a minus sign, leading zeros, an additional % sign and which base you want to use (10/decimal, 16 hexadecimal, etc). All these decision during the string conversions will change the size of the number. So, i guess it will be best to use "sprintf" with proper conversion options and then apply the resulting string to getStrWidth().
I would like to know how can i get the width of 'int' type, not a string. Thanks.