下面列出了怎么用java.awt.font.GlyphJustificationInfo的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public GlyphJustificationInfo create() {
float weight = ((Number) map.get(KEY_WEIGHT)).floatValue();
boolean growAbsorb = (Boolean) map.get(KEY_GROW_ABSORB);
int growPriority = ((Number) map.get(KEY_GROW_PRIORITY)).intValue();
float growLeftLimit = ((Number) map.get(KEY_GROW_LEFT_LIMIT))
.floatValue();
float growRightLimit = ((Number) map.get(KEY_GROW_RIGHT_LIMIT))
.floatValue();
boolean shrinkAbsorb = (Boolean) map.get(KEY_SHRINK_ABSORB);
int shrinkPriority = ((Number) map.get(KEY_SHRINK_PRIORITY)).intValue();
float shrinkLeftLimit = ((Number) map.get(KEY_SHRINK_LEFT_LIMIT))
.floatValue();
float shrinkRightLimit = ((Number) map.get(KEY_SHRINK_RIGHT_LIMIT))
.floatValue();
return new GlyphJustificationInfo(weight, growAbsorb, growPriority,
growLeftLimit, growRightLimit, shrinkAbsorb, shrinkPriority,
shrinkLeftLimit, shrinkRightLimit);
}
public GlyphElement(GlyphVector gv, int index) {
glyphCode = gv.getGlyphCode(index);
transform = gv.getGlyphTransform(index);
outline = new ShapeSerializationWrapper(gv.getGlyphOutline(index));
position = new Point2DSerializationWrapper(
gv.getGlyphPosition(index));
logicalBounds = new ShapeSerializationWrapper(
gv.getGlyphLogicalBounds(index));
GlyphJustificationInfo gji = gv.getGlyphJustificationInfo(index);
justificationInfo = gji == null ? null
: new GlyphJustificationInfoSerializationWrapper(gji);
glyphMetrics = new GlyphMetricsSerializationWrapper(
gv.getGlyphMetrics(index));
visualBounds = new ShapeSerializationWrapper(
gv.getGlyphVisualBounds(index));
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
@Override
public SerializationWrapper<?> filter(Object object) {
if (object instanceof GlyphJustificationInfo) {
GlyphJustificationInfo gji = (GlyphJustificationInfo) object;
return new GlyphJustificationInfoSerializationWrapper(gji);
}
return null;
}
public GlyphJustificationInfoSerializationWrapper(
GlyphJustificationInfo gji) {
map.put(KEY_WEIGHT, gji.weight);
map.put(KEY_GROW_ABSORB, gji.growAbsorb);
map.put(KEY_GROW_PRIORITY, gji.growPriority);
map.put(KEY_GROW_LEFT_LIMIT, gji.growLeftLimit);
map.put(KEY_GROW_RIGHT_LIMIT, gji.growRightLimit);
map.put(KEY_SHRINK_ABSORB, gji.shrinkAbsorb);
map.put(KEY_SHRINK_PRIORITY, gji.shrinkPriority);
map.put(KEY_SHRINK_LEFT_LIMIT, gji.shrinkLeftLimit);
map.put(KEY_SHRINK_RIGHT_LIMIT, gji.shrinkRightLimit);
}
@Override
public GlyphJustificationInfo getGlyphJustificationInfo(
int glyphIndex) {
if (glyphs[glyphIndex].justificationInfo == null)
return null;
return glyphs[glyphIndex].justificationInfo.create();
}
public GlyphJustificationInfo getGlyphJustificationInfo(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
// currently we don't have enough information to do this right. should
// get info from the font and use real OT/GX justification. Right now
// sun/font/ExtendedTextSourceLabel assigns one of three infos
// based on whether the char is kanji, space, or other.
return null;
}
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
// This simple implementation only uses spaces for justification.
// Since regular characters aren't justified, we don't need to deal with
// special infos for combining marks or ligature substitution glyphs.
// added character justification for kanjii only 2/22/98
StandardGlyphVector gv = getGV();
float[] charinfo = getCharinfo();
float size = gv.getFont().getSize2D();
GlyphJustificationInfo nullInfo =
new GlyphJustificationInfo(0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
GlyphJustificationInfo spaceInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);
GlyphJustificationInfo kanjiInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
char[] chars = source.getChars();
int offset = source.getStart();
// assume data is 1-1 and either all rtl or all ltr, for now
int numGlyphs = gv.getNumGlyphs();
int minGlyph = 0;
int maxGlyph = numGlyphs;
boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
if (charStart != 0 || charLimit != source.getLength()) {
if (ltr) {
minGlyph = charStart;
maxGlyph = charLimit;
} else {
minGlyph = numGlyphs - charLimit;
maxGlyph = numGlyphs - charStart;
}
}
for (int i = 0; i < numGlyphs; ++i) {
GlyphJustificationInfo info = null;
if (i >= minGlyph && i < maxGlyph) {
if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
info = nullInfo;
} else {
int ci = v2l(i); // 1-1 assumption again
char c = chars[offset + ci];
if (Character.isWhitespace(c)) {
info = spaceInfo;
// CJK, Hangul, CJK Compatibility areas
} else if (c >= 0x4e00 &&
(c < 0xa000) ||
(c >= 0xac00 && c < 0xd7b0) ||
(c >= 0xf900 && c < 0xfb00)) {
info = kanjiInfo;
} else {
info = nullInfo;
}
}
}
infos[infoStart + i] = info;
}
}
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
// This simple implementation only uses spaces for justification.
// Since regular characters aren't justified, we don't need to deal with
// special infos for combining marks or ligature substitution glyphs.
// added character justification for kanjii only 2/22/98
StandardGlyphVector gv = getGV();
float[] charinfo = getCharinfo();
float size = gv.getFont().getSize2D();
GlyphJustificationInfo nullInfo =
new GlyphJustificationInfo(0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
GlyphJustificationInfo spaceInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);
GlyphJustificationInfo kanjiInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
char[] chars = source.getChars();
int offset = source.getStart();
// assume data is 1-1 and either all rtl or all ltr, for now
int numGlyphs = gv.getNumGlyphs();
int minGlyph = 0;
int maxGlyph = numGlyphs;
boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
if (charStart != 0 || charLimit != source.getLength()) {
if (ltr) {
minGlyph = charStart;
maxGlyph = charLimit;
} else {
minGlyph = numGlyphs - charLimit;
maxGlyph = numGlyphs - charStart;
}
}
for (int i = 0; i < numGlyphs; ++i) {
GlyphJustificationInfo info = null;
if (i >= minGlyph && i < maxGlyph) {
if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
info = nullInfo;
} else {
int ci = v2l(i); // 1-1 assumption again
char c = chars[offset + ci];
if (Character.isWhitespace(c)) {
info = spaceInfo;
// CJK, Hangul, CJK Compatibility areas
} else if (c >= 0x4e00 &&
(c < 0xa000) ||
(c >= 0xac00 && c < 0xd7b0) ||
(c >= 0xf900 && c < 0xfb00)) {
info = kanjiInfo;
} else {
info = nullInfo;
}
}
}
infos[infoStart + i] = info;
}
}
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
// This simple implementation only uses spaces for justification.
// Since regular characters aren't justified, we don't need to deal with
// special infos for combining marks or ligature substitution glyphs.
// added character justification for kanjii only 2/22/98
StandardGlyphVector gv = getGV();
float[] charinfo = getCharinfo();
float size = gv.getFont().getSize2D();
GlyphJustificationInfo nullInfo =
new GlyphJustificationInfo(0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
GlyphJustificationInfo spaceInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);
GlyphJustificationInfo kanjiInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
char[] chars = source.getChars();
int offset = source.getStart();
// assume data is 1-1 and either all rtl or all ltr, for now
int numGlyphs = gv.getNumGlyphs();
int minGlyph = 0;
int maxGlyph = numGlyphs;
boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
if (charStart != 0 || charLimit != source.getLength()) {
if (ltr) {
minGlyph = charStart;
maxGlyph = charLimit;
} else {
minGlyph = numGlyphs - charLimit;
maxGlyph = numGlyphs - charStart;
}
}
for (int i = 0; i < numGlyphs; ++i) {
GlyphJustificationInfo info = null;
if (i >= minGlyph && i < maxGlyph) {
if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
info = nullInfo;
} else {
int ci = v2l(i); // 1-1 assumption again
char c = chars[offset + ci];
if (Character.isWhitespace(c)) {
info = spaceInfo;
// CJK, Hangul, CJK Compatibility areas
} else if (c >= 0x4e00 &&
(c < 0xa000) ||
(c >= 0xac00 && c < 0xd7b0) ||
(c >= 0xf900 && c < 0xfb00)) {
info = kanjiInfo;
} else {
info = nullInfo;
}
}
}
infos[infoStart + i] = info;
}
}
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
// This simple implementation only uses spaces for justification.
// Since regular characters aren't justified, we don't need to deal with
// special infos for combining marks or ligature substitution glyphs.
// added character justification for kanjii only 2/22/98
StandardGlyphVector gv = getGV();
float[] charinfo = getCharinfo();
float size = gv.getFont().getSize2D();
GlyphJustificationInfo nullInfo =
new GlyphJustificationInfo(0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
GlyphJustificationInfo spaceInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);
GlyphJustificationInfo kanjiInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
char[] chars = source.getChars();
int offset = source.getStart();
// assume data is 1-1 and either all rtl or all ltr, for now
int numGlyphs = gv.getNumGlyphs();
int minGlyph = 0;
int maxGlyph = numGlyphs;
boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
if (charStart != 0 || charLimit != source.getLength()) {
if (ltr) {
minGlyph = charStart;
maxGlyph = charLimit;
} else {
minGlyph = numGlyphs - charLimit;
maxGlyph = numGlyphs - charStart;
}
}
for (int i = 0; i < numGlyphs; ++i) {
GlyphJustificationInfo info = null;
if (i >= minGlyph && i < maxGlyph) {
if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
info = nullInfo;
} else {
int ci = v2l(i); // 1-1 assumption again
char c = chars[offset + ci];
if (Character.isWhitespace(c)) {
info = spaceInfo;
// CJK, Hangul, CJK Compatibility areas
} else if (c >= 0x4e00 &&
(c < 0xa000) ||
(c >= 0xac00 && c < 0xd7b0) ||
(c >= 0xf900 && c < 0xfb00)) {
info = kanjiInfo;
} else {
info = nullInfo;
}
}
}
infos[infoStart + i] = info;
}
}
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
// This simple implementation only uses spaces for justification.
// Since regular characters aren't justified, we don't need to deal with
// special infos for combining marks or ligature substitution glyphs.
// added character justification for kanjii only 2/22/98
StandardGlyphVector gv = getGV();
float[] charinfo = getCharinfo();
float size = gv.getFont().getSize2D();
GlyphJustificationInfo nullInfo =
new GlyphJustificationInfo(0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
GlyphJustificationInfo spaceInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);
GlyphJustificationInfo kanjiInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
char[] chars = source.getChars();
int offset = source.getStart();
// assume data is 1-1 and either all rtl or all ltr, for now
int numGlyphs = gv.getNumGlyphs();
int minGlyph = 0;
int maxGlyph = numGlyphs;
boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
if (charStart != 0 || charLimit != source.getLength()) {
if (ltr) {
minGlyph = charStart;
maxGlyph = charLimit;
} else {
minGlyph = numGlyphs - charLimit;
maxGlyph = numGlyphs - charStart;
}
}
for (int i = 0; i < numGlyphs; ++i) {
GlyphJustificationInfo info = null;
if (i >= minGlyph && i < maxGlyph) {
if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
info = nullInfo;
} else {
int ci = v2l(i); // 1-1 assumption again
char c = chars[offset + ci];
if (Character.isWhitespace(c)) {
info = spaceInfo;
// CJK, Hangul, CJK Compatibility areas
} else if (c >= 0x4e00 &&
(c < 0xa000) ||
(c >= 0xac00 && c < 0xd7b0) ||
(c >= 0xf900 && c < 0xfb00)) {
info = kanjiInfo;
} else {
info = nullInfo;
}
}
}
infos[infoStart + i] = info;
}
}
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
// This simple implementation only uses spaces for justification.
// Since regular characters aren't justified, we don't need to deal with
// special infos for combining marks or ligature substitution glyphs.
// added character justification for kanjii only 2/22/98
StandardGlyphVector gv = getGV();
float[] charinfo = getCharinfo();
float size = gv.getFont().getSize2D();
GlyphJustificationInfo nullInfo =
new GlyphJustificationInfo(0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
GlyphJustificationInfo spaceInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);
GlyphJustificationInfo kanjiInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
char[] chars = source.getChars();
int offset = source.getStart();
// assume data is 1-1 and either all rtl or all ltr, for now
int numGlyphs = gv.getNumGlyphs();
int minGlyph = 0;
int maxGlyph = numGlyphs;
boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
if (charStart != 0 || charLimit != source.getLength()) {
if (ltr) {
minGlyph = charStart;
maxGlyph = charLimit;
} else {
minGlyph = numGlyphs - charLimit;
maxGlyph = numGlyphs - charStart;
}
}
for (int i = 0; i < numGlyphs; ++i) {
GlyphJustificationInfo info = null;
if (i >= minGlyph && i < maxGlyph) {
if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
info = nullInfo;
} else {
int ci = v2l(i); // 1-1 assumption again
char c = chars[offset + ci];
if (Character.isWhitespace(c)) {
info = spaceInfo;
// CJK, Hangul, CJK Compatibility areas
} else if (c >= 0x4e00 &&
(c < 0xa000) ||
(c >= 0xac00 && c < 0xd7b0) ||
(c >= 0xf900 && c < 0xfb00)) {
info = kanjiInfo;
} else {
info = nullInfo;
}
}
}
infos[infoStart + i] = info;
}
}
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
// This simple implementation only uses spaces for justification.
// Since regular characters aren't justified, we don't need to deal with
// special infos for combining marks or ligature substitution glyphs.
// added character justification for kanjii only 2/22/98
StandardGlyphVector gv = getGV();
float[] charinfo = getCharinfo();
float size = gv.getFont().getSize2D();
GlyphJustificationInfo nullInfo =
new GlyphJustificationInfo(0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
GlyphJustificationInfo spaceInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);
GlyphJustificationInfo kanjiInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
char[] chars = source.getChars();
int offset = source.getStart();
// assume data is 1-1 and either all rtl or all ltr, for now
int numGlyphs = gv.getNumGlyphs();
int minGlyph = 0;
int maxGlyph = numGlyphs;
boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
if (charStart != 0 || charLimit != source.getLength()) {
if (ltr) {
minGlyph = charStart;
maxGlyph = charLimit;
} else {
minGlyph = numGlyphs - charLimit;
maxGlyph = numGlyphs - charStart;
}
}
for (int i = 0; i < numGlyphs; ++i) {
GlyphJustificationInfo info = null;
if (i >= minGlyph && i < maxGlyph) {
if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
info = nullInfo;
} else {
int ci = v2l(i); // 1-1 assumption again
char c = chars[offset + ci];
if (Character.isWhitespace(c)) {
info = spaceInfo;
// CJK, Hangul, CJK Compatibility areas
} else if (c >= 0x4e00 &&
(c < 0xa000) ||
(c >= 0xac00 && c < 0xd7b0) ||
(c >= 0xf900 && c < 0xfb00)) {
info = kanjiInfo;
} else {
info = nullInfo;
}
}
}
infos[infoStart + i] = info;
}
}
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
// This simple implementation only uses spaces for justification.
// Since regular characters aren't justified, we don't need to deal with
// special infos for combining marks or ligature substitution glyphs.
// added character justification for kanjii only 2/22/98
StandardGlyphVector gv = getGV();
float[] charinfo = getCharinfo();
float size = gv.getFont().getSize2D();
GlyphJustificationInfo nullInfo =
new GlyphJustificationInfo(0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
GlyphJustificationInfo spaceInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);
GlyphJustificationInfo kanjiInfo =
new GlyphJustificationInfo(size,
true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);
char[] chars = source.getChars();
int offset = source.getStart();
// assume data is 1-1 and either all rtl or all ltr, for now
int numGlyphs = gv.getNumGlyphs();
int minGlyph = 0;
int maxGlyph = numGlyphs;
boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
if (charStart != 0 || charLimit != source.getLength()) {
if (ltr) {
minGlyph = charStart;
maxGlyph = charLimit;
} else {
minGlyph = numGlyphs - charLimit;
maxGlyph = numGlyphs - charStart;
}
}
for (int i = 0; i < numGlyphs; ++i) {
GlyphJustificationInfo info = null;
if (i >= minGlyph && i < maxGlyph) {
if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
info = nullInfo;
} else {
int ci = v2l(i); // 1-1 assumption again
char c = chars[offset + ci];
if (Character.isWhitespace(c)) {
info = spaceInfo;
// CJK, Hangul, CJK Compatibility areas
} else if (c >= 0x4e00 &&
(c < 0xa000) ||
(c >= 0xac00 && c < 0xd7b0) ||
(c >= 0xf900 && c < 0xfb00)) {
info = kanjiInfo;
} else {
info = nullInfo;
}
}
}
infos[infoStart + i] = info;
}
}
@Override
public GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex) {
throw new UnsupportedOperationException();
}
/**
* Returns the justification information for the glyph at
* the specified index into this <code>GlyphVector</code>.
* @param glyphIndex the index into this <code>GlyphVector</code>
* that corresponds to the glyph from which to retrieve its
* justification properties
* @return a {@link GlyphJustificationInfo} object that
* represents the justification properties of the glyph at the
* specified <code>glyphIndex</code> into this
* <code>GlyphVector</code>.
* @throws IndexOutOfBoundsException if <code>glyphIndex</code>
* is less than 0 or greater than or equal to the number
* of glyphs in this <code>GlyphVector</code>
*/
public abstract GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex);
/**
* Returns the justification information for the glyph at
* the specified index into this <code>GlyphVector</code>.
* @param glyphIndex the index into this <code>GlyphVector</code>
* that corresponds to the glyph from which to retrieve its
* justification properties
* @return a {@link GlyphJustificationInfo} object that
* represents the justification properties of the glyph at the
* specified <code>glyphIndex</code> into this
* <code>GlyphVector</code>.
* @throws IndexOutOfBoundsException if <code>glyphIndex</code>
* is less than 0 or greater than or equal to the number
* of glyphs in this <code>GlyphVector</code>
*/
public abstract GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex);
/**
* Return GlyphJustificationInfo objects for the characters between
* charStart and charLimit, starting at offset infoStart. Infos
* will be in visual order. All positions between infoStart and
* getNumJustificationInfos will be set. If a position corresponds
* to a character outside the provided range, it is set to null.
*/
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit) {
}
/**
* Return GlyphJustificationInfo objects for the characters between
* charStart and charLimit, starting at offset infoStart. Infos
* will be in visual order. All positions between infoStart and
* getNumJustificationInfos will be set. If a position corresponds
* to a character outside the provided range, it is set to null.
*/
public abstract void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit);
/**
* Return GlyphJustificationInfo objects for the characters between
* charStart and charLimit, starting at offset infoStart. Infos
* will be in visual order. All positions between infoStart and
* getNumJustificationInfos will be set. If a position corresponds
* to a character outside the provided range, it is set to null.
*/
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit);