Comment 1 for bug 890589

Revision history for this message
Robert Nordan (rpvn) wrote :

OK, there is something wrong with the underlying Pango library (or pango-sharp which is the gobetween).

When you call this method in FontManager.cs, it's supposedto return nsizes = 0 if the font is not a bitmap font. (Most fonts are vector fonts these days, so they will return 0)

// Query for supported sizes for this font
fontFace.ListSizes (out sizes, out nsizes);

if (nsizes == 0)
 return default_font_sizes;

List<int> result = new List<int> ();

for (int i = 0; i < nsizes; i++)
 result.Add (*(&sizes + 4 * i)); //Here's where things go wrong....

However, sometimes it returns garbage like 32767 which means it's returning uninitialized values, but that will still pass the check. Now, putting a try/catch around the function trying to recover the sizes will work in debug mode and catch the nullreference exception, but not when you run without debug because such things aren't checked then. (And then the font menu is filled with gibberish numbers.)

There is a real ugly hack that can fix this, but I'm not sure I want to do it:

//Ugly hack to deal with pango returning garbage when not finished initiliazing
if (nsizes <= 0 || nsizes > 200)
 return default_font_sizes;

Is it worth it to try and chase this down further or should we just do it the easy way?