Optimum Label Size

Is there any straight forward method to calculate the optimum height for a Label so the text appears properly centered.
So far I have resorted to hit and miss which is time consuming

For example. if I make a label with 48pt font, the label has to be 54px tall to not cut off the tails of “y”'s and "j"s, but any taller and the text starts migrating to the bottom of the label

It’s totally dependent on the baseline, ascender, and descender values for the font in use. It also differs on the platforms and the same font family can be drawn one or two points off from each other even when using Adobe or Google fonts.

Short answer - trial and error … oh, and don’t depend on the IDE’s representation.

well it seems that if you “measure” the textheight (since font is in pts and label is in px) it works
EXCEPT if you apply Bold or Italics… this seems to create a much larger cap area… which pushes the text down so the baseline is near the bottom of the label…

SOoooooo… stay tuned… I will have a custom label control here soon :slight_smile:

Another example of “we shouldn’t need to do that …” and, it’s definitely not new: