當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。