for (i = 1; ; i++) { key.Assign(NS_LITERAL_STRING("mathfont.")); key.AppendInt(i, 10); if (NS_FAILED(mathfontProp->GetStringProperty(key, value))) break; Clean(value); gGlyphTableList->AddGlyphTable(value);
nsFont font(nsnull, 0, 0, 0, 0, 0); nsXPIDLString familyList; nsCOMPtr<nsIPref> pref; pref = do_GetService(NS_PREF_CONTRACTID); if (pref) {  pref->CopyUnicharPref("font.mathfont-family", getter_Copies(familyList));
InitGlobals(){  NS_ASSERTION(!gInitialized, "Error -- already initialized");  gInitialized = PR_TRUE;  PRInt32 count = nsMathMLOperators::CountStretchyOperator();  if (!count) {    // nothing to stretch, so why bother...    return NS_OK;  }  // Allocate the placeholders for the preferred parts and variants  nsGlyphTableList::gParts = new PRInt32[count];  if (!nsGlyphTableList::gParts)    return NS_ERROR_OUT_OF_MEMORY;  nsGlyphTableList::gVariants = new PRInt32[count];  if (!nsGlyphTableList::gVariants) {    delete nsGlyphTableList::gParts;    return NS_ERROR_OUT_OF_MEMORY;  }  PRInt32 i;  for (i = 0; i < count; i++) {    nsGlyphTableList::gParts[i] = kNotFound; // i.e., -1    nsGlyphTableList::gVariants[i] = kNotFound; // i.e., -1  }  // Allocate gGlyphTableList  nsresult rv = NS_ERROR_OUT_OF_MEMORY;  gGlyphTableList = new nsGlyphTableList();  if (gGlyphTableList) {    rv = gGlyphTableList->Initialize();  }  if (NS_FAILED(rv)) {    delete nsGlyphTableList::gParts;    delete nsGlyphTableList::gVariants;    if (gGlyphTableList) delete gGlyphTableList;    gGlyphTableList = nsnull;    return rv;  }  /*  else    The gGlyphTableList has been successfully registered as a shutdown observer.    It will be deleted at shutdown, even if a failure happens below.  */  nsAutoString key, value;  nsCOMPtr<nsIPersistentProperties> mathfontProp;  // Add the math fonts in the gGlyphTableList in order of preference ...  // Note: we only load font-names at this stage. The actual glyph tables will  // be loaded lazily (see nsGlyphTable::ElementAt()).  // Load the "mathfont.properties" file  value.Truncate();  rv = LoadProperties(value, mathfontProp);  if (NS_FAILED(rv)) return rv;  // Load the "mathfontPUA.properties" file  value.Assign(NS_LITERAL_STRING("PUA"));  rv = LoadProperties(value, gPUAProperties);  if (NS_FAILED(rv)) return rv;  // Enlist the glyph tables associated to each given mathfont  for (i = 1; ; i++) {    key.Assign(NS_LITERAL_STRING("mathfont."));    key.AppendInt(i, 10);    if (NS_FAILED(mathfontProp->GetStringProperty(key, value)))      break;    Clean(value);    gGlyphTableList->AddGlyphTable(value);  }  // Append a null separator  gGlyphTableList->AppendElement(nsnull);  // Let the particular characters have their preferred extension tables  nsCOMPtr<nsISimpleEnumerator> iterator;  if (NS_SUCCEEDED(mathfontProp->SimpleEnumerateProperties(getter_AddRefs(iterator)))) {    PRBool more;    while ((NS_SUCCEEDED(iterator->HasMoreElements(&more))) && more) {      nsCOMPtr<nsIPropertyElement> element;      if (NS_SUCCEEDED(iterator->GetNext(getter_AddRefs(element)))) {        nsXPIDLString xkey, xvalue;        if (NS_SUCCEEDED(element->GetKey(getter_Copies(xkey))) &&            NS_SUCCEEDED(element->GetValue(getter_Copies(xvalue)))) {          key.Assign(xkey);          // expected key: "extension.\uNNNN.parts" or "extension.\NNNN.variants"          if ((22 <= key.Length()) && (0 == key.Find("extension.\\u"))) {            PRInt32 error = 0;            key.Cut(0, 12); // 12 is the length of "extension.\\u";            PRUnichar uchar = key.ToInteger(&error, 16);            if (error) continue;            key.Cut(0, 5); // the digits of the unicode point + dot ("NNNN.")            value.Assign(xvalue);            Clean(value);            SetPreferredTableList(uchar, key, value);          }        }      }    }  }  return rv;}