Css 无法加载字体面javafx
我有一个小问题,我使用Javafx,只是把图标放在一个文本中。 所以我找到了这篇文章,它可以帮助我: Derek给出的解决方案是可行的,但当我尝试将我的样式放入css时,它不起作用:Css 无法加载字体面javafx,css,javafx,material-design,font-awesome,font-face,Css,Javafx,Material Design,Font Awesome,Font Face,我有一个小问题,我使用Javafx,只是把图标放在一个文本中。 所以我找到了这篇文章,它可以帮助我: Derek给出的解决方案是可行的,但当我尝试将我的样式放入css时,它不起作用: @font-face { src: url(typeface/fontawesome-webfont.ttf); } @font-face { font-family: 'Indie Flower'; src: url(http://fonts.googleapis.com/css?family=I
@font-face {
src: url(typeface/fontawesome-webfont.ttf);
}
@font-face {
font-family: 'Indie Flower';
src: url(http://fonts.googleapis.com/css?family=Indie+Flower);
}
@font-face {
src: url(typeface/govicons-webfont.ttf);
}
@font-face {
src: url(typeface/fontawesome-webfont.ttf);
}
@font-face {
font-family: "MaterialIcons";
src: url(typeface/MaterialIcons-Regular.ttf);
}
#i {
-fx-font-family: 'Indie Flower';
-fx-font-size: 80;
-fx-fill: forestgreen;
}
#love {
-fx-font-family: "MaterialIcons";
-fx-font-size: 60;
-fx-fill: firebrick;
}
#u {
-fx-font-family: "Indie Flower";
-fx-font-size: 80;
-fx-fill: forestgreen;
}
然后这是我的java类,我把所有的东西都称为:
public class Test extends Application {
@Override
public void start(Stage stage) {
System.setProperty("http.proxyHost", "myProxy");
System.setProperty("https.proxyHost", "myProxy");
System.setProperty("http.proxyPort", "myPort");
System.setProperty("https.proxyPort", "myPort");
Text i = new Text("I");
Text love = new Text("\uE87D");
Text u = new Text("you");
u.setId("u");
i.setId("i");
love.setId("love");
i.getStyleClass().add("i");
love.getStyleClass().add("love");
u.getStyleClass().add("u");
TextFlow textFlow = new TextFlow(i, love, u);
textFlow.setStyle("-fx-padding: 20px; -fx-background-color: azure;");
Scene scene = new Scene(textFlow);
final File externalCSSFile = new File("resources/Style.css");
// Get style from external CSS
scene.getStylesheets().add("file:///" +
externalCSSFile.getAbsolutePath().replace("\\", "/"));
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
当然,名为的文件以正确的路径存在。
因此,如果您知道它不起作用,请帮助我:)实际问题是什么?问题是文本的字体和图标没有加载,我有一个基本的文本字体,而图标没有。。。