最近我正在学习gluon mobile,发现iphone 5S模拟器中标签的字体具有有线功能。
按照“ Comments”的教程,创建了一个名为“ EditionView”的视图,并在其中添加了两个标签,然后在.root
中设置字体,如下所示:
-fx-font-family: "Hiragino Sans", Roboto, "System Regular";
在edition.css
中,我将.label
设置如下:
.label {
-fx-text-fill: -primary-swatch-700;
-fx-font-size: 20;
-fx-background-color: yellow;
}
这是我的版本。fmxl:
<?xml version="1.0" encoding="UTF-8"?>
<?import com.gluonhq.charm.glisten.mvc.View?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<View fx:id="edition" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="350.0" stylesheets="@edition.css" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.freedom.demo.views.EditionPresenter">
<center>
<VBox prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
<children>
<Label maxWidth="1.7976931348623157E308" text="名字:">
<VBox.margin>
<Insets bottom="10.0" left="10.0" top="10.0" />
</VBox.margin>
</Label>
<TextField fx:id="authorText">
<VBox.margin>
<Insets left="5.0" />
</VBox.margin>
</TextField>
<Label maxWidth="1.7976931348623157E308" text="评论:">
<VBox.margin>
<Insets bottom="10.0" left="10.0" top="10.0" />
</VBox.margin>
</Label>
<TextArea fx:id="commentsText" prefHeight="108.0" prefWidth="350.0">
</TextArea>
<HBox alignment="CENTER" prefHeight="41.0" prefWidth="350.0" spacing="20.0" styleClass="buttonsHbox">
<children>
<Button fx:id="submit" mnemonicParsing="false" text="提交" />
<Button mnemonicParsing="false" text="取消" />
</children>
<VBox.margin>
<Insets left="10.0" right="10.0" top="30.0" />
</VBox.margin>
</HBox>
</children>
<padding>
<Insets bottom="20.0" left="15.0" right="15.0" top="20.0" />
</padding>
</VBox>
</center>
</View>
当我切换到版本视图时,得到以下结果:
第一个标签正确显示,而第二个标签不正确! 您能解释一下为什么发生这种情况吗?
我已通过@font-face
导入我自己的中文字体家族来解决此问题。仍然不知道在使用Hiragino Sans
时哪里出了错,+--- com.gluonhq:charm:5.0.0
| +--- com.gluonhq:connect:1.4.4
| | \--- org.glassfish:javax.json:1.0.4
| +--- com.gluonhq:charm-cloudlink-client:4.4.7
| | +--- com.gluonhq:connect:1.4.4 (*)
| | +--- com.gluonhq:charm-down-plugin-device:3.6.0
| | | \--- com.gluonhq:charm-down-core:3.6.0 -> 3.8.0
| | +--- com.gluonhq:charm-down-plugin-in-app-billing:3.6.0
| | | \--- com.gluonhq:charm-down-core:3.6.0 -> 3.8.0
| | +--- com.gluonhq:charm-down-plugin-push-notifications:3.6.0
| | | +--- com.gluonhq:charm-down-core:3.6.0 -> 3.8.0
| | | \--- com.gluonhq:charm-down-plugin-runtime-args:3.6.0
| | | \--- com.gluonhq:charm-down-core:3.6.0 -> 3.8.0
| | \--- com.gluonhq:charm-down-plugin-storage:3.6.0 -> 3.8.0
| | \--- com.gluonhq:charm-down-core:3.8.0
| +--- com.gluonhq:charm-glisten-connect-view:5.0.0
| | +--- com.gluonhq:charm-cloudlink-client:4.4.7 (*)
| | \--- com.gluonhq:charm-glisten:5.0.0
| | +--- com.gluonhq:charm-down-plugin-display:3.8.0
| | | \--- com.gluonhq:charm-down-core:3.8.0
| | +--- com.gluonhq:charm-down-plugin-lifecycle:3.8.0
| | | \--- com.gluonhq:charm-down-core:3.8.0
| | +--- com.gluonhq:charm-down-plugin-statusbar:3.8.0
| | | \--- com.gluonhq:charm-down-core:3.8.0
| | \--- com.gluonhq:charm-down-plugin-storage:3.8.0 (*)
| \--- com.gluonhq:charm-glisten:5.0.0 (*)
+--- com.google.guava:guava:26.0 FAILED
+--- com.gluonhq:charm-down-plugin-display:3.8.0 (*)
+--- com.gluonhq:charm-down-plugin-lifecycle:3.8.0 (*)
+--- com.gluonhq:charm-down-plugin-statusbar:3.8.0 (*)
+--- com.gluonhq:charm-down-plugin-storage:3.8.0 (*)
\--- com.gluonhq:robovm-cocoatouch:2.3.1-ios11
\--- com.gluonhq:robovm-objc:2.3.1-ios11
是内置在iphone模拟器中的,应该支持所有汉字。
================================= ps:这是我的依赖树:
{{1}}