for (PRUint32 i=0; i<(sizeof(gEmptyMap)/sizeof(gEmptyMap[0])); i++) gEmptyMap[i] = 0;
InitGlobals(void){#ifdef NS_FONT_DEBUG  char* debug = PR_GetEnv("NS_FONT_DEBUG");  if (debug) {    PR_sscanf(debug, "%lX", &gDebug);  }#endif  nsresult res;  nsServiceManager::GetService(kCharSetManagerCID,    NS_GET_IID(nsICharsetConverterManager2), (nsISupports**) &gCharSetManager);  if (!gCharSetManager) {    FreeGlobals();    return NS_ERROR_FAILURE;  }  nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref),    (nsISupports**) &gPref);  if (!gPref) {    FreeGlobals();    return NS_ERROR_FAILURE;  }  // get the "disable double byte font special chars" setting  PRBool val = PR_TRUE;  nsresult rv = gPref->GetBoolPref("font.allow_double_byte_special_chars", &val);  if (NS_SUCCEEDED(rv))    gAllowDoubleByteSpecialChars = val;  // setup the double byte font special chars glyph map  for (int i=0; gDoubleByteSpecialChars[i]; i++) {    SET_REPRESENTABLE(gDoubleByteSpecialCharsMap, gDoubleByteSpecialChars[i]);  }  PRInt32 scale_minimum = 0;  gPref->GetIntPref("font.scale.outline.min", &scale_minimum);  if (NS_SUCCEEDED(res)) {    gOutlineScaleMinimum = scale_minimum;    SIZE_FONT_PRINTF(("gOutlineScaleMinimum = %d", gOutlineScaleMinimum));  }  gPref->GetIntPref("font.scale.bitmap.min", &scale_minimum);  if (NS_SUCCEEDED(res)) {    gBitmapScaleMinimum = scale_minimum;    SIZE_FONT_PRINTF(("gBitmapScaleMinimum = %d", gBitmapScaleMinimum));  }  PRInt32 percent = 0;  gPref->GetIntPref("font.scale.bitmap.oversize", &percent);  if (percent) {    gBitmapOversize = percent/100.0;    SIZE_FONT_PRINTF(("gBitmapOversize = %g", gBitmapOversize));  }  percent = 0;  gPref->GetIntPref("font.scale.bitmap.undersize", &percent);  if (percent) {    gBitmapUndersize = percent/100.0;    SIZE_FONT_PRINTF(("gBitmapUndersize = %g", gBitmapUndersize));  }  gNodes = new nsHashtable();  if (!gNodes) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gCachedFFRESearches = new nsHashtable();  if (!gCachedFFRESearches) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gFamilies = new nsHashtable();  if (!gFamilies) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gAliases = new nsHashtable();  if (!gAliases) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  nsFontFamilyName* f = gFamilyNameTable;  while (f->mName) {    nsCStringKey key(f->mName);    gAliases->Put(&key, f->mXName);    f++;  }  gWeights = new nsHashtable();  if (!gWeights) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  nsFontPropertyName* p = gWeightNames;  while (p->mName) {    nsCStringKey key(p->mName);    gWeights->Put(&key, (void*) p->mValue);    p++;  }  gStretches = new nsHashtable();  if (!gStretches) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  p = gStretchNames;  while (p->mName) {    nsCStringKey key(p->mName);    gStretches->Put(&key, (void*) p->mValue);    p++;  }  gCharSetMaps = new nsHashtable();  if (!gCharSetMaps) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  nsFontCharSetMap* charSetMap = gCharSetMap;  while (charSetMap->mName) {    nsCStringKey key(charSetMap->mName);    gCharSetMaps->Put(&key, charSetMap);    charSetMap++;  }  gSpecialCharSets = new nsHashtable();  if (!gSpecialCharSets) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  nsFontCharSetMap* specialCharSetMap = gSpecialCharSetMap;  while (specialCharSetMap->mName) {    nsCStringKey key(specialCharSetMap->mName);    gSpecialCharSets->Put(&key, specialCharSetMap);    specialCharSetMap++;  }  gUnicode = NS_NewAtom("x-unicode");  if (!gUnicode) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gUserDefined = NS_NewAtom(USER_DEFINED);  if (!gUserDefined) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  // the user's locale  nsCOMPtr<nsILanguageAtomService> langService;  langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);  if (langService) {    langService->GetLocaleLanguageGroup(&gUsersLocale);  }  if (!gUsersLocale) {    gUsersLocale = NS_NewAtom("x-western");  }  gWesternLocale = NS_NewAtom("x-western");  if (!gUsersLocale) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gInitialized = 1;  return NS_OK;}