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


Java GraphicsEnvironment.getAvailableFontFamilyNames方法代码示例

本文整理汇总了Java中java.awt.GraphicsEnvironment.getAvailableFontFamilyNames方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsEnvironment.getAvailableFontFamilyNames方法的具体用法?Java GraphicsEnvironment.getAvailableFontFamilyNames怎么用?Java GraphicsEnvironment.getAvailableFontFamilyNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.GraphicsEnvironment的用法示例。


在下文中一共展示了GraphicsEnvironment.getAvailableFontFamilyNames方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: print

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public int print(Graphics g, PageFormat pf, int pageIndex) {
    if (pageIndex != 0) return NO_SUCH_PAGE;
    Graphics2D g2= (Graphics2D)g;

    g2.setPaint(Color.black);

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontList = ge.getAvailableFontFamilyNames();
    g2.setFont (new Font ("Arial", Font.PLAIN, 20));
    g2.drawString("Arial - Plain", 144, 120);
    g2.setFont (new Font ("Arial", Font.BOLD, 20));
    g2.drawString("Arial - Bold", 144, 145);
    g2.setFont (new Font ("Arial", Font.ITALIC, 20));
    g2.drawString("Arial - Italic", 144, 170);
    g2.setFont (new Font ("Times New Roman", Font.PLAIN, 20));
    g2.drawString("Times New Roman - Plain", 144, 195);
    g2.setFont (new Font ("Times New Roman", Font.BOLD, 20));
    g2.drawString("Times New Roman - Bold", 144, 220);
    g2.setFont (new Font ("Times New Roman", Font.ITALIC, 20));
    g2.drawString("Times New Roman - Italic", 144, 245);

    return PAGE_EXISTS;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:PrintFontStyle.java

示例2: getFontFamilies

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
private String[] getFontFamilies() {
    if (fontFamilyNames == null) {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        fontFamilyNames = env.getAvailableFontFamilyNames();
    }
    return fontFamilyNames;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:8,代码来源:FontChooser.java

示例3: loadFonts

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
/**
 * Loads all available fonts into the combo
 *
 */
private void loadFonts() {
	GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	String[] fontNames = ge.getAvailableFontFamilyNames();
	
	for(String font : fontNames) {
		fontComboModel.addElement(font);
	}
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:13,代码来源:FengFonts.java

示例4: run

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public void run()
{
  GraphicsEnvironment ge = null;
  // -= Simon Lessard =-
  // TODO: Check if synchronization is required
  Hashtable<String, Boolean> fontNames = null;

  try
  {
    ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

    if (ge != null)
    {
      String[] families = ge.getAvailableFontFamilyNames();

      if ((families != null) && (families.length > 0))
      {
        fontNames = new Hashtable<String, Boolean>(families.length);
        for (int i = 0; i < families.length; i++)
        {
          String name = families[i].toLowerCase();
          fontNames.put(name, Boolean.TRUE);
        }
      }
    }
  }
  catch (Throwable t)
  {
    // If any exception occurs during getLocalGraphicsEnvironment(),
    // we assume we've got a non-graphical environment
    _LOG.warning(_EXCEPTION_MESSAGE, t);
  }

  __setFontsLoaded(fontNames);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:36,代码来源:GraphicsUtils.java

示例5: getFontFamilies

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
protected String[] getFontFamilies() {
	if (fontFamilyNames == null) {
		GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
		fontFamilyNames = env.getAvailableFontFamilyNames();
	}
	return fontFamilyNames;
}
 
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:8,代码来源:JFontChooser.java

示例6: getFont

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
private static Font getFont() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontNames = ge.getAvailableFontFamilyNames();
    String fontName = fontNames[0];
    for (String name : fontNames) {
        if ("Arial".equals(name)) {
            fontName = name;
            break;
        }
    }
    return new Font(fontName, Font.PLAIN, 30);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:bug8132119.java

示例7: getFontFamilies

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
protected String[] getFontFamilies()
{
    if (fontFamilyNames == null)
    {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        fontFamilyNames = env.getAvailableFontFamilyNames();
    }
    return fontFamilyNames;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:10,代码来源:JFontChooser.java

示例8: main

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static void main(String[] args) {

		List<String> monospaceFontFamilyNames = new ArrayList<>();
		GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment
				.getLocalGraphicsEnvironment();
		String[] fontFamilyNames = graphicsEnvironment
				.getAvailableFontFamilyNames();

		BufferedImage bufferedImage = new BufferedImage(1, 1,
				BufferedImage.TYPE_INT_ARGB);
		Graphics graphics = bufferedImage.createGraphics();

		for (String fontFamilyName : fontFamilyNames) {
			boolean isMonospaced = true;
			//
			int fontStyle = Font.PLAIN;
			int fontSize = 12;
			Font font = new Font(fontFamilyName, fontStyle, fontSize);
			@SuppressWarnings("serial")
			List<Integer> codePoints = new ArrayList<Integer>() {
				{
					add(108); /* l */
					add(109); /* m */
					add(119); /* w */
					add(49); /* 1 */
					add(52); /* 4 */
				}
			};
			FontMetrics fontMetrics = graphics.getFontMetrics(font);

			int firstCharacterWidth = 0;
			boolean hasFirstCharacterWidth = false;
			for (int codePoint : codePoints) {
				if (Character.isValidCodePoint(codePoint)
						&& (Character.isLetter(codePoint)
								|| Character.isDigit(codePoint))) {
					char character = (char) codePoint;
					int characterWidth = fontMetrics.charWidth(character);
					if (hasFirstCharacterWidth) {
						if (characterWidth != firstCharacterWidth) {
							isMonospaced = false;
							break;
						}
					} else {
						firstCharacterWidth = characterWidth;
						hasFirstCharacterWidth = true;
					}
				}
			}

			if (isMonospaced) {
				monospaceFontFamilyNames.add(fontFamilyName);
			}
		}

		graphics.dispose();
		for (String fontFamily : monospaceFontFamilyNames) {
			System.out.println(fontFamily);
		}
	}
 
开发者ID:sergueik,项目名称:SWET,代码行数:61,代码来源:ListJavaFonts.java

示例9: getFontsList

import java.awt.GraphicsEnvironment; //导入方法依赖的package包/类
public static String[] getFontsList() {
    GraphicsEnvironment gEnv = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    String envfonts[] = gEnv.getAvailableFontFamilyNames();
    return envfonts;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:7,代码来源:Utilidades.java


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