if ((!name) || (name[0] != '-')) {
if ((!name) || (name[0] != '-') || (PL_strpbrk(name, "*?") != nsnull)) {
GetFontNames(const char* aPattern, PRBool aAnyFoundry, nsFontNodeArray* aNodes){#ifdef NS_FONT_DEBUG_CALL_TRACE  if (gFontDebug & NS_FONT_DEBUG_CALL_TRACE) {    printf("GetFontNames %s\n", aPattern);  }#endif  // get FreeType fonts  nsFT2FontCatalog::GetFontNames(aPattern, aNodes);  nsCAutoString previousNodeName;  nsHashtable* node_hash;  if (aAnyFoundry) {    NS_ASSERTION(aPattern[1] == '*', "invalid 'anyFoundry' pattern");    node_hash = gAFRENodes;  }  else {    node_hash = gFFRENodes;  }  #ifdef ENABLE_X_FONT_BANNING  int  screen_xres,       screen_yres;  /* Get Xserver DPI.    * We cannot use Mozilla's API here because it may "override" the DPI   * got from the Xserver via prefs. But we want to filter ("ban") fonts   * we get from the Xserver which _it_(=Xserver) has "choosen" for us   * using its DPI value ...   */  screen_xres = int((float(::gdk_screen_width())  / (float(::gdk_screen_width_mm())  / 25.4f)) + 0.5f);  screen_yres = int((float(::gdk_screen_height()) / (float(::gdk_screen_height_mm()) / 25.4f)) + 0.5f);#endif /* ENABLE_X_FONT_BANNING */        BANNED_FONT_PRINTF(("Loading font '%s'", aPattern));  /*   * We do not use XListFontsWithInfo here, because it is very expensive.   * Instead, we get that info at the time when we actually load the font.   */  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[256]; /* X11 font names are never larger than 255 chars */    strcpy(name, list[i]);     if ((!name) || (name[0] != '-')) {      continue;    }        char buf[512];    PL_strncpyz(buf, name, sizeof(buf));    char *fName = buf;    char* p = name + 1;    int scalable = 0;    PRBool outline_scaled = PR_FALSE;#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;    }    // check if bitmap non-scaled font    if ((pixelSize[0] != '0') || (pointSize[0] != '0')) {      SCALED_FONT_PRINTF(("bitmap (non-scaled) font: %s", fName));    }    // check if bitmap scaled font    else if ((pixelSize[0] == '0') && (pointSize[0] == '0')          && (resolutionX[0] != '0') && (resolutionY[0] != '0')) {      SCALED_FONT_PRINTF(("bitmap scaled font: %s", fName));    }    // check if outline scaled font    else if ((pixelSize[0] == '0') && (pointSize[0] == '0')          && (resolutionX[0] == '0') && (resolutionY[0] == '0')) {      outline_scaled = PR_TRUE;      SCALED_FONT_PRINTF(("outline scaled font: %s", fName));    }    else {      SCALED_FONT_PRINTF(("unexpected font values: %s", fName));      SCALED_FONT_PRINTF(("      pixelSize[0] = %c", pixelSize[0]));      SCALED_FONT_PRINTF(("      pointSize[0] = %c", pointSize[0]));      SCALED_FONT_PRINTF(("    resolutionX[0] = %c", resolutionX[0]));      SCALED_FONT_PRINTF(("    resolutionY[0] = %c", resolutionY[0]));      static PRBool already_complained = PR_FALSE;      // only complaing once       if (!already_complained) {        already_complained = PR_TRUE;        NS_ASSERTION(pixelSize[0] == '0', "font scaler type test failed");        NS_ASSERTION(pointSize[0] == '0', "font scaler type test failed");        NS_ASSERTION(resolutionX[0] == '0', "font scaler type test failed");        NS_ASSERTION(resolutionY[0] == '0', "font scaler type test failed");      }    }    FIND_FIELD(spacing);    FIND_FIELD(averageWidth);    if (averageWidth[0] == '0') {      scalable = 1;/* Workaround for bug 103159 ("sorting fonts by foundry names cause font * size of css ignored in some cases"). * Hardcoded font ban until bug 104075 ("need X font banning") has been * implemented. See http://bugzilla.mozilla.org/show_bug.cgi?id=94327#c34 * for additional comments... */      #ifndef DISABLE_WORKAROUND_FOR_BUG_103159      // skip 'mysterious' and 'spurious' cases like      // -adobe-times-medium-r-normal--17-120-100-100-p-0-iso8859-9      if ((pixelSize[0] != '0' || pointSize[0] != 0) &&           (outline_scaled == PR_FALSE)) {        PR_LOG(FontMetricsGTKLM, PR_LOG_DEBUG, ("rejecting font '%s' (via hardcoded workaround for bug 103159)\n", list[i]));        BANNED_FONT_PRINTF(("rejecting font '%s' (via hardcoded workaround for bug 103159)", list[i]));                  continue;      }  #endif /* DISABLE_WORKAROUND_FOR_BUG_103159 */    }    char* charSetName = p; // CHARSET_REGISTRY & CHARSET_ENCODING    if (!*charSetName) {      continue;    }#ifdef ENABLE_X_FONT_BANNING#define BOOL2STR(b) ((b)?("true"):("false"))        if (gFontRejectRegEx || gFontAcceptRegEx) {      char fmatchbuf[512]; /* See sprintf() below. */                 sprintf(fmatchbuf, "fname=%s;scalable=%s;outline_scaled=%s;xdisplay=%s;xdpy=%d;ydpy=%d;xdevice=%s",              list[i], /* full font name */              BOOL2STR(scalable),               BOOL2STR(outline_scaled),              XDisplayString(GDK_DISPLAY()),              screen_xres,              screen_yres,              "display" /* Xlib gfx supports other devices like "printer", too - DO NOT REMOVE! */              );#undef BOOL2STR                        if (gFontRejectRegEx) {        /* reject font if reject pattern matches it... */                if (regexec(gFontRejectRegEx, fmatchbuf, 0, nsnull, 0) == REG_OK) {          PR_LOG(FontMetricsGTKLM, PR_LOG_DEBUG, ("rejecting font '%s' (via reject pattern)\n", fmatchbuf));          BANNED_FONT_PRINTF(("rejecting font '%s' (via reject pattern)", fmatchbuf));          continue;        }        }      if (gFontAcceptRegEx) {        if (regexec(gFontAcceptRegEx, fmatchbuf, 0, nsnull, 0) == REG_NOMATCH) {          PR_LOG(FontMetricsGTKLM, PR_LOG_DEBUG, ("rejecting font '%s' (via accept pattern)\n", fmatchbuf));          BANNED_FONT_PRINTF(("rejecting font '%s' (via accept pattern)", fmatchbuf));          continue;        }      }           }    #endif /* ENABLE_X_FONT_BANNING */        nsFontCharSetMap *charSetMap = GetCharSetMap(charSetName);    nsFontCharSetInfo* charSetInfo = charSetMap->mInfo;    // indirection for font specific charset encoding     if (charSetInfo == &Special) {      nsCAutoString familyCharSetName(familyName);      familyCharSetName.Append('-');      familyCharSetName.Append(charSetName);      nsCStringKey familyCharSetKey(familyCharSetName);      charSetMap = NS_STATIC_CAST(nsFontCharSetMap*, gSpecialCharSets->Get(&familyCharSetKey));      if (!charSetMap)        charSetMap = gNoneCharSetMap;      charSetInfo = charSetMap->mInfo;    }    if (!charSetInfo) {#ifdef NOISY_FONTS      printf("cannot find charset %s\n", charSetName);#endif      charSetInfo = &Unknown;    }    SetCharsetLangGroup(charSetInfo);    SetFontLangGroupInfo(charSetMap);    nsCAutoString nodeName;    if (aAnyFoundry)      nodeName.Assign('*');    else      nodeName.Assign(foundry);    nodeName.Append('-');    nodeName.Append(familyName);    nodeName.Append('-');    nodeName.Append(charSetName);    nsCStringKey key(nodeName);    nsFontNode* node = (nsFontNode*) node_hash->Get(&key);    if (!node) {      node = new nsFontNode;      if (!node) {        continue;      }      node_hash->Put(&key, node);      node->mName = nodeName;      node->mCharSetInfo = charSetInfo;    }    int found = 0;    if (nodeName == previousNodeName) {      found = 1;    }    else {      found = (aNodes->IndexOf(node) >= 0);    }    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 = NodeGetStyle(node, styleIndex);    if (!style)      continue;    nsCStringKey weightKey(weightName);    int weightNumber = NS_PTR_TO_INT32(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 = NodeGetWeight(style, weightIndex);    if (!weight)      continue;      nsCStringKey setWidthKey(setWidth);    int stretchIndex = NS_PTR_TO_INT32(gStretches->Get(&setWidthKey));    if (!stretchIndex) {#ifdef NOISY_FONTS      printf("cannot find stretch %s\n", setWidth);#endif      stretchIndex = 5;    }    stretchIndex--;    nsFontStretch* stretch = NodeGetStretch(weight, stretchIndex);    if (!stretch)      continue;    if (scalable) {      if (!NodeAddScalable(stretch, outline_scaled, name, familyName,            weightName, slant, setWidth, addStyle, spacing, charSetName))        continue;    }      // get pixel size before the string is changed    int pixels = atoi(pixelSize);    p = name;    while (p < charSetName) {      if (!*p) {        *p = '-';      }      p++;    }     if (pixels) {      if (!NodeAddSize(stretch, pixels, name, charSetInfo))        continue;    }  }  XFreeFontNames(list);#ifdef DEBUG_DUMP_TREE  DumpTree();#endif}