gFontForIgnorable = new nsFontWinSubstitute(gIgnorableCCMapExt); if (!gFontForIgnorable) { FreeGlobals(); return NS_ERROR_OUT_OF_MEMORY; }
InitGlobals(void){  nsServiceManager::GetService(kCharsetConverterManagerCID,    NS_GET_IID(nsICharsetConverterManager), (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;  }  // if we do not include/compensate external leading in calculating normal   // line height, we don't set gDoingLineheightFixup either to keep old behavior.  // These code should be eliminated in future when we choose to stay with   // one normal lineheight calculation method.  PRInt32 intPref;  if (NS_SUCCEEDED(gPref->GetIntPref(      "browser.display.normal_lineheight_calc_control", &intPref)))    gDoingLineheightFixup = (intPref != 0);  nsCOMPtr<nsILanguageAtomService> langService;  langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);  if (langService) {    langService->GetLocaleLanguageGroup(&gUsersLocale);  }  if (!gUsersLocale) {    gUsersLocale = NS_NewAtom("x-western");  }  if (!gUsersLocale) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }    if (!gSystemLocale) {    UINT cp= ::GetACP();    for (int i = 1; i < eCharset_COUNT; ++i) {      if (gCharsetInfo[i].mCodePage == cp) {        gSystemLocale = NS_NewAtom(gCharsetInfo[i].mLangGroup);        break;      }    }  }  if (!gSystemLocale) {    gSystemLocale = gUsersLocale;    NS_ADDREF(gSystemLocale);  }  gUserDefined = NS_NewAtom(USER_DEFINED);  if (!gUserDefined) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gJA = NS_NewAtom("ja");  if (!gJA) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gKO = NS_NewAtom("ko");  if (!gKO) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gZHCN = NS_NewAtom("zh-CN");  if (!gZHCN) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gZHTW = NS_NewAtom("zh-TW");  if (!gZHTW) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gZHHK = NS_NewAtom("zh-HK");  if (!gZHHK) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  //register an observer to take care of cleanup  gFontCleanupObserver = new nsFontCleanupObserver();  NS_ASSERTION(gFontCleanupObserver, "failed to create observer");  if (gFontCleanupObserver) {    // register for shutdown    nsresult rv;    nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1", &rv));    if (NS_SUCCEEDED(rv)) {      rv = observerService->AddObserver(gFontCleanupObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);    }      }  gInitialized = 1;  return NS_OK;}