java fx 加载css,使用JavaFX 8和css加载自定义字体

Note that the below will work only with Java versions >= 1.8u60

我遇到了同样的问题.在JavaFX 8中加载CSS的方法是设置字体表面文件,然后使用字体名称作为参考,可以通过预览字体找到.

字体文件相对于CSS.我有根设置字体,但您可以删除它并保留每个节点.

CSS code

@font-face {

src: url("freeuniverse2.ttf"),

}

.root {

-fx-background-color: gray;

-fx-font-family: "Free Universe 2";

}

#window {

-fx-border-image-source: url("images/windowfill.png");

-fx-border-image-slice: 17 6 13 6 fill;

-fx-border-image-width: 17 6 13 6 ;

-fx-background-color: gray;

}

.text {

-fx-text-fill: white;

-fx-font-size: 16px;

-fx-font-family: "Free Universe 2";

-fx-background-color: transparent;

}

.pane {

-fx-border-image-source: url("images/windowfill.png");

-fx-border-image-slice: 17 6 13 6 fill;

-fx-border-image-width: 17 6 13 6 ;

-fx-background-color: gray;

}

.vbox {

-fx-border-image-source: url("images/windowfill.png");

-fx-border-image-slice: 17 6 13 6 fill;

-fx-border-image-width: 17 6 13 6 ;

-fx-background-color: gray;

}

#title-text {

-fx-text-fill: white;

-fx-font-size: 36px;

-fx-font-family: "Free Universe 2";

}

.label {

-fx-text-fill: white;

-fx-font-size: 16px;

-fx-font-family: "Free Universe 2";

-fx-background-color: transparent;

}

Font File Preview(Below you can see the real Font Name)

0Q1zq.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值