css - Java FX 为 2 种语言使用 2 种字体
问题描述
我的 Java FX 应用程序包含英语和希伯来语文本,我想将Roboto用于英语文本,将Noto Sans 希伯来语用于希伯来语文本。
我想出的代码不起作用,如下所述,代码:
// java
Parent root = new VBox() {{
getChildren().addAll(
new Label("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"),
new Label("the quick brown fox jumps over the lazy dog"),
new Label("השפן טעם ביס ואכל קצת גזר חד")
);
}};
primaryStage.setScene(new Scene(root) {{
getStylesheets().add(getClass().getResource("style.css").toExternalForm());
}});
primaryStage.show();
// style.css
@font-face {
src: url('Roboto-Regular.ttf');
}
@font-face {
src: url('NotoSansHebrew-Regular.ttf');
}
.root {
/* Attempt 1 - it only takes the first one */
-fx-font-family: "Roboto" "Noto Sans Hebrew";
/* Attempt 2 - it only takes the last one */
-fx-font-family: "Roboto";
-fx-font-family: "Noto Sans Hebrew";
}
解决方案
推荐阅读
- mysql - 为什么 my.ini 文件中的更改不影响?
- javascript - React,写handleInputChange函数更优雅
- linux - 将命令结果输出到 txt 文件
- vue.js - Vue 无法从库中读取未定义的属性“扩展”
- python - cqlsh 和 Python cassandra 驱动程序中最大时间 uuid 的差异
- python - 有人可以解释为什么 .asp 链接会出现奇怪的行为吗?
- angularjs - AngularJS 1.4 全面升级到 Angular 8。我应该迁移到 1.5 然后升级还是重写?
- c++ - 我的函数因式分解程序存在变量问题,显示不正确的答案
- python - 如何拉伸 matplotlib 频谱图的 x 轴?
- r - valueBox 显示使用反应函数从 selectInput 中选择的列的最大值