本文整理汇总了Java中sun.font.FontResolver类的典型用法代码示例。如果您正苦于以下问题:Java FontResolver类的具体用法?Java FontResolver怎么用?Java FontResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FontResolver类属于sun.font包,在下文中一共展示了FontResolver类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例4: addFonts
import sun.font.FontResolver; //导入依赖的package包/类
/**
* Resolve the given chars into Fonts using FontResolver, then add
* font runs for each.
*/
private void addFonts(char[] chars, Map<? extends Attribute, ?> attributes,
int start, int limit) {
FontResolver resolver = FontResolver.getInstance();
CodePointIterator iter = CodePointIterator.create(chars, start, limit);
for (int runStart = iter.charIndex(); runStart < limit; runStart = iter.charIndex()) {
int fontIndex = resolver.nextFontRunIndex(iter);
addFont(resolver.getFont(fontIndex, attributes), runStart);
}
}
示例5: 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;
}
示例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;
}
示例7: addFonts
import sun.font.FontResolver; //导入依赖的package包/类
/**
* Resolve the given chars into Fonts using FontResolver, then add
* font runs for each.
*/
private void addFonts(char[] chars, Map attributes, int start, int limit) {
FontResolver resolver = FontResolver.getInstance();
CodePointIterator iter = CodePointIterator.create(chars, start, limit);
for (int runStart = iter.charIndex(); runStart < limit; runStart = iter.charIndex()) {
int fontIndex = resolver.nextFontRunIndex(iter);
addFont(resolver.getFont(fontIndex, attributes), runStart);
}
}
示例8: 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;
}
示例9: addFonts
import sun.font.FontResolver; //导入依赖的package包/类
/**
* Resolve the given chars into Fonts using FontResolver, then add
* font runs for each.
*/
private void addFonts(char[] chars, Map attributes, int start, int limit) {
FontResolver resolver = FontResolver.getInstance();
CodePointIterator iter = CodePointIterator.create(chars, start, limit);
for (int runStart = iter.charIndex(); runStart < limit; runStart = iter.charIndex()) {
int fontIndex = resolver.nextFontRunIndex(iter);
addFont(resolver.getFont(fontIndex, attributes), runStart);
}
}