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


Java Font.canDisplay方法代码示例

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


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

示例1: main

import java.awt.Font; //导入方法依赖的package包/类
/** Call with hex codes of interesting characters. */
public static void main(String[] args) {
    List<Integer> chars;
    if (args.length == 0) {
        chars = Collections.singletonList((int) Util.DT);
    } else {
        chars = new ArrayList<>(args.length);
        for (String arg : args) {
            chars.add(Integer.parseInt(arg, 16));
        }
    }
    Font[] fonts =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
    for (Integer c : chars) {
        System.out.println("Fonts that can display 0x"
            + Integer.toHexString(c));
        for (Font f : fonts) {
            if (f.canDisplay(c)) {
                System.out.println(f.getFontName());
            }
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:24,代码来源:ShowFonts.java

示例2: getSymbolFont

import java.awt.Font; //导入方法依赖的package包/类
/** Returns the font for special (arrow-like) characters. */
public static Font getSymbolFont() {
    if (SYMBOL_FONT == null) {
        initLookAndFeel();
        Font result = getLabelFont();
        if (!result.canDisplay(Util.DT)) {
            result = UIManager.getDefaults()
                .getFont("SansSerif");
        }
        if (result == null || !result.canDisplay(Util.DT)) {
            result = loadFont("stixgeneralregular.ttf").deriveFont(getLabelFont().getSize2D());
        }
        SYMBOL_FONT = result;
    }
    return SYMBOL_FONT;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:Options.java

示例3: makeDisplayable

import java.awt.Font; //导入方法依赖的package包/类
/**
 * Makes the given String displayble. Probably there doesn't exists
 * perfect solution for all situation. (someone prefer display those
 * squares for undisplayable chars, someone unicode placeholders). So lets
 * try do the best compromise.
 */
private static String makeDisplayable(String str , Font f) {
    if( str == null || f == null){
        return str;
    }
    StringBuilder buf = new StringBuilder(str.length());
    char[] chars = str.toCharArray();
    for (int i = 0; i < chars.length; i++) {
        char c = chars[i];
        switch (c) {
            case '\t': buf.append(c); break;
            case '\n': buf.append(c); break;
            case '\r': buf.append(c); break;
            case '\b': buf.append("\\b"); break; // NOI18N
            case '\f': buf.append("\\f"); break; // NOI18N
            default:
                if( f == null || f.canDisplay( c ) ){
                    buf.append(c);
                } else {
                    buf.append("\\u"); // NOI18N
                    String hex = Integer.toHexString(c);
                    for (int j = 0; j < 4 - hex.length(); j++){
                        buf.append('0'); //NOI18N
                    }
                    buf.append(hex);
                }
        }
    }
    return buf.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ToolTipSupport.java

示例4: runTest

import java.awt.Font; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    Font font = ((TextContext)ctx).font;
    boolean b = false;
    do {
        for (int i = 0; i < 0x10000; i += 0x64) {
            b ^= font.canDisplay((char)i);
        }
    } while (--numReps >= 0);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:TextMeasureTests.java

示例5: canDisplayRange

import java.awt.Font; //导入方法依赖的package包/类
protected boolean canDisplayRange(Font font, int rangeStart, int rangeEnd) {
    for (int i = rangeStart; i < rangeEnd; i++) {
        if (font.canDisplay(i)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:Font2DTest.java

示例6: makeDisplayble

import java.awt.Font; //导入方法依赖的package包/类
/**
 * Makes the given String displayble. Probably there doesn't exists
 * perfect solution for all situation. (someone prefer display those
 * squares for undisplayable chars, someone unicode placeholders). So lets
 * try do the best compromise.
 */
private static String makeDisplayble(String str, Font f) {
    if (null == str) {
        return str;
    }

    if (null == f) {
        f = new JLabel().getFont();
    }

    StringBuffer buf = new StringBuffer((int) (str.length() * 1.3)); // x -> \u1234
    char[] chars = str.toCharArray();

    for (int i = 0; i < chars.length; i++) {
        char c = chars[i];

        switch (c) {
        case '\t':
            buf.append("&nbsp;&nbsp;&nbsp;&nbsp;" + // NOI18N
                "&nbsp;&nbsp;&nbsp;&nbsp;"
            ); // NOI18N
            break;

        case '\n':
            break;

        case '\r':
            break;

        case '\b':
            buf.append("\\b");

            break; // NOI18N

        case '\f':
            buf.append("\\f");

            break; // NOI18N

        default:

            if (!processHtmlEntity(buf, c)) {
                if ((null == f) || f.canDisplay(c)) {
                    buf.append(c);
                } else {
                    buf.append("\\u"); // NOI18N

                    String hex = Integer.toHexString(c);

                    for (int j = 0; j < (4 - hex.length()); j++)
                        buf.append('0');

                    buf.append(hex);
                }
            }
        }
    }

    return buf.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:66,代码来源:TableSheetCell.java

示例7: makeDisplayble

import java.awt.Font; //导入方法依赖的package包/类
/**
 * Makes the given String displayble. Probably there doesn't exists
 * perfect solution for all situation. (someone prefer display those
 * squares for undisplayable chars, someone unicode placeholders). So lets
 * try do the best compromise.
 */
private static String makeDisplayble(String str, Font f) {
    if (null == str) {
        return str;
    }

    if (null == f) {
        f = new JLabel().getFont();
    }

    StringBuffer buf = new StringBuffer(str.length() * 6); // x -> \u1234
    char[] chars = str.toCharArray();

    for (int i = 0; i < chars.length; i++) {
        char c = chars[i];

        switch (c) {
        // label doesn't interpret tab correctly
        case '\t':
            buf.append("        "); // NOI18N
            break;

        case '\n':
            break;

        case '\r':
            break;

        case '\b':
            buf.append("\\b");

            break; // NOI18N

        case '\f':
            buf.append("\\f");

            break; // NOI18N

        default:

            if ((null == f) || f.canDisplay(c)) {
                buf.append(c);
            } else {
                buf.append("\\u"); // NOI18N

                String hex = Integer.toHexString(c);

                for (int j = 0; j < (4 - hex.length()); j++)
                    buf.append('0');

                buf.append(hex);
            }
        }
    }

    return buf.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:63,代码来源:RendererFactory.java


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