initButton label limited to 9 characters

Trying to utilise the Adafruit_GFX functions, specifically initButton, but seem to have a problem where the label is limited to 9 characters. Say I want the button to read “Turn On Power”, when compiled and uploaded to my Uno, the button displays fine and text appears, but it reads ‘Turn On P’.
Does this for all my buttons.
There is plenty of space to fit the text, so much I could write twice as many characters.
Any ideas? Sample below

void setup(void)
{
    tft.begin(tft.readID());
    tft.setRotation(0);               //Portrait orientation
    powersw_btn.initButton(&tft, 120,  20, 240, 40, TFT_WHITE, TFT_CYAN, TFT_BLACK, "Turn On Power", 2);

I don't know the library, but I guess you have checked that the text will fit with in the dimensions you have defined for the button: 120, 20, 240, 40

Otherwise, the obvious solution is to shorten "Turn On Power" to "ON"

You have the source code for the library and could change the function definition if you wanted or you could, of course, complain to Adafruit

public:
  Adafruit_GFX_Button(void);
  // "Classic" initButton() uses center & size
  void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w,
                  uint16_t h, uint16_t outline, uint16_t fill,
                  uint16_t textcolor, char *label, uint8_t textsize);
  void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w,
                  uint16_t h, uint16_t outline, uint16_t fill,
                  uint16_t textcolor, char *label, uint8_t textsize_x,
                  uint8_t textsize_y);

It is the label variable that is causing the problem
It is declared like this

char _label[10];

So is limited to 9 characters allowing for the zero termination

OK so I changed the code in Adafruit_GFX.h as per below, from 10 to 20

private:
  Adafruit_GFX *_gfx;
  int16_t _x1, _y1; // Coordinates of top-left corner
  uint16_t _w, _h;
  uint8_t _textsize_x;
  uint8_t _textsize_y;
  uint16_t _outlinecolor, _fillcolor, _textcolor;
  char _label[20];

...and the only other instance I could find in Adafruit_GFX.cpp from 9 to 20, and other combo's. Nothing worked. What can I change to fix this please to get things working for now?

void Adafruit_GFX_Button::initButtonUL(Adafruit_GFX *gfx, int16_t x1,
                                       int16_t y1, uint16_t w, uint16_t h,
                                       uint16_t outline, uint16_t fill,
                                       uint16_t textcolor, char *label,
                                       uint8_t textsize_x, uint8_t textsize_y) {
  _x1 = x1;
  _y1 = y1;
  _w = w;
  _h = h;
  _outlinecolor = outline;
  _fillcolor = fill;
  _textcolor = textcolor;
  _textsize_x = textsize_x;
  _textsize_y = textsize_y;
  _gfx = gfx;
  strncpy(_label, label, 20);
}

What you have done looks right but I cannot test it because I do not have the required screen. Try printing _label to the Serial monitor after copying label to it in the library. Is it correct ?

Presumably the private _label variable is output to the screen somewhere in the library but at the moment I don't have time to look

Not exactly sure how to do that.

But, I played around, dont know why it didn't work before, but I just changed both aformentioned values to 20 again, and it worked. It now displays all the characters. Go figure.

Go figure.

I figure that you did it wrong the first time but at least it works now !