ADDITIONAL SYSTEM INFORMATION :
OS: Mac OS X 10.14.2
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
A DESCRIPTION OF THE PROBLEM :
JavaFX 11.0.1: All True Type Collection Fonts (*.ttc) don't display bold or italic when the style is set to "-fx-font-weight: bold;" or "-fx-font-style: italic;".
Other font implementations, i.e. *.ttf, work as expected.
This is a regression from java version 1.8.0_191.
The same problem happens on Fedora29 but not on Windows 10.
REGRESSION : Last worked in version 8u192
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new javafx.scene.text.Text element.
Set the style to a font implemented as a True Type Collection font. i.e. *.ttc, such as Helvetica on Mac OS X with "-fx-font-family: Helvetica;".
Also set the font weight to bold with "-fx-font-weight: bold;" or to italic with "-fx-font-style: italic;" and the text will be displayed as normal. i.e. not bold or italic.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Text should be displayed as bold or italic.
ACTUAL -
Text is displayed as normal.
---------- BEGIN SOURCE ----------
package org.fontbugfx8;
import java.util.List;
import javafx.application.Application;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MainApp extends Application {
private TextFlow info() {
String osInfo = System.getProperty("os.name") + " version: " + System.getProperty("os.version");
String javaVersion = "Java version: " + System.getProperty("java.version");
Text textInfo = new Text(osInfo + " " + javaVersion);
textInfo.setStyle("-fx-font-size: 24px;-fx-fill: #0072c6;");
TextFlow textFlow = new TextFlow(textInfo);
textFlow.setPrefHeight(48);
textFlow.setStyle("-fx-margin: 10px 0 0 0;");
return textFlow;
}
private TextFlow title(String title) {
Text ttfFonts = new Text(title);
ttfFonts.setStyle("-fx-font-size: 24px;-fx-underline: true;");
TextFlow textFlow = new TextFlow(ttfFonts);
textFlow.setPrefHeight(48);
return textFlow;
}
private TextFlow addFontFamily(String fontFamily) {
List<String> fonts = Font.getFontNames(fontFamily);
if (fonts.isEmpty()) { // Font is missing
Text fontMissing = new Text("Font: \"" + fontFamily + "\" is missing");
fontMissing.setStyle("-fx-font-size: 20px;-fx-fill: red;");
TextFlow textFlow = new TextFlow(fontMissing);
textFlow.setPrefHeight(40);
return textFlow;
}
else {
String fontStyle = "-fx-font-family: " + fontFamily + ";-fx-font-size: 20px;";
Text textNormal = new Text(fontFamily + ": normal");
textNormal.setStyle(fontStyle + "-fx-font-weight: normal;");
Text textBold = new Text(" bold");
textBold.setStyle(fontStyle + "-fx-font-weight: bold;");
Text textItalic = new Text(" italic");
textItalic.setStyle(fontStyle + "-fx-font-style: italic;");
TextFlow textFlow = new TextFlow(textNormal, textBold, textItalic);
textFlow.setPrefHeight(40);
return textFlow;
}
}
@Override
public void start(Stage stage) {
VBox view = new VBox();
view.setStyle("-fx-padding: 0 0 0 10px;");
Scene scene = new Scene(view);
stage.setMinWidth(800);
stage.setMinHeight(800);
stage.setTitle("JavaFX 1.8 .ttc fonts work");
stage.setScene(scene);
//
view.getChildren().add(info());
//
view.getChildren().add(title("Test missing font check works"));
view.getChildren().add(addFontFamily("Uknown"));
//
view.getChildren().add(title("Test JavaFX 1.8 .ttf fonts: shows bold and italic"));
view.getChildren().add(addFontFamily("Arial"));
view.getChildren().add(addFontFamily("Courier new"));
view.getChildren().add(addFontFamily("Georgia"));
view.getChildren().add(addFontFamily("Tahoma"));
view.getChildren().add(addFontFamily("Verdana"));
//
view.getChildren().add(title("Test JavaFX 1.8 .ttc fonts bug: shows bold and italic"));
view.getChildren().add(addFontFamily("Helvetica"));
view.getChildren().add(addFontFamily("Helvetica Neue"));
view.getChildren().add(addFontFamily("Lucida Grande"));
view.getChildren().add(addFontFamily("Menlo"));
view.getChildren().add(addFontFamily("Times New Roman"));
//
stage.show();
}
public static void main(String[] args) {
launch(MainApp.class);
}
}
---------- END SOURCE ----------
FREQUENCY : always