U8g2_for_Adafruit_GFX icon indicating copy to clipboard operation
U8g2_for_Adafruit_GFX copied to clipboard

there is no SetFontPosTop function in the library

Open hznupeter opened this issue 5 years ago • 4 comments

there are servral function to set the font postition in the u8g2 library.But it can't use the the U8g2_for_Adafruit_GFX. here is the lost function: void setFontPosBaseline(void) { u8g2_SetFontPosBaseline(&u8g2); } void setFontPosBottom(void) { u8g2_SetFontPosBottom(&u8g2); } void setFontPosTop(void) { u8g2_SetFontPosTop(&u8g2); } void setFontPosCenter(void) { u8g2_SetFontPosCenter(&u8g2); } can i add these functions into this library, thk bro.

hznupeter avatar Aug 20 '19 12:08 hznupeter

Indeed I simplified this version.

can i add these functions into this library, thk bro.

sure...

olikraus avatar Aug 20 '19 13:08 olikraus

the fontpos is very useful .(* ̄︶ ̄)

hznupeter avatar Aug 21 '19 01:08 hznupeter

can you add setFontPosTop function in this repo. I've tried a lot,but failed. thank you

hznupeter avatar Sep 05 '19 02:09 hznupeter

You just need to add getFontAscent() to the y value to get the baseline position from the top pos position.

The following function will accept the upper left position of instead of the base line position. In the same way you can write wrapper functions to other functions if required.

int16_t drawTopPosUTF8(U8G2_FOR_ADAFRUIT_GFX &u8g2, int16_t x, int16_t y, const char *str);
{
   return u8g2.drawUTF8(x,  y+u8g2.getFontAscent(),str);
}

code is not tested...

olikraus avatar Sep 07 '19 06:09 olikraus