本文整理汇总了Java中org.apache.harmony.awt.gl.font.CompositeFont.getGlyph方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeFont.getGlyph方法的具体用法?Java CompositeFont.getGlyph怎么用?Java CompositeFont.getGlyph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.harmony.awt.gl.font.CompositeFont
的用法示例。
在下文中一共展示了CompositeFont.getGlyph方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawCompositeString
import org.apache.harmony.awt.gl.font.CompositeFont; //导入方法依赖的package包/类
/**
* Method to draw string with graphics that has composite font
* at desired coordinates.
*
* @param g CommonGraphics2D to draw onto
* @param str String to draw
* @param x starting X coordinate to draw at
* @param y starting Y coordinate to draw at
*/
public void drawCompositeString(CommonGraphics2D g, String str, double x,
double y) {
XGraphics2D xg2d = (XGraphics2D)g;
long display = xg2d.display;
int screen = xg2d.xConfig.dev.screen;
long colormap = x11.XDefaultColormap(display, screen);
X11.XColor xcolor = getXColor(g.getColor());
long xcolorPtr = xcolor.lock();
CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
long font = 0;
int xOffset = (int)Math.round(x); // X offset to draw
int yOffset = (int)Math.round(y); // Y offset to draw
int offs = 0; // width of substring with the same font header
String sChars = new String();
char chars[];
for (int i=0; i < str.length(); i++){
char c = str.charAt(i);
Glyph gl = wcf.getGlyph(c);
if (font == 0){
font = gl.getPFont();
}
int glWidth = Math.round(gl.getGlyphPointMetrics().getAdvance());
if (glWidth ==0){
continue;
}
long glPFont = gl.getPFont();
if (font != glPFont){
chars = sChars.toCharArray();
LinuxNativeFont.drawStringNative(xg2d.xftDraw, display,
colormap, font, xOffset, yOffset, chars,
sChars.length(), xcolorPtr);
xOffset += offs;
offs = 0;
sChars = String.valueOf(gl.getChar());
font = glPFont;
} else {
sChars += String.valueOf(gl.getChar());
}
offs += glWidth;
}
chars = sChars.toCharArray();
if (chars.length != 0){
LinuxNativeFont.drawStringNative(xg2d.xftDraw, display, colormap,
font, xOffset, yOffset, chars, sChars.length(),
xcolorPtr);
}
xcolor.unlock();
}
示例2: drawCompositeString
import org.apache.harmony.awt.gl.font.CompositeFont; //导入方法依赖的package包/类
/**
* Method to draw string with graphics that has composite font
* at desired coordinates.
*
* @param g Graphics to draw onto
* @param str String to draw
* @param x starting X coordinate to draw at
* @param y starting Y coordinate to draw at
*/
@SuppressWarnings("deprecation")
public void drawCompositeString(Graphics2D g, String str, int x, int y) {
int len = str.length();
if (len == 0){
return;
}
AffineTransform trans = ((WinGDIGraphics2D)g).getTransform();
long gi = ((WinGDIGraphics2D)g).getGraphicsInfo();
long hdc = ((WinGDIGraphics2D)g).getDC();
x += (int)Math.round(trans.getTranslateX());
y += (int)Math.round(trans.getTranslateY());
win32.SetTextColor(hdc, getGDIColor(g.getColor().getRGB()));
win32.SetBkMode(hdc, WindowsDefs.TRANSPARENT);
CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
int fontIndex = charFontIndex;
WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
long font = physFont.getFontHandle();
win32.SelectObject(hdc, font);
int ascent = physFont.getAscent(); // Font ascent
int offs = 0; // width of substring with the same font header
int yOffset = y - ascent; // Y offset to draw (y - font.ascent)
int xOffset = x; // X offset to draw
int start = 0;
int count = 0;
for (int i=0; i < len; i++){
char c = str.charAt(i);
Glyph gl = wcf.getGlyph(c);
int glWidth = Math.round(gl.getGlyphPointMetrics().getAdvance());
if (glWidth ==0){
continue;
}
fontIndex = wcf.getCharFontIndex(c, 0);
if (fontIndex != charFontIndex){
charFontIndex = fontIndex;
win32.TextOutW(hdc, xOffset, yOffset,
str.substring(start, start + count), count);
xOffset += offs;
offs = 0;
count = 1;
start = i;
physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
font = physFont.getFontHandle();
win32.SelectObject(hdc, font);
yOffset = y - physFont.getAscent();
} else {
count++;
}
offs += glWidth;
}
win32.TextOutW(hdc, xOffset, yOffset,
str.substring(start, start + count), count);
}
示例3: drawCompositeString
import org.apache.harmony.awt.gl.font.CompositeFont; //导入方法依赖的package包/类
/**
* Method to draw string with graphics that has composite font
* at desired coordinates.
*
* @param g Graphics to draw onto
* @param str String to draw
* @param x starting X coordinate to draw at
* @param y starting Y coordinate to draw at
*/
@SuppressWarnings("deprecation")
public void drawCompositeString(Graphics2D g, String str, int x, int y) {
int len = str.length();
if (len == 0){
return;
}
AffineTransform trans = ((WinGDIPGraphics2D)g).getTransform();
long gi = ((WinGDIPGraphics2D)g).getGraphicsInfo();
long hdc = NativeFont.gdiPlusGetHDC(gi);
x += (int)Math.round(trans.getTranslateX());
y += (int)Math.round(trans.getTranslateY());
win32.SetTextColor(hdc, getGDIColor(g.getColor().getRGB()));
win32.SetBkMode(hdc, WindowsDefs.TRANSPARENT);
CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
int fontIndex = charFontIndex;
WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
long font = physFont.getFontHandle();
win32.SelectObject(hdc, font);
int ascent = physFont.getAscent(); // Font ascent
int offs = 0; // width of substring with the same font header
int yOffset = y - ascent; // Y offset to draw (y - font.ascent)
int xOffset = x; // X offset to draw
int start = 0;
int count = 0;
for (int i=0; i < len; i++){
char c = str.charAt(i);
Glyph gl = wcf.getGlyph(c);
int glWidth = Math.round(gl.getGlyphPointMetrics().getAdvance());
if (glWidth ==0){
continue;
}
fontIndex = wcf.getCharFontIndex(c, 0);
if (fontIndex != charFontIndex){
charFontIndex = fontIndex;
win32.TextOutW(hdc, xOffset, yOffset,
str.substring(start, start + count), count);
xOffset += offs;
offs = 0;
count = 1;
start = i;
physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
font = physFont.getFontHandle();
win32.SelectObject(hdc, font);
yOffset = y - physFont.getAscent();
} else {
count++;
}
offs += glWidth;
}
win32.TextOutW(hdc, xOffset, yOffset,
str.substring(start, start + count), count);
NativeFont.gdiPlusReleaseHDC(gi, hdc);
}