本文整理汇总了Java中javafx.scene.text.Font.loadFont方法的典型用法代码示例。如果您正苦于以下问题:Java Font.loadFont方法的具体用法?Java Font.loadFont怎么用?Java Font.loadFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.text.Font
的用法示例。
在下文中一共展示了Font.loadFont方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadFonts
import javafx.scene.text.Font; //导入方法依赖的package包/类
private void loadFonts() {
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-Black.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-BlackItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-Bold.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-BoldItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/RobotoCondensed-Bold.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/RobotoCondensed-BoldItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/RobotoCondensed-Italic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/RobotoCondensed-Light.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/RobotoCondensed-LightItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/RobotoCondensed-Regular.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-Italic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-Light.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-LightItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-Medium.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-MediumItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-Regular.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-Thin.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto/Roboto-ThinItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-Bold.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-BoldItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-Italic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-Light.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-LightItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-Medium.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-MediumItalic.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-Regular.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-Thin.ttf"), 14);
Font.loadFont(getClass().getResourceAsStream("fonts/roboto_mono/RobotoMono-ThinItalic.ttf"), 14);
}
示例2: initializeFonts
import javafx.scene.text.Font; //导入方法依赖的package包/类
void initializeFonts() {
infoFont = Font.loadFont(ClassLoader.getSystemResource("Orbitron-Regular.ttf").toExternalForm(), mGridDimension * 0.75);
turnsFont = Font.loadFont(ClassLoader.getSystemResource("Orbitron-Regular.ttf").toExternalForm(), mGridDimension * 0.6);
playerFont = Font.font("Helvetica", FontWeight.NORMAL, mGridDimension * 0.45);
messageFont = Font.loadFont(ClassLoader.getSystemResource("Orbitron-Regular.ttf").toExternalForm(), mGridDimension * 0.35);
menuFont = Font.loadFont(ClassLoader.getSystemResource("Orbitron-Regular.ttf").toExternalForm(), mGridDimension * 0.35);
}
示例3: start
import javafx.scene.text.Font; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
Font.loadFont(getClass().getClassLoader().getResource
("FontAwesome.otf").toExternalForm(), 10);
Game game = new Game();
Pane boardPane = loadBoardPane(game);
Pane topPane = loadTopPane(game);
Pane rightPane = loadRightPane(game);
BorderPane root = new BorderPane();
root.setRight(rightPane);
root.setCenter(boardPane);
root.setTop(topPane);
primaryStage.setTitle("Gomoku");
primaryStage.setScene(new Scene(root, 800, 600));
primaryStage.setMinWidth(800);
primaryStage.setMinHeight(600);
primaryStage.getIcons().add(new Image(getClass().getClassLoader()
.getResource("AppIcon.png").toExternalForm()));
primaryStage.show();
primaryStage.setOnCloseRequest(event -> {
game.stop();
});
}
示例4: MainController
import javafx.scene.text.Font; //导入方法依赖的package包/类
/**
* @param mainView
* the view to be used by this controller
*/
public MainController(final MainView mainView) {
this.mainView = mainView;
Font.loadFont(MainController.class.getResource("/com/msc/serverbrowser/fonts/FontAwesome.otf").toExternalForm(), 12);
configureMenuItems();
registerBottomBarHyperlinks();
}
示例5: loadFonts
import javafx.scene.text.Font; //导入方法依赖的package包/类
/** Load all fonts from 'assets/fonts'. **/
private void loadFonts() {
try (DirectoryStream<Path> directoryStream =
Files.newDirectoryStream(Main.getInstance().getPluginProxy().getAssetsDirPath().resolve("fonts"))) {
for (Path fontPath : directoryStream) {
if (fontPath.getFileName().toString().endsWith(".ttf")) {
Font.loadFont(Files.newInputStream(fontPath), 10);
}
}
} catch (IOException e) {
Main.log(e);
}
Balloon.setDefaultFont(Main.getProperties().getString("balloon.font"));
LocalFont.setDefaultFont(Main.getProperties().getString("interface.font"));
}
示例6: registerFont
import javafx.scene.text.Font; //导入方法依赖的package包/类
public void registerFont(String fontUrl, String name) {
Font.loadFont(fontUrl, 14);
}
示例7: init
import javafx.scene.text.Font; //导入方法依赖的package包/类
/**
* 初始化游戏字体
*/
@Override
public void init() {
Font.loadFont(Game2048.class.getClassLoader().getResource(TTF).toExternalForm(), 10.0);
}
示例8: loadFont
import javafx.scene.text.Font; //导入方法依赖的package包/类
/**
* Load a font from Google Web Fonts Service
*
* Note: this is only designed to work with simple stylesheets with single
* font in them.
*
* @param googleFontCssUrl The url to css stylesheet with @fontface
* definition
* @return The name of the font family, or "System" if there was a error
* @throws java.net.MalformedURLException
*/
public static String loadFont(String googleFontCssUrl) throws MalformedURLException {
String fontName = "System";
try {
URL cssUrl = new URL(googleFontCssUrl);
URLConnection con = cssUrl.openConnection();
InputStream in = con.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
String fontUrl = null;
StringBuilder srcs = new StringBuilder();
while ((line = reader.readLine()) != null) {
// System.out.println(line);
if (line.contains("src:")) {
Matcher matcher = TTF_PATTERN.matcher(line);
if (matcher.find()) {
fontUrl = matcher.group(0);
// System.out.println("FOUND fontUrl = " + fontUrl);
break;
}
matcher = OTF_PATTERN.matcher(line);
if (matcher.find()) {
fontUrl = matcher.group(0);
// System.out.println("FOUND fontUrl = " + fontUrl);
break;
}
srcs.append(line);
srcs.append('\n');
}
}
if (fontUrl != null) {
Font font = Font.loadFont(fontUrl, 10);
fontName = font.getFamily();
} else {
System.err.println("Failed to find any supported fonts "
+ "(TTF or OTF) in CSS src:\n" + srcs.toString());
}
} catch (IOException ex) {
Logger.getLogger(WebFontEncoder.class.getName()).log(Level.SEVERE, null, ex);
}
return fontName;
}