下面列出了java.awt.Font#layoutGlyphVector ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g.setColor(Color.black);
float x = 100;
float y = 100;
Font f = FontUtils.getFont();
g.setFont(f);
FontRenderContext frc = g2.getFontRenderContext();
GlyphVector gv = f.layoutGlyphVector(frc, text.toCharArray(), 0, text.length(), Font.LAYOUT_LEFT_TO_RIGHT);
Rectangle2D bb = gv.getPixelBounds(frc, x, y);
double scale = 2.91;
scale = 1.3461;
scale = 2;
bb.setRect(bb.getX() - 250.5, bb.getY() + 150.566, bb.getWidth()*scale, bb.getHeight()*scale);
drawTextInBox(g2, text, bb);
}
public void runTest(Object ctx, int numReps) {
TCContext tcctx = (TCContext)ctx;
final Font font = tcctx.font;
final char[] chars = tcctx.chars1;
final int start = 1;
final int limit = chars.length - 1;
final FontRenderContext frc = tcctx.frc;
final int flags = tcctx.flags;
GlyphVector gv;
do {
gv = font.layoutGlyphVector(frc, chars, start, limit, flags);
} while (--numReps >= 0);
}