Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8126453

Inconsistent list of font families when using Font API

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8
    • 7u6
    • javafx
    • JavaFX 2.2 b15

      I'm trying to build a list of available font families in order to implement a Font picker. I discovered that you get different results depending on which API call you use.
      For instance, if you do 1.:

              Font f = Font.getDefault();
              double defSize = f.getSize();
              Set<Font> allFonts = new TreeSet<Font>(Fonts.fontComparator);

              for (String familly : Font.getFamilies()) {
                  for (String name : Font.getFontNames(familly)) {
                      Font font = new Font(name, defSize);
                      allFonts.add(font);
                  }
              }

      then extract a set of families from the list of fonts in allFonts, you don't get the same result as if you do 2.:

              for (String name : Font.getFontNames()) {
                  Font font = new Font(name, defSize);
                  allFonts.add(font);
              }

      then extract a set of families from the list of fonts in allFonts.

      On my windows machine, if I use 1. then my list of families does not contain "Lucida Sans", but if I use 2. it does.

      Shouldn't both sets be the same in the end? Why aren't they?

            prr Philip Race
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: