JDK-8113844 : Spacing of default bold font is odd
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2011-07-22
  • Updated: 2015-06-16
  • Resolved: 2011-07-22
Related Reports
Duplicate :  
Description
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);
    }
}
Comments
The problem is becasue we want fractional metrics but we were forced to round the rendering position for greyscale to integer metrics to work around horrible artifacts with Intel hardware. The LCD bug you mention is saying that we already have subpixel glyphs but we need to position them properly. The greyscale case is that we don't yet have glyphs tuned to sub-pixel positions. That is covered by RT-14187: Support glyph rasterisation to sub-pixel precision.
22-07-2011