用拉链绘画看起来不好
drawstring
的结果具有相同的字体和大小在Java中
当画家(或单词)中使用相同的字体和大小绘制时,外观是不同的。在Java中用牵引线绘制看起来不好。
为什么看起来如此不同?
有没有办法使它看起来像一个单词或Java中的画家?
顶部是在Java中绘制的,较低的画面是用画家绘制的。
代码:
Font fontBold28 = new Font("Arial", Font.BOLD|Font.ITALIC, 28);
g.setFont(fontBold28);
g.setColor(Color.black);
g.drawString("ABCDEFG", x, y);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抗质量。
文本抗质量(也称为字体平滑)是一种渲染引擎模糊角色形状边缘的能力,因此边缘看起来不会锯齿状。
它通常在JAVA2D图形对象中默认情况下关闭,因为它会导致文本绘图较慢,但是在现代计算环境中,该性能差异的重要性少于以前。除非您经常渲染文本,否则您可能不会注意到差异。
您可以使用
阅读看到他们全部。 java教程也描述了它们。
Antialiasing.
Text antialiasing, also known as font smoothing, is a rendering engine’s ability to blur the edges of character shapes, so the edges don’t look jagged.
It’s usually off by default in Java2D Graphics objects, because it causes text drawing to be slower, but in modern computing environments, that performance difference matters less than it used to. You probably won’t notice the difference, unless you are rendering text frequently.
You can turn on text antialiasing using the setRenderingHint method of Graphics2D:
There are many behaviors of drawing that can be controlled by setting rendering hints. Read the RenderingHints documentation to see them all. The Java Tutorial also describes them.