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


Java Font.getFont方法代码示例

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


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

示例1: getFontAtCurrentPos

import java.awt.Font; //导入方法依赖的package包/类
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:TextLine.java

示例2: NSFPlayer

import java.awt.Font; //导入方法依赖的package包/类
public NSFPlayer(int i){
	super();
	
	System.out.println("Making an NSF Player!");
	Map<TextAttribute, Object> attributes = new HashMap<>();

	attributes.put(TextAttribute.FAMILY, "Default");
	attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_SEMIBOLD);
	attributes.put(TextAttribute.SIZE, 14);
	largefont = Font.getFont(attributes);
	attributes.put(TextAttribute.FAMILY, "Default");
	attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_SEMIBOLD);
	attributes.put(TextAttribute.SIZE, 10);
	smallfont = Font.getFont(attributes);
	nsfemode = i==1;
}
 
开发者ID:QuantumSoundings,项目名称:BassNES,代码行数:17,代码来源:NSFPlayer.java

示例3: getGraphicOrFont

import java.awt.Font; //导入方法依赖的package包/类
/**
 * Extract a GraphicAttribute or Font from the given attributes.
 * If attributes does not contain a GraphicAttribute, Font, or
 * Font family entry this method returns null.
 */
private static Object getGraphicOrFont(
        Map<? extends Attribute, ?> attributes) {

    Object value = attributes.get(TextAttribute.CHAR_REPLACEMENT);
    if (value != null) {
        return value;
    }
    value = attributes.get(TextAttribute.FONT);
    if (value != null) {
        return value;
    }

    if (attributes.get(TextAttribute.FAMILY) != null) {
        return Font.getFont(attributes);
    }
    else {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:StyledParagraph.java

示例4: leak

import java.awt.Font; //导入方法依赖的package包/类
private static void leak() {
    Map<TextAttribute, Object> textAttributes = new HashMap<>();
    textAttributes.put(TextAttribute.FAMILY, "Sans Serif");
    textAttributes.put(TextAttribute.SIZE, 12);
    textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
    Font font = Font.getFont(textAttributes);
    JLabel label = new JLabel();
    int dummy = 0;
    for (int i = 0; i < 500; i++) {
        if (i % 10 == 0) System.out.println("Starting iter " + (i+1));
        for (int j = 0; j <1000; j++) {
            FontMetrics fm = label.getFontMetrics(font);
            dummy += SwingUtilities.computeStringWidth(fm, Integer.toString(j));
        }
    }
    System.out.println("done " + dummy);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:KerningLeak.java

示例5: unmarshal

import java.awt.Font; //导入方法依赖的package包/类
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
    final Map<TextAttribute, Object> attributes;
    if (reader.hasMoreChildren()) {
        reader.moveDown();
        if (!reader.getNodeName().equals("attributes")) {
            final String classAlias = mapper.aliasForSystemAttribute("class");
            attributes = new HashMap<TextAttribute, Object>();
            do {
                if (!attributes.isEmpty()) {
                    reader.moveDown();
                }
                final Class<?> type = mapper.realClass(reader.getAttribute(classAlias));
                final TextAttribute attribute = (TextAttribute)textAttributeConverter.fromString(reader.getNodeName());
                final Object value = type == Mapper.Null.class ? null : context.convertAnother(null, type);
                attributes.put(attribute, value);
                reader.moveUp();
            } while (reader.hasMoreChildren());
        } else {
            // in <attributes>
            @SuppressWarnings("unchecked")
            final Map<TextAttribute, Object> typedAttributes = (Map<TextAttribute, Object>)context.convertAnother(
                null, Map.class);
            attributes = typedAttributes;
            reader.moveUp(); // out of </attributes>
        }
    } else {
        attributes = Collections.emptyMap();
    }
    for (final Iterator<?> iter = attributes.values().iterator(); iter.hasNext();) {
        if (iter.next() == null) {
            iter.remove();
        }
    }
    final Font font = Font.getFont(attributes);
    if (context.getRequiredType() == FontUIResource.class) {
        return new FontUIResource(font);
    } else {
        return font;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:FontConverter.java

示例6: instantiate

import java.awt.Font; //导入方法依赖的package包/类
protected Expression instantiate(Object oldInstance, Encoder out) {
    Font font = (Font) oldInstance;

    int count = 0;
    String family = null;
    int style = Font.PLAIN;
    int size = 12;

    Map<TextAttribute, ?> basic = font.getAttributes();
    Map<TextAttribute, Object> clone = new HashMap<>(basic.size());
    for (TextAttribute key : basic.keySet()) {
        Object value = basic.get(key);
        if (value != null) {
            clone.put(key, value);
        }
        if (key == TextAttribute.FAMILY) {
            if (value instanceof String) {
                count++;
                family = (String) value;
            }
        }
        else if (key == TextAttribute.WEIGHT) {
            if (TextAttribute.WEIGHT_REGULAR.equals(value)) {
                count++;
            } else if (TextAttribute.WEIGHT_BOLD.equals(value)) {
                count++;
                style |= Font.BOLD;
            }
        }
        else if (key == TextAttribute.POSTURE) {
            if (TextAttribute.POSTURE_REGULAR.equals(value)) {
                count++;
            } else if (TextAttribute.POSTURE_OBLIQUE.equals(value)) {
                count++;
                style |= Font.ITALIC;
            }
        } else if (key == TextAttribute.SIZE) {
            if (value instanceof Number) {
                Number number = (Number) value;
                size = number.intValue();
                if (size == number.floatValue()) {
                    count++;
                }
            }
        }
    }
    Class<?> type = font.getClass();
    if (count == clone.size()) {
        return new Expression(font, type, "new", new Object[]{family, style, size});
    }
    if (type == Font.class) {
        return new Expression(font, type, "getFont", new Object[]{clone});
    }
    return new Expression(font, type, "new", new Object[]{Font.getFont(clone)});
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:MetaData.java


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