Java AWT字体混乱 [英] Java AWT Fonts scrambled

查看:84
本文介绍了Java AWT字体混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前正在使用以下代码在XChart库中绘制文本,但例如在ODROID C2上,文本已被打乱且不可读(请参阅所附图片).之前使用的代码是从layout.draw开头的行,但由于它在EPS和PDF导出中引起问题,因此已被替换.我们在此处上有一个github问题,其中指出了各种问题的原因.在其他几种安装上运行正常.

We are currently using the following code to draw texts in the XChart Library, but on the ODROID C2 for example the text is scrambled and not readable (see attached picture for reference). The code used before was the line starting with layout.draw but it was replaced as it was causing issues in the EPS and PDF export. We have a github issue here which states various reasons for the problems. It is working fine on several other installations.

      FontRenderContext frc = g.getFontRenderContext();
      // TextLayout layout = new TextLayout(tickLabel, font, new FontRenderContext(null, true, false));
      TextLayout layout = new TextLayout(tickLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), frc);
      Rectangle2D tickLabelBounds = layout.getBounds();
      // layout.draw(g, (float) xOffset, (float) (yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0));

      Shape shape = layout.getOutline(null);

      AffineTransform orig = g.getTransform();
      AffineTransform at = new AffineTransform();
      at.translate((float) xOffset, (float) (yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0));
      g.transform(at);
      g.fill(shape);
      g.setTransform(orig);

更新:

结果证明这与arm64 java有关.当使用64位Java时,问题如下所示,当使用32位Java时,它可以正常工作.仍然我不知道为什么或如何解决这个问题.

Turns out this is arm64 java related. When using 64 Bit Java the issue is as shown, when using 32 Bit Java it is working normally. Still I don't have any idea why or how to fix this.

推荐答案

此问题与在odroid c2上运行的oracles arm64 Java有关.切换到Zulu Java后,该问题已解决.

This issue was somehow related to oracles arm64 Java running on the odroid c2. After switching to Zulu Java, the issue was resolved.

这篇关于Java AWT字体混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