bitrazor.com ...THE source for mediocre content                                      

How to Determine the Width of a Font             

Keywords: tivo hme bananas default font width calculation

TiVo provides a way to get back a bunch of font metrics from the box itself.  There's a good starter application that demonstrates this included with the HME samples.

I've already dumped all of the character widths for many popular sizes of the default font (10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36) and stuck them into int[] arrays.  See

For each character in your string, use the glyphs[] array and look up the position in the array.  Then use that position as the index into the int[] array for the font size you're using.  That'll give you the width of each character.  Using this information, you can calculate the pixel width of your string.

                                                         Last updated: February 19, 2007