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

Spacing of default bold font is odd

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • None
    • javafx
    • Product: javafx-2.0beta
      Platform: macosx-universal
      Build-Number: 213
      Build-ID: 2011-07-21_13-17-35

      This program produces the bold version of the default font using Font.font(defaultFont.getFamily(), FontWeight.BOLD, defaultFont.getSize()). That is the same font as the one you get with a CSS rule such as -fx-font-weight: bold, so we can expect that people will be seeing it often. On both Windows and Mac the spacing is wrong, as you can see in the attached screenshots. I suspect that the font metrics are being scaled to non-integer widths, but whatever the reason it is obviously not right for the spacing of the same letters to be different depending only on what letters precede them.

      I do not think that this is a problem with sub-pixel positioning as in RT-14423.

      public class DeleteMe extends Application {
          public static void main(String[] args) {
              launch(args);
          }

          @Override public void start(Stage stage) throws Exception {
              Font defaultFont = Font.getDefault();
              Font defaultBold = Font.font(defaultFont.getFamily(), FontWeight.BOLD, defaultFont.getSize());
              Label background = LabelBuilder.create().text("Background color").font(defaultBold).build();
              Label foreground = LabelBuilder.create().text("Foreground color").font(defaultBold).build();
              VBox vbox = VBoxBuilder.create().children(background, foreground).build();
              StageBuilder.create().scene(new Scene(vbox)).visible(true).applyTo(stage);
          }
      }

        1. bold-windows.png
          6 kB
          Eamonn McManus
        2. bold-mac.png
          13 kB
          Eamonn McManus

            prr Philip Race
            emcmanuswse Eamonn McManus (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: