javafx.scene.text.Font#loadFont ( )源码实例Demo

下面列出了javafx.scene.text.Font#loadFont ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Path-of-Leveling   文件: POELevelFx.java
public void setUpFonts() throws Exception{
    Platform.setImplicitExit( false );
    addTrayIcon();
    Font.loadFont(POELevelFx.class.getResource("/fonts/Fontin-Regular.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/Fontin-Italic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/Fontin-Bold.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/Fontin-SmallCaps.ttf").toExternalForm(), 10);

    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Thin.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-ThinItalic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Regular.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-ThinItalic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-MediumItalic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Medium.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Light.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-LightItalic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Italic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Bold.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-BoldItalic.ttf").toExternalForm(), 10);
}
 
源代码2 项目: exit_code_java   文件: Desktop.java
public static Font loadFont(String fontName, double fontSize) {

        try {
            java.net.URL fontUrl = Desktop.class.getResource(fontName);
            if(fontUrl != null){
                return Font.loadFont(fontUrl.toExternalForm(), fontSize);
            }else{
                return Font.loadFont("file:" + fontName, fontSize);
            }

        } catch(IllegalArgumentException | NullPointerException s) {
            Logger.warn("\""+ fontName +"\" was not found. Using default font");
            return Font.loadFont("/resources/fonts/Roboto-Regular.ttf", fontSize);

        }
    }
 
源代码3 项目: exit_code_java   文件: Main.java
public static Font loadFont(String fontName, double fontSize) {
        if (fontName == null) {
            return Font.loadFont("/resources/fonts/Roboto-Regular.ttf", fontSize);
        }

    try {
        java.net.URL fontUrl = Main.class.getResource(fontName);
        if(fontUrl != null) {
            return Font.loadFont(fontUrl.toExternalForm(), fontSize);
        } else {
            return Font.loadFont("file:" + fontName, fontSize);
        }

    } catch(IllegalArgumentException | NullPointerException s) {
        Logger.warn("\""+ fontName +"\" was not found. Using default font");
        return Font.loadFont("/resources/fonts/Roboto-Regular.ttf", fontSize);
    }
}
 
源代码4 项目: DeskChan   文件: App.java
/** Load all fonts from 'assets/fonts'. **/
private void loadFonts() {
	File[] fonts = Main.getPluginProxy().getAssetsDirPath().resolve("fonts").listFiles();
	if (fonts != null) {
		try {
			for (File fontPath : fonts) {
				if (fontPath.getName().endsWith(".ttf")) {
					Font.loadFont(new FileInputStream(fontPath), 10);
				}
			}
		} catch (IOException e) {
			Main.log(e);
		}
	}
	LocalFont.setDefaultFont(Main.getProperties().getString("interface.font"));
	CharacterBalloon.setDefaultFont(Main.getProperties().getString("balloon.font"));
}
 
源代码5 项目: Enzo   文件: SimpleLineChartSkin.java
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.06 * PREFERRED_HEIGHT)); // "OpenSans"

    canvasBkg = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctxBkg    = canvasBkg.getGraphicsContext2D();

    canvasFg  = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctxFg     = canvasFg.getGraphicsContext2D();

    pane      = new Pane();
    pane.getChildren().setAll(canvasBkg, canvasFg);

    getChildren().setAll(pane);
    resize();
    drawBackground();
    drawForeground();
}
 
源代码6 项目: Lipi   文件: Lipi.java
private void readyGui() {

        //Must do this for opening browser;
        HostServicesProviderUtil.INSTANCE.init(getHostServices());

        //Load font
        File f = new File("kalpurush.ttf");
        try {
            Font.loadFont(f.getCanonicalPath(), 10);
        } catch (Exception e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
        }

        wizPane = new VBox();

        wizPane.getStylesheets().add(Paths.get("res/material.css").toAbsolutePath().toUri().toString());
        wizPane.getStylesheets().add(Paths.get("res/custom.css").toAbsolutePath().toUri().toString());

        primaryStage.getIcons().add(
                new Image(Paths.get("res/lipi-icon.png").toAbsolutePath().toUri().toString())
        );
    }
 
