Font alignment bug

See attached. Trying to dynamically select a font size based on string length and if it is textual or numeric. If numeric, I can use larger font numbers 5 thru 8. But the fonts are not consistently aligned. There is no bottom justify, so I have to use VCENTER and then skew the fonts down based on the string height.

However, as you can see in the attached, the Garmin 820 centers the numbers about 15% above the center line. And on the VivoActive HR, it centers the numbers about 15% below the center line (15% of the string height). So any logic that attempts to position the string, say, 5 pixels from the bottom of the data field, will vary based on the device, due to inconsistent rendering of the font to a VCENTER parameter.

In the attached, the RED line is the dead center of the value area and where the font should be centered. The BLUE box is the size of the string (height and width.

This inconsistency by device occurs for all the numeric fonts - 5 thru 8.
community.garmin.com/.../1260335.jpg
  • By device and specific font, fonts can differ based on the amount of white space above and/or below the character itself. It's the way the native fonts were done in the FW for some reason, so that won't change (it would break a bunch of existing things if it did). You just have to code for it. To make things easier you may want to just user the alphanumeric font, even for numbers.

    Instead of talking "font numbers", are you using font names in the code? Like FONT_NUMBER_HOT? The reason I mention it, is it can help to make things a bit more readable in the code. I have not idea what "fonts 5-8" are for example :). On some devices, you may also see a difference between the FONT_* and FONT_SYSTEM_* fonts.
  • By device and specific font, fonts can differ based on the amount of white space above and/or below the character itself. It's the way the native fonts were done in the FW for some reason, so that won't change (it would break a bunch of existing things if it did). You just have to code for it. To make things easier you may want to just user the alphanumeric font, even for numbers.

    Instead of talking "font numbers", are you using font names in the code? Like FONT_NUMBER_HOT? The reason I mention it, is it can help to make things a bit more readable in the code. I have not idea what "fonts 5-8" are for example :). On some devices, you may also see a difference between the FONT_* and FONT_SYSTEM_* fonts.



    Thanks Jim! The problem I'm seeing is the fonts 0 thru 4 (those are the actual numbers for the enum XTINY, TINY, SMALL, MEDIUM, LARGE) for the alphanumeric fonts aren't big enough... even the max size (4 = LARGE). The numeric fonts (5 thru 8) are larger, but have the alignment issue. I can code for it, but I need to figure out an offset table I guess for EVERY device. Ugh. A bottom justify would fix this. Oh well. Or I guess I could write my own font, but that takes up a lot of memory and the 26Kb devices are already memory limited.

    Thanks Jim! Always learn from your replies!!