Adjusting Font Placement using VCENTER

I solved the issue of dealing with the way different devices place text strings using VCENTER. This is the logic to ensure your text string appears vertically centered. I used monkey.jungle excludeAnnotations and "has" logic to set flags to perform the skews. And a nested FOR loop to check the text string for the existence of any of the 20 descender characters. A pain, but necessary for the text to look nicely centered for one of my fields.

var skew = dc.getFontDescent(font)/2;

OLD EDGE DEVICES (like 520, 820, 1030, Explore):

If your text string does NOT have any descenders (meaning no y, j, ], etc)... then VCENTER does what you expect.

However, if you have descenders, you need to move your text string UP by the amount: skew

NEW EDGE DEVICES (1040, 1050):

If your text string does have descenders, then VCENTER does what you expect.

However, if it does NOT have any descenders, you need to move your text string DOWN by: skew

EDGE EXPLORE2:

If this has descenders or not, you always have to move your text string UP by: skew

There may be other devices that require special handling, but at least I now have the pattern to make it work.

  • I don't like this... My output includes user input, so I have no way of knowing whether there's y or j, and then I haven't even talked about 30+ other languages...

  • agree - this is a pain in the butt... but I don't have a better solution for text centering. for English at least, it is trivial to check for the existence of any of the 20 characters that have descenders in a string before drawing it. The new 1050 at least throws another wrench in that a capital "J" descends.