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


Java FontResolver.getFont方法代码示例

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


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

示例1: getFontAtCurrentPos

import sun.font.FontResolver; //导入方法依赖的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: getFontAtCurrentPos

import sun.font.FontResolver; //导入方法依赖的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:jgaltidor,项目名称:VarJ,代码行数:18,代码来源:TextLine.java

示例3: insertChar

import sun.font.FontResolver; //导入方法依赖的package包/类
/**
 * Return a StyledParagraph reflecting the insertion of a single character
 * into the text.  This method will attempt to reuse the given paragraph,
 * but may create a new paragraph.
 * @param aci an iterator over the text.  The text should be the same as the
 *     text used to create (or most recently update) oldParagraph, with
 *     the exception of inserting a single character at insertPos.
 * @param chars the characters in aci
 * @param insertPos the index of the new character in aci
 * @param oldParagraph a StyledParagraph for the text in aci before the
 *     insertion
 */
public static StyledParagraph insertChar(AttributedCharacterIterator aci,
                                         char[] chars,
                                         int insertPos,
                                         StyledParagraph oldParagraph) {

    // If the styles at insertPos match those at insertPos-1,
    // oldParagraph will be reused.  Otherwise we create a new
    // paragraph.

    char ch = aci.setIndex(insertPos);
    int relativePos = Math.max(insertPos - aci.getBeginIndex() - 1, 0);

    Map<? extends Attribute, ?> attributes =
        addInputMethodAttrs(aci.getAttributes());
    Decoration d = Decoration.getDecoration(attributes);
    if (!oldParagraph.getDecorationAt(relativePos).equals(d)) {
        return new StyledParagraph(aci, chars);
    }
    Object f = getGraphicOrFont(attributes);
    if (f == null) {
        FontResolver resolver = FontResolver.getInstance();
        int fontIndex = resolver.getFontIndex(ch);
        f = resolver.getFont(fontIndex, attributes);
    }
    if (!oldParagraph.getFontOrGraphicAt(relativePos).equals(f)) {
        return new StyledParagraph(aci, chars);
    }

    // insert into existing paragraph
    oldParagraph.length += 1;
    if (oldParagraph.decorations != null) {
        insertInto(relativePos,
                   oldParagraph.decorationStarts,
                   oldParagraph.decorations.size());
    }
    if (oldParagraph.fonts != null) {
        insertInto(relativePos,
                   oldParagraph.fontStarts,
                   oldParagraph.fonts.size());
    }
    return oldParagraph;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:55,代码来源:StyledParagraph.java

示例4: singleFont

import sun.font.FontResolver; //导入方法依赖的package包/类
private static Font singleFont(char[] text,
                               int start,
                               int limit,
                               Map<? extends Attribute, ?> attributes) {

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

    Font font = null;
    try {
        font = (Font)attributes.get(TextAttribute.FONT);
    }
    catch (ClassCastException e) {
    }
    if (font == null) {
        if (attributes.get(TextAttribute.FAMILY) != null) {
            font = Font.getFont(attributes);
            if (font.canDisplayUpTo(text, start, limit) != -1) {
                return null;
            }
        } else {
            FontResolver resolver = FontResolver.getInstance();
            CodePointIterator iter = CodePointIterator.create(text, start, limit);
            int fontIndex = resolver.nextFontRunIndex(iter);
            if (iter.charIndex() == limit) {
                font = resolver.getFont(fontIndex, attributes);
            }
        }
    }

    if (sameBaselineUpTo(font, text, start, limit) != limit) {
        return null;
    }

    return font;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:38,代码来源:TextLayout.java

示例5: singleFont

import sun.font.FontResolver; //导入方法依赖的package包/类
private static Font singleFont(char[] text,
                               int start,
                               int limit,
                               Map attributes) {

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

    Font font = null;
    try {
        font = (Font)attributes.get(TextAttribute.FONT);
    }
    catch (ClassCastException e) {
    }
    if (font == null) {
        if (attributes.get(TextAttribute.FAMILY) != null) {            
            font = Font.getFont(attributes);
            if (font.canDisplayUpTo(text, start, limit) != -1) {
                return null;
            }
        } else {
            FontResolver resolver = FontResolver.getInstance();
            CodePointIterator iter = CodePointIterator.create(text, start, limit);
            int fontIndex = resolver.nextFontRunIndex(iter);
            if (iter.charIndex() == limit) {
                font = resolver.getFont(fontIndex, attributes);
            }
        }
    }

    if (sameBaselineUpTo(font, text, start, limit) != limit) {
        return null;
    }

    return font;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:38,代码来源:TextLayout.java

示例6: singleFont

import sun.font.FontResolver; //导入方法依赖的package包/类
private static Font singleFont(char[] text,
                               int start,
                               int limit,
                               Map attributes) {

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

    Font font = null;
    try {
        font = (Font)attributes.get(TextAttribute.FONT);
    }
    catch (ClassCastException e) {
    }
    if (font == null) {
        if (attributes.get(TextAttribute.FAMILY) != null) {
            font = Font.getFont(attributes);
            if (font.canDisplayUpTo(text, start, limit) != -1) {
                return null;
            }
        } else {
            FontResolver resolver = FontResolver.getInstance();
            CodePointIterator iter = CodePointIterator.create(text, start, limit);
            int fontIndex = resolver.nextFontRunIndex(iter);
            if (iter.charIndex() == limit) {
                font = resolver.getFont(fontIndex, attributes);
            }
        }
    }

    if (sameBaselineUpTo(font, text, start, limit) != limit) {
        return null;
    }

    return font;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:38,代码来源:TextLayout.java

示例7: insertChar

import sun.font.FontResolver; //导入方法依赖的package包/类
/**
 * Return a StyledParagraph reflecting the insertion of a single character
 * into the text.  This method will attempt to reuse the given paragraph,
 * but may create a new paragraph.
 * @param aci an iterator over the text.  The text should be the same as the
 *     text used to create (or most recently update) oldParagraph, with
 *     the exception of inserting a single character at insertPos.
 * @param chars the characters in aci
 * @param insertPos the index of the new character in aci
 * @param oldParagraph a StyledParagraph for the text in aci before the
 *     insertion
 */
public static StyledParagraph insertChar(AttributedCharacterIterator aci,
                                         char[] chars,
                                         int insertPos,
                                         StyledParagraph oldParagraph) {
    
    // If the styles at insertPos match those at insertPos-1, 
    // oldParagraph will be reused.  Otherwise we create a new
    // paragraph.
    
    char ch = aci.setIndex(insertPos);
    int relativePos = Math.max(insertPos - aci.getBeginIndex() - 1, 0);
    
    Map attributes = addInputMethodAttrs(aci.getAttributes());
    Decoration d = Decoration.getDecoration(attributes);
    if (!oldParagraph.getDecorationAt(relativePos).equals(d)) {
        return new StyledParagraph(aci, chars);
    }
    Object f = getGraphicOrFont(attributes);
    if (f == null) {
        FontResolver resolver = FontResolver.getInstance();
        int fontIndex = resolver.getFontIndex(ch);
        f = resolver.getFont(fontIndex, attributes);
    }
    if (!oldParagraph.getFontOrGraphicAt(relativePos).equals(f)) {
        return new StyledParagraph(aci, chars);
    }
    
    // insert into existing paragraph
    oldParagraph.length += 1;
    if (oldParagraph.decorations != null) {
        insertInto(relativePos, 
                   oldParagraph.decorationStarts, 
                   oldParagraph.decorations.size());
    }
    if (oldParagraph.fonts != null) {
        insertInto(relativePos, 
                   oldParagraph.fontStarts, 
                   oldParagraph.fonts.size());
    }
    return oldParagraph;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:54,代码来源:StyledParagraph.java

示例8: insertChar

import sun.font.FontResolver; //导入方法依赖的package包/类
/**
 * Return a StyledParagraph reflecting the insertion of a single character
 * into the text.  This method will attempt to reuse the given paragraph,
 * but may create a new paragraph.
 * @param aci an iterator over the text.  The text should be the same as the
 *     text used to create (or most recently update) oldParagraph, with
 *     the exception of inserting a single character at insertPos.
 * @param chars the characters in aci
 * @param insertPos the index of the new character in aci
 * @param oldParagraph a StyledParagraph for the text in aci before the
 *     insertion
 */
public static StyledParagraph insertChar(AttributedCharacterIterator aci,
                                         char[] chars,
                                         int insertPos,
                                         StyledParagraph oldParagraph) {

    // If the styles at insertPos match those at insertPos-1,
    // oldParagraph will be reused.  Otherwise we create a new
    // paragraph.

    char ch = aci.setIndex(insertPos);
    int relativePos = Math.max(insertPos - aci.getBeginIndex() - 1, 0);

    Map attributes = addInputMethodAttrs(aci.getAttributes());
    Decoration d = Decoration.getDecoration(attributes);
    if (!oldParagraph.getDecorationAt(relativePos).equals(d)) {
        return new StyledParagraph(aci, chars);
    }
    Object f = getGraphicOrFont(attributes);
    if (f == null) {
        FontResolver resolver = FontResolver.getInstance();
        int fontIndex = resolver.getFontIndex(ch);
        f = resolver.getFont(fontIndex, attributes);
    }
    if (!oldParagraph.getFontOrGraphicAt(relativePos).equals(f)) {
        return new StyledParagraph(aci, chars);
    }

    // insert into existing paragraph
    oldParagraph.length += 1;
    if (oldParagraph.decorations != null) {
        insertInto(relativePos,
                   oldParagraph.decorationStarts,
                   oldParagraph.decorations.size());
    }
    if (oldParagraph.fonts != null) {
        insertInto(relativePos,
                   oldParagraph.fontStarts,
                   oldParagraph.fonts.size());
    }
    return oldParagraph;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:54,代码来源:StyledParagraph.java


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