当前位置: 首页>>代码示例>>Java>>正文


Java Font.loadFont方法代码示例

本文整理汇总了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);

}
 
开发者ID:ulriknyman,项目名称:H-Uppaal,代码行数:33,代码来源:HUPPAAL.java

示例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);
    }
 
开发者ID:nwg-piotr,项目名称:EistReturns,代码行数:9,代码来源:Utils.java

示例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();
    });
}
 
开发者ID:haslam22,项目名称:gomoku,代码行数:28,代码来源:Main.java

示例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();
}
 
开发者ID:Bios-Marcel,项目名称:ServerBrowser,代码行数:11,代码来源:MainController.java

示例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"));
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:16,代码来源:App.java

示例6: registerFont

import javafx.scene.text.Font; //导入方法依赖的package包/类
public void registerFont(String fontUrl, String name) {
    Font.loadFont(fontUrl, 14);
}
 
开发者ID:jdesive,项目名称:textmd,代码行数:4,代码来源:Fonts.java

示例7: init

import javafx.scene.text.Font; //导入方法依赖的package包/类
/**
 * 初始化游戏字体
 */
@Override
public void init() {
    Font.loadFont(Game2048.class.getClassLoader().getResource(TTF).toExternalForm(), 10.0);
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:8,代码来源:Game2048.java

示例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;
    }
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:55,代码来源:WebFontEncoder.java


注:本文中的javafx.scene.text.Font.loadFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。