if ((!list[i]) || (list[i][0] != '-')) {
if ((!list[i]) || (list[i][0] != '-') || (PL_strpbrk(list[i], "*?") != nsnull)) {
GetFontNames(const char* aPattern, PRBool aAnyFoundry, nsFontNodeArrayXlib* aNodes){  Display *dpy = xxlib_rgb_get_display(gXlibRgbHandle);  Screen  *scr = xxlib_rgb_get_screen (gXlibRgbHandle);#ifdef NS_FONT_DEBUG_CALL_TRACE  if (gFontDebug & NS_FONT_DEBUG_CALL_TRACE) {    printf("GetFontNames %s\n", aPattern);  }#endif#ifdef USE_FREETYPE  // get FreeType fonts  nsFT2FontCatalog::GetFontNames(aPattern, aNodes);#endif /* USE_FREETYPE */  nsCAutoString previousNodeName;  nsHashtable* node_hash;  if (aAnyFoundry) {    NS_ASSERTION(aPattern[1] == '*', "invalid 'anyFoundry' pattern");    node_hash = gAFRENodes;  }  else {    node_hash = gFFRENodes;  }#ifdef USE_XPRINT#ifdef DEBUG  if(nsFontMetricsXlib::mPrinterMode)  {    if (!dpy)    {      NS_ERROR("Obtaining font information without having a |Display *|");      abort(); /* DIE!! */    }      if (XpGetContext(dpy) == None)    {      /* applications must not make any assumptions about fonts _before_ XpSetContext() !!! */      NS_ERROR("Obtaining font information without valid print context (XListFonts()) _before_ XpSetContext()");      abort(); /* DIE!! */    }      }               #endif /* DEBUG */#endif /* USE_XPRINT */  #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 ...   */#ifdef USE_XPRINT  if (nsFontMetricsXlib::mPrinterMode) {    Bool success;    long dpi = 0;    success = XpuGetResolution(dpy, XpGetContext(dpy), &dpi);    NS_ASSERTION(success, "XpuGetResolution(dpy, XpGetContext(dpy), &dpi); failure!");    screen_xres = screen_yres = dpi;  }  else#endif /* USE_XPRINT */  {      screen_xres = int(((( double(::XWidthOfScreen(scr)))  * 25.4 / double(::XWidthMMOfScreen(scr)) ))  + 0.5);    screen_yres = int(((( double(::XHeightOfScreen(scr))) * 25.4 / double(::XHeightMMOfScreen(scr)) )) + 0.5);  }#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(dpy, 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 */    if ((!list[i]) || (list[i][0] != '-')) {      continue;    }    strcpy(name, list[i]);        char *p = name + 1;    PRBool scalable       = PR_FALSE,           outline_scaled = PR_FALSE;#ifdef USE_XPRINT    PRBool builtin_printer_font = PR_FALSE;    int    resX = -1,           resY = -1;#endif /* USE_XPRINT */#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 = PR_TRUE;    }    FIND_FIELD(pointSize);    if (pointSize[0] == '0') {      scalable = PR_TRUE;    }    FIND_FIELD(resolutionX);#ifdef USE_XPRINT    resX = atoi(resolutionX);    NS_ASSERTION(!(resolutionX[0] != '0' && resX == 0), "atoi(resolutionX) failure.");#endif /* USE_XPRINT */    if (resolutionX[0] == '0') {      scalable = PR_TRUE;    }    FIND_FIELD(resolutionY);#ifdef USE_XPRINT    resY = atoi(resolutionY);    NS_ASSERTION(!(resolutionY[0] != '0' && resY == 0), "atoi(resolutionY) failure.");#endif /* USE_XPRINT */    if (resolutionY[0] == '0') {      scalable = PR_TRUE;    }    /* check if bitmap non-scaled font */    if ((pixelSize[0] != '0') || (pointSize[0] != '0')) {      SCALED_FONT_PRINTF(("bitmap (non-scaled) font: %s", list[i]));    }    /* 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", list[i]));    }    /* 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", list[i]));    }    else {      SCALED_FONT_PRINTF(("unexpected font values: %s", list[i]));      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);#ifdef USE_XPRINT    /* I am not sure what Xprint built-in printer fonts exactly look like     * (usually '-adobe-helvetica-medium-r-normal--50-120-300-300-p-0-iso8859-1'     * for a 300DPI printer) - but this test is good enough (except when     * someone installs 300DPI bitmap (!!) fonts on a system... =:-)     */    if (nsFontMetricsXlib::mPrinterMode &&        averageWidth[0] == '0' &&         resX >= screen_xres    &&         resY >= screen_yres) {      builtin_printer_font = PR_TRUE;      /* Treat built-in printer fonts like outline-scaled ones... */      outline_scaled = PR_TRUE;      PR_LOG(FontMetricsXlibLM, PR_LOG_DEBUG, ("This may be a built-in printer font '%s'\n", list[i]));    }#endif /* USE_XPRINT */    if (averageWidth[0] == '0') {      scalable = PR_TRUE;/* 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       * The only "legal" use for this type of XLFD are Xprint       * build-in printer fonts.like       * -adobe-times-medium-r-normal--50-120-300-300-p-0-iso8859-1       * (300DPI printer)       */      if ((pixelSize[0] != '0' || pointSize[0] != 0) &&           (outline_scaled == PR_FALSE)#ifdef USE_XPRINT           && (builtin_printer_font == PR_FALSE)#endif /* USE_XPRINT */                    ) {        PR_LOG(FontMetricsXlibLM, 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(dpy),              screen_xres,              screen_yres,#ifdef USE_XPRINT              nsFontMetricsXlib::mPrinterMode?("printer"):#endif /* USE_XPRINT */              ("display")              );#undef BOOL2STR                        if (gFontRejectRegEx) {        /* reject font if reject pattern matches it... */                if (regexec(gFontRejectRegEx, fmatchbuf, 0, nsnull, 0) == REG_OK) {          PR_LOG(FontMetricsXlibLM, 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(FontMetricsXlibLM, 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 */        nsFontCharSetMapXlib *charSetMap = GetCharSetMap(charSetName);    nsFontCharSetInfoXlib* 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(nsFontCharSetMapXlib*, 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);    nsFontNodeXlib* node = (nsFontNodeXlib*) node_hash->Get(&key);    if (!node) {      node = new nsFontNodeXlib;      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;    }    nsFontStyleXlib* 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);    nsFontWeightXlib* 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--;    nsFontStretchXlib* stretch = NodeGetStretch(weight, stretchIndex);    if (!stretch)      continue;    if (scalable) {      if (!NodeAddScalable(stretch, outline_scaled,#ifdef USE_XPRINT                           builtin_printer_font, resX, resY, #endif /* USE_XPRINT */                           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}