For a project I am currently working on in JavaFX, I want the user to be able to enter a name of a Deck which can contain multiple languages (e.g. 日本語 N4 Vocab).
To be able to display fonts from multiple languages correctly, I tried specifying multiple fonts in the css of a textfield like this in a stack:
.text-field {
-fx-font-family: "Work Sans", "Noto Sans JP";
}
But I realised that JavaFX does not support comma-separated series of font family names in the -fx-font-family property.
So I have a few questions:
- Is using fallback fonts as above the correct way to support using multiple fonts for a Label / TextField?
- If it is, how do I go around this limitation to implement this feature.
- If not, what else should I do to improve the rendering of multi-language Strings in JavaFX?
Update | This is what I tried:
@font-face {
src: url('WorkSans-Regular.ttf');
}
@font-face {
src: url('WorkSans-Bold.ttf');
}
@font-face {
src: url('NotoSans-Regular.ttf');
}
.text-area {
-fx-font-size: 30;
-fx-font-family: 'Work Sans';
-fx-font-weight: bold;
}
And this is the what the TextArea displays when unsupported characters are entered:

