charSet->mStyles[styleIndex] = style; }  int weightNumber = (int) PL_HashTableLookup(gWeights, weightName);
node->mStyles[styleIndex] = style; }  nsStringKey weightKey(weightName); int weightNumber = (int) gWeights->Get(&weightKey);
GetFontNames(char* aPattern){  nsFontFamily* family = nsnull;  int count;  char** list = ::XListFonts(GDK_DISPLAY(), aPattern, INT_MAX, &count);  if ((!list) || (count < 1)) {    return nsnull;  }  for (int i = 0; i < count; i++) {    char* name = list[i];    if ((!name) || (name[0] != '-')) {      continue;    }    char* p = name + 1;    int scalable = 0;#ifdef FIND_FIELD#undef FIND_FIELD#endif#define FIND_FIELD(var)           \  char* var = p;                  \  while ((*p) && ((*p) != '-')) { \    p++;                          \  }                               \  if (*p) {                       \    *p++ = 0;                     \  }                               \  else {                          \    continue;                     \  }#ifdef SKIP_FIELD#undef SKIP_FIELD#endif#define SKIP_FIELD(var)           \  while ((*p) && ((*p) != '-')) { \    p++;                          \  }                               \  if (*p) {                       \    p++;                          \  }                               \  else {                          \    continue;                     \  }    SKIP_FIELD(foundry);    // XXX What to do about the many Applix fonts that start with "ax"?    FIND_FIELD(familyName);    if (!*familyName) {      continue;    }    FIND_FIELD(weightName);    FIND_FIELD(slant);    FIND_FIELD(setWidth);    FIND_FIELD(addStyle);    FIND_FIELD(pixelSize);    if (pixelSize[0] == '0') {      scalable = 1;    }    FIND_FIELD(pointSize);    if (pointSize[0] == '0') {      scalable = 1;    }    FIND_FIELD(resolutionX);    if (resolutionX[0] == '0') {      scalable = 1;    }    FIND_FIELD(resolutionY);    if (resolutionY[0] == '0') {      scalable = 1;    }    FIND_FIELD(spacing);    FIND_FIELD(averageWidth);    if (averageWidth[0] == '0') {      scalable = 1;    }    char* charSetName = p; // CHARSET_REGISTRY & CHARSET_ENCODING    if (!*charSetName) {      continue;    }    nsFontCharSetInfo* charSetInfo =      (nsFontCharSetInfo*) PL_HashTableLookup(gCharSets, charSetName);    // indirection for font specific charset encoding     if (charSetInfo == &Special) {      char *familyCharSetName = PR_smprintf ("%s-%s", familyName, charSetName);      charSetInfo = (nsFontCharSetInfo*) PL_HashTableLookup         (gSpecialCharSets, familyCharSetName);      PR_smprintf_free (familyCharSetName);    }    if (!charSetInfo) {#ifdef NOISY_FONTS      printf("cannot find charset %s\n", charSetName);#endif      continue;    }    if (charSetInfo == &Ignore) {      // XXX printf("ignoring %s\n", charSetName);      continue;    }    nsAutoString familyName2;    familyName2.AssignWithConversion(familyName);    family =      (nsFontFamily*) PL_HashTableLookup(gFamilies, (nsString*) &familyName2);    if (!family) {      family = new nsFontFamily;      if (!family) {        continue;      }      nsString* copy = new nsString(NS_ConvertASCIItoUCS2(familyName));      if (!copy) {        delete family;        continue;      }      PL_HashTableAdd(gFamilies, copy, family);    }    if (!family->mCharSets) {      family->mCharSets = PL_NewHashTable(0, PL_HashString, PL_CompareStrings,        NULL, NULL, NULL);      if (!family->mCharSets) {        continue;      }    }    nsFontCharSet* charSet =      (nsFontCharSet*) PL_HashTableLookup(family->mCharSets, charSetName);    if (!charSet) {      charSet = new nsFontCharSet;      if (!charSet) {        continue;      }      char* copy = strdup(charSetName);      if (!copy) {        delete charSet;        continue;      }      charSet->mInfo = charSetInfo;      PL_HashTableAdd(family->mCharSets, copy, charSet);    }    int styleIndex;    // XXX This does not cover the full XLFD spec for SLANT.    switch (slant[0]) {    case 'i':      styleIndex = NS_FONT_STYLE_ITALIC;      break;    case 'o':      styleIndex = NS_FONT_STYLE_OBLIQUE;      break;    case 'r':    default:      styleIndex = NS_FONT_STYLE_NORMAL;      break;    }    nsFontStyle* style = charSet->mStyles[styleIndex];    if (!style) {      style = new nsFontStyle;      if (!style) {        continue;      }      charSet->mStyles[styleIndex] = style;    }    int weightNumber = (int) PL_HashTableLookup(gWeights, weightName);    if (!weightNumber) {#ifdef NOISY_FONTS      printf("cannot find weight %s\n", weightName);#endif      weightNumber = NS_FONT_WEIGHT_NORMAL;    }    int weightIndex = WEIGHT_INDEX(weightNumber);    nsFontWeight* weight = style->mWeights[weightIndex];    if (!weight) {      weight = new nsFontWeight;      if (!weight) {        continue;      }      style->mWeights[weightIndex] = weight;    }      int stretchIndex = (int) PL_HashTableLookup(gStretches, setWidth);    if (!stretchIndex) {#ifdef NOISY_FONTS      printf("cannot find stretch %s\n", setWidth);#endif      stretchIndex = 5;    }    stretchIndex--;    nsFontStretch* stretch = weight->mStretches[stretchIndex];    if (!stretch) {      stretch = new nsFontStretch;      if (!stretch) {        continue;      }      weight->mStretches[stretchIndex] = stretch;    }    if (scalable) {      if (!stretch->mScalable) {        stretch->mScalable = PR_smprintf("%s-%s-%s-%s-%s-%%d-*-*-*-%s-*-%s",          name, weightName, slant, setWidth, addStyle, spacing, charSetName);      }      continue;    }      int pixels = atoi(pixelSize);    if (stretch->mSizesCount) {      nsFontGTK* end = &stretch->mSizes[stretch->mSizesCount];      nsFontGTK* s;      for (s = stretch->mSizes; s < end; s++) {        if (s->mSize == pixels) {          break;        }      }      if (s != end) {        continue;      }    }    if (stretch->mSizesCount == stretch->mSizesAlloc) {      int newSize = 2 * (stretch->mSizesAlloc ? stretch->mSizesAlloc : 1);      nsFontGTK* newPointer = new nsFontGTKNormal[newSize];      if (newPointer) {        for (int j = stretch->mSizesAlloc - 1; j >= 0; j--) {          newPointer[j] = stretch->mSizes[j];        }        stretch->mSizesAlloc = newSize;        delete [] stretch->mSizes;        stretch->mSizes = newPointer;      }      else {        continue;      }    }    p = name;    while (p < charSetName) {      if (!*p) {        *p = '-';      }      p++;    }    char* copy = strdup(name);    if (!copy) {      continue;    }    nsFontGTK* size = &stretch->mSizes[stretch->mSizesCount++];    size->mName = copy;    size->mFont = nsnull;    size->mSize = pixels;    size->mActualSize = 0;    size->mBaselineAdjust = 0;    size->mMap = nsnull;    size->mCharSetInfo = charSetInfo;  }  XFreeFontNames(list);#ifdef DEBUG_DUMP_TREE  DumpTree();#endif  return family;}