Look And Feel drawButtonText not consistent

I am working on getting textbuttons to show with a specific Look And Feel. Once I added the drawButtonText method to my LookAndFeel class, the text sometimes shows on the buttons and sometimes doesn’t. Below is what happens when I run the code. However, sometimes when I run the code, this issue is nonexistent and the text is properly written on the buttons.

Once I click on the buttons without the text, the text appears. Also, it’s those specific buttons that consistently won’t have text when running. This behavior is really weird because all the buttons were made the same way. Below is my drawButtonText method. This issue started happening after adding this method to my custom LookAndFeel class. I am also using a separate font, so maybe the issue may be arising from there as well.

void PerformanceButtonLookAndFeel::drawButtonText (Graphics &g, TextButton &button, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown)
{
    Font font = getDinotMediumFont();
    font.setHeight(button.getHeight()/5);
    font.setHorizontalScale(1.0);
    g.setFont(font);
    g.setColour(Colour(51, 51, 51));

    auto leftIndent = button.getWidth()*textIndentProp_;
    auto textWidth = button.getWidth()*(1-textIndentProp_*2);
    auto topIndent = button.getHeight()*textIndentProp_;
    auto textHeight = button.getHeight()*(1-textIndentProp_*2);

    g.drawFittedText(button.getButtonText().toUpperCase(), leftIndent, topIndent, textWidth, textHeight, Justification::centred, 2, 1);
}

It would be great if I could get help me understand why this unpredictable behavior is occurring after running the code without changing anything. It would also be great if there were other ways for customizing a button’s font.