nsStringKey familyCharSetKey(familyCharSetName);
nsCStringKey familyCharSetKey(familyCharSetName);
GetFontNames(char* aPattern, nsFontNodeArray* aNodes){#ifdef NS_FONT_DEBUG_CALL_TRACE  if (gDebug & NS_FONT_DEBUG_CALL_TRACE) {    printf("GetFontNames %s\n", aPattern);  }#endif  nsCAutoString previousNodeName;  /*   * We do not use XListFontsWithInfo here, because it is very expensive.   * Instead, we get that info at load time (gdk_font_load).   */  int count;  char** list = ::XListFonts(GDK_DISPLAY(), aPattern, INT_MAX, &count);  if ((!list) || (count < 1)) {    return;  }  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;                     \  }    FIND_FIELD(foundry);    // XXX What to do about the many Applix fonts that start with "ax"?    FIND_FIELD(familyName);    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;    }    nsStringKey charSetKey(charSetName);    nsFontCharSetInfo* charSetInfo =      (nsFontCharSetInfo*) gCharSets->Get(&charSetKey);    // indirection for font specific charset encoding     if (charSetInfo == &Special) {      nsCAutoString familyCharSetName(familyName);      familyCharSetName.Append('-');      familyCharSetName.Append(charSetName);      nsStringKey familyCharSetKey(familyCharSetName);      charSetInfo =        (nsFontCharSetInfo*) gSpecialCharSets->Get(&familyCharSetKey);    }    if (!charSetInfo) {#ifdef NOISY_FONTS      printf("cannot find charset %s\n", charSetName);#endif      charSetInfo = &Unknown;    }    if (charSetInfo->mCharSet && (!charSetInfo->mLangGroup)) {      nsCOMPtr<nsIAtom> charset;      nsresult res = gCharSetManager->GetCharsetAtom2(charSetInfo->mCharSet,        getter_AddRefs(charset));      if (NS_SUCCEEDED(res)) {        res = gCharSetManager->GetCharsetLangGroup(charset,          &charSetInfo->mLangGroup);        if (NS_FAILED(res)) {#ifdef NOISY_FONTS          printf("=== cannot get lang group for %s\n", charSetInfo->mCharSet);#endif        }      }    }    nsCAutoString nodeName(foundry);    nodeName.Append('-');    nodeName.Append(familyName);    nodeName.Append('-');    nodeName.Append(charSetName);    nsStringKey key(nodeName);    nsFontNode* node = (nsFontNode*) gNodes->Get(&key);    if (!node) {      node = new nsFontNode;      if (!node) {        continue;      }      gNodes->Put(&key, node);      node->mName = nodeName;      node->mCharSetInfo = charSetInfo;    }    int found = 0;    if (nodeName == previousNodeName) {      found = 1;    }    else {      PRInt32 n = aNodes->Count();      for (PRInt32 j = 0; j < n; j++) {        if (aNodes->GetElement(j) == node) {          found = 1;        }      }    }    previousNodeName = nodeName;    if (!found) {      aNodes->AppendElement(node);    }    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 = node->mStyles[styleIndex];    if (!style) {      style = new nsFontStyle;      if (!style) {        continue;      }      node->mStyles[styleIndex] = style;    }    nsStringKey weightKey(weightName);    int weightNumber = (int) gWeights->Get(&weightKey);    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;    }      nsStringKey setWidthKey(setWidth);    int stretchIndex = (int) gStretches->Get(&setWidthKey);    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-%s-%%d-*-*-*-%s-*-%s",          name, familyName, 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 nsFontGTK*[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 = PR_smprintf("%s", name);    if (!copy) {      continue;    }    nsFontGTK* size = new nsFontGTKNormal();    if (!size) {      continue;    }    stretch->mSizes[stretch->mSizesCount++] = size;    size->mName = copy;    size->mFont = nsnull;    size->mSize = pixels;    size->mBaselineAdjust = 0;    size->mMap = nsnull;    size->mCharSetInfo = charSetInfo;  }  XFreeFontNames(list);#ifdef DEBUG_DUMP_TREE  DumpTree();#endif}