源代码7 项目: Enzo   文件: RoundLcdClock.java
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/digital.ttf"), (0.5833333333 * PREFERRED_HEIGHT));         // "Digital-7"
    //Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/digitalreadout.ttf"), (0.5833333333 * PREFERRED_HEIGHT));  // "Digital Readout Upright"


    canvasBkg = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctxBkg    = canvasBkg.getGraphicsContext2D();

    canvasFg  = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctxFg     = canvasFg.getGraphicsContext2D();

    pane      = new Pane();
    pane.getChildren().setAll(canvasBkg, canvasFg);

    getChildren().setAll(pane);
    resize();
}
 
源代码8 项目: GitFx   文件: GitFxController.java
@Override
    public void initialize(URL url, ResourceBundle rb) {
        Font.loadFont(GitFxController.class.getResource("/fonts/fontawesome-webfont.ttf").toExternalForm(), 12);
        
        //[CHANGE] I think we should use some common resource from where all these values are fetched...
        gitinit.setText('\uf04b' + "");		
        gitopen.setText('\uf07c' + "");
        gitsettings.setText('\uf013' + "");
        gitsync.setText('\uf021' + "");
        gitclone.setText('\uf0c5' + "");
        
        RepositoryTree.getSelectionModel().selectedItemProperty().addListener(
                (observable, oldValue, newValue) -> {
                    TreeItem<String> selectedItem = (TreeItem<String>) newValue;
                    if (selectedItem != null) {
//[LOG]					logger.debug("Selected Text" + selectedItem.getValue());
                        addProgressIndicator(historyContainer);
                        if (!selectedItem.getValue().equals("github"))
                            initializeHistoryAccordion(selectedItem.getValue());
                    }
                });
        GitFXGsonUtil.checkRepoInformation();
        initializeTree();
        initializeHistoryAccordion();
    }
 
源代码9 项目: Cryogen   文件: Main.java
@Override
public void start(Stage primaryStage) throws Exception {
    //iCloudTest.dryRun("email", "password");
    Font.loadFont(Main.class.getResource("binResc/Roboto-Thin.ttf").toExternalForm(), 24);
    StaticStage.mainStage = primaryStage;
    primaryStage.initStyle(StageStyle.TRANSPARENT);
    primaryStage.setTitle("Icew1nd");
    StaticStage.loadScreen(Lite.splash() ? "Splash" : "Title");
    primaryStage.setMinHeight(600);
    primaryStage.setMinWidth(800);
    primaryStage.setHeight(600);
    primaryStage.setWidth(800);
    primaryStage.getIcons().addAll(
            //This isn't working with my ultra-high DPI. :(
            new Image(Main.class.getResourceAsStream("binResc/icon.png"))
    );
}
 
源代码10 项目: AsciidocFX   文件: AppStarter.java
private void loadRequiredFonts() {
    Font.loadFont(AppStarter.class.getResourceAsStream("/font/NotoSerif-Regular.ttf"), -1);
    Font.loadFont(AppStarter.class.getResourceAsStream("/font/NotoSerif-Italic.ttf"), -1);
    Font.loadFont(AppStarter.class.getResourceAsStream("/font/NotoSerif-Bold.ttf"), -1);
    Font.loadFont(AppStarter.class.getResourceAsStream("/font/NotoSerif-BoldItalic.ttf"), -1);
    Font.loadFont(AppStarter.class.getResourceAsStream("/font/DejaVuSansMono.ttf"), -1);
    Font.loadFont(AppStarter.class.getResourceAsStream("/font/DejaVuSansMono-Bold.ttf"), -1);
    Font.loadFont(AppStarter.class.getResourceAsStream("/font/DejaVuSansMono-Oblique.ttf"), -1);
}
 
