當前位置: 首頁>>代碼示例>>Java>>正文


Java Font.getFamily方法代碼示例

本文整理匯總了Java中javafx.scene.text.Font.getFamily方法的典型用法代碼示例。如果您正苦於以下問題:Java Font.getFamily方法的具體用法?Java Font.getFamily怎麽用?Java Font.getFamily使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.text.Font的用法示例。


在下文中一共展示了Font.getFamily方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import javafx.scene.text.Font; //導入方法依賴的package包/類
@Override
public void write(JsonWriter writer, Font value) throws IOException {
	if (value == null) {
		writer.nullValue();
		return;
	}

	String s = value.getFamily();

	writer.value(s);
}
 
開發者ID:Quantencomputer,項目名稱:cyoastudio,代碼行數:12,代碼來源:FontAdapter.java

示例2: 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.getFamily方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。