[英]Is there a maximum font size for Java Graphics2D?
I am creating image tiles in Java, and require to create very large texts (font sizes over 200,000...) However, it seems that when the font size reaches over a certain threshold, the Graphics engine in Java (JDK1.6.0.18) no longer draws the string correctly. 我正在用Java创建图像图块,并且需要创建非常大的文本(字体大小超过200,000 ...)。但是,似乎当字体大小超过某个阈值时,Java中的图形引擎(JDK1.6.0.18 )不再正确绘制字符串。 On my Win7/64 environment it seems I can only print Helvetica characters up to 27915 pixel size.
在Win7 / 64环境中,看来我只能打印最大27915像素大小的Helvetica字符。
Is there a way around this? 有没有解决的办法? How can I draw such large characters?
如何绘制这么大的字符? Am I doing something wrong?
难道我做错了什么? Is this a known limitation?
这是已知限制吗?
A sample application: 一个示例应用程序:
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import com.sun.image.codec.jpeg.*;
public class FontTest {
public static void main(String[] args) throws Exception {
BufferedImage image = new BufferedImage(1000,1000,BufferedImage.TYPE_INT_RGB);
Graphics2D g = Zoomer.getGraphics(image);
int fontsize = 27916;
Font font = new Font("Helvetica",Font.PLAIN,fontsize);
g.setFont(font);
g.setColor(Color.YELLOW);
g.drawString("Z", 5, 990);
JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder(new FileOutputStream(new File("image."+fontsize+".jpg"),false));
JPEGEncodeParam param = jpeg.getDefaultJPEGEncodeParam(image);
jpeg.encode(image);
System.out.println("Ready with fontsize:"+fontsize);
}
Any image up to 27915 displays the left bottom part of the Z correctly, but for 27915 and higher, it displays it backward somehow. 直到27915以下的任何图像都可以正确显示Z的左下部分,但是对于27915及更高版本,它会以某种方式向后显示。
Sample of the wrong image (with the yellow to the left i/o the right: size=27,916 错误图像的样本(左侧为黄色,右侧为I / O: 大小= 27916
Which JDK version are you using? 您正在使用哪个JDK版本? Try the latest JDK 6 release as well as the latest JDK 7 beta.
试用最新的JDK 6版本以及最新的JDK 7 beta。 Or use Apache Batik instead.
或改用Apache Batik 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.