源代码11 项目: Enzo   文件: OnOffSwitchSkin.java
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.5 * PREFERRED_HEIGHT)); // "OpenSans"
    font = Font.font("Open Sans", 0.5 * PREFERRED_HEIGHT);

    background = new Region();
    background.getStyleClass().setAll("background");
    background.setStyle("-switch-color: " + Util.colorToCss((Color) getSkinnable().getSwitchColor()) + ";");

    selectedText  = new Text("1");
    selectedText.setFont(font);
    selectedText.getStyleClass().setAll("selected-text");
    selectedText.setStyle("-text-color-on: " + Util.colorToCss((Color) getSkinnable().getTextColorOn()) + ";");

    deselectedText = new Text("0");
    deselectedText.setFont(font);
    deselectedText.getStyleClass().setAll("deselected-text");
    deselectedText.setStyle("-text-color-off: " + Util.colorToCss((Color) getSkinnable().getTextColorOff()) + ";");

    thumb = new Region();
    thumb.getStyleClass().setAll("thumb");
    thumb.setMouseTransparent(true);
    thumb.setStyle("-thumb-color: " + Util.colorToCss((Color) getSkinnable().getThumbColor()) + ";");

    pane = new Pane(background, selectedText, deselectedText, thumb);
    pane.getStyleClass().setAll("on-off-switch");

    moveToDeselected = new TranslateTransition(Duration.millis(180), thumb);
    moveToSelected = new TranslateTransition(Duration.millis(180), thumb);

    // Add all nodes
    getChildren().setAll(pane);
}
 
源代码12 项目: Lipi   文件: RunTestsJavaFX.java
private void readyGui(Stage primaryStage) {
        this.primaryStage = primaryStage;
        editorStage = new Stage();

        tabbedHMDPostEditor = new TabbedHMDPostEditor(editorStage);
        editorStage.setScene(new Scene(tabbedHMDPostEditor));

        primaryStage.setTitle("Main Application");
        editorStage.setTitle("Hugo Markdown Editor");
        //Must do this for opening browser;
        HostServicesProviderUtil.INSTANCE.init(getHostServices());

        pane = new VBox();

        File f = new File("kalpurush.ttf");
        try {
            Font.loadFont(f.getCanonicalPath(), 10);
        } catch (Exception e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
        }

        pane.getStylesheets().add(Paths.get("res/material.css").toAbsolutePath().toUri().toString());
        pane.getStylesheets().add(Paths.get("res/custom.css").toAbsolutePath().toUri().toString());
//

        primaryStage.setScene(new Scene(pane));
    }
 
源代码13 项目: Talk   文件: TalkClient.java
@Override
	public void start(Stage primaryStage) throws IOException {
		Font.loadFont(getClass().getResource("/assets/OpenSansEmoji.ttf").toExternalForm(), 16);

//		Font.getFamilies();
//		for(String s: Font.getFamilies()) {
//			System.out.println(s);
//		}
		pStage = primaryStage;
		pStage.setTitle("Talk by netcan v"+ VERSION);
		pStage.setResizable(false);
		loginScene();
	}
 
源代码14 项目: Enzo   文件: QlockTwoSkin.java
private void initGraphics() {
    startX     = PREFERRED_WIDTH * 0.114;
    startY     = PREFERRED_WIDTH * 0.112;
    stepX      = PREFERRED_WIDTH * 0.072;
    stepY      = PREFERRED_WIDTH * 0.08;
    font       = Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/din.otf"), PREFERRED_WIDTH * 0.048);
    background = new Region();
    background.getStyleClass().addAll("background", getSkinnable().getColor().STYLE_CLASS);

    stainlessBackground.setImage(texture.getImage(PREFERRED_WIDTH, PREFERRED_HEIGHT));
    stainlessBackground.setOpacity(getSkinnable().getColor() == QlockTwo.QlockColor.STAINLESS_STEEL ? 1 : 0);

    p1 = new Region();
    p1.getStyleClass().add("dot-off");
    p2 = new Region();
    p2.getStyleClass().add("dot-off");
    p3 = new Region();
    p3.getStyleClass().add("dot-off");
    p4 = new Region();
    p4.getStyleClass().add("dot-off");

    highlight = new Region();
    highlight.getStyleClass().add("highlight");

    matrix = new Label[11][10];
    for (int y = 0 ; y < 10 ; y++) {
        for (int x = 0 ; x < 11 ; x++) {
            matrix[x][y] = new Label();
            matrix[x][y].setAlignment(Pos.CENTER);
            matrix[x][y].setPrefWidth(PREFERRED_WIDTH * 0.048);
            matrix[x][y].setPrefHeight(PREFERRED_HEIGHT * 0.048);
            matrix[x][y].setText(getSkinnable().getQlock().getMatrix()[y][x]);
            matrix[x][y].setFont(font);
            matrix[x][y].getStyleClass().add("text-off");
        }
    }

    pane.getChildren().setAll(background,
                              stainlessBackground,
                              p4,
                              p3,
                              p2,
                              p1);
    for (int y = 0 ; y < 10 ; y++) {
        for (int x = 0 ; x < 11 ; x++) {
            pane.getChildren().add(matrix[x][y]);
        }
    }
    pane.getChildren().add(highlight);

    getChildren().setAll(pane);
    resize();
}
 
源代码15 项目: Jupiter   文件: Fonts.java
/** Loads Anonymous Pro font. */
private static void anonymous() {
  Font.loadFont(Fonts.class.getResource("/jupiter/fonts/Anonymous_Pro/AnonymousPro.ttf").toExternalForm(), 10);
  Font.loadFont(Fonts.class.getResource("/jupiter/fonts/Anonymous_Pro/AnonymousPro-Bold.ttf").toExternalForm(), 10);
}
 
源代码16 项目: Jupiter   文件: Fonts.java
/** Loads Montserrat font. */
private static void montserrat() {
  Font.loadFont(Fonts.class.getResource("/jupiter/fonts/Montserrat/Montserrat-Medium.ttf").toExternalForm(), 10);
  Font.loadFont(Fonts.class.getResource("/jupiter/fonts/Montserrat/Montserrat-Regular.ttf").toExternalForm(), 10);
  Font.loadFont(Fonts.class.getResource("/jupiter/fonts/Montserrat/Montserrat-SemiBold.ttf").toExternalForm(), 10);
}
 
源代码17 项目: Enzo   文件: SimpleGaugeSkin.java
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.06 * PREFERRED_HEIGHT)); // "OpenSans"

    sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsCtx    = sectionsCanvas.getGraphicsContext2D();

    measuredRangeCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    measuredRangeCanvas.setManaged(getSkinnable().isMeasuredRangeVisible());
    measuredRangeCanvas.setVisible(getSkinnable().isMeasuredRangeVisible());
    measuredRangeCtx    = measuredRangeCanvas.getGraphicsContext2D();        
    
    if (getSkinnable().getValue() < getSkinnable().getMinValue()) getSkinnable().setValue(getSkinnable().getMinValue());
    if (getSkinnable().getValue() > getSkinnable().getMaxValue()) getSkinnable().setValue(getSkinnable().getMaxValue());

    needleRotate = new Rotate(180 - getSkinnable().getStartAngle());
    if (getSkinnable().getMinValue() < 0) {
        needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() - getSkinnable().getMinValue()) * angleStep);
    } else {
        //needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() + getSkinnable().getMinValue()) * angleStep);
    }

    angleStep = getSkinnable().getAngleRange() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue());
    needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue()) * angleStep);

    needle = new Path();
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getStyleClass().setAll("needle");
    needle.getTransforms().setAll(needleRotate);       

    value = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinValue()) + getSkinnable().getUnit());
    value.setMouseTransparent(true);
    value.setTextOrigin(VPos.CENTER);
    value.getStyleClass().setAll("value");

    title = new Text(getSkinnable().getTitle());
    title.setTextOrigin(VPos.CENTER);
    title.getStyleClass().setAll("title");

    // Add all nodes
    pane = new Pane();
    pane.getStyleClass().add("simple-gauge");
    pane.getChildren().setAll(sectionsCanvas,
                              measuredRangeCanvas,
                              needle,
                              value,
                              title);

    getChildren().setAll(pane);
    resize();
}
 
源代码18 项目: util4j   文件: Game2048.java
/**
 * 初始化游戏字体
 */
@Override
public void init() {
    Font.loadFont(Game2048.class.getClassLoader().getResource(TTF).toExternalForm(), 10.0);
}
 
源代码19 项目: HubTurbo   文件: UI.java
public static void loadFonts() {
    Font.loadFont(UI.class.getResource("octicons/octicons-local.ttf").toExternalForm(), 32);
}
 
源代码20 项目: PDF4Teachers   文件: FontUtils.java
public static Font getFont(String family, boolean italic, boolean bold, double size){

        return Font.loadFont(getFontFile(family, italic, bold), size);
    }
 
 方法所在类
 同类方法