【问题标题】:Faster method than TextLayout.draw() - Graphics2D?比 TextLayout.draw() - Graphics2D 更快的方法?
【发布时间】:2018-07-02 02:03:52
【问题描述】:

我正在执行以下操作以将文本写入位图:

AttributedString as = new AttributedString(buf.toString());
FontRenderContext frc = graphics.getFontRenderContext();
LineBreakMeasurer lineMeasurer = new LineBreakMeasurer(as.getIterator(), frc);
TextLayout layout = lineMeasurer.nextLayout(Integer.MAX_VALUE);
layout.draw (graphics, left, line.getBaseline());

问题是,虽然这在 Java 中非常快,但我们也使用 IKVM 来编译它以在 .NET 下运行,它在那里非常慢。

还有其他方法可以将格式化文本写入 Graphics2D 对象吗?

【问题讨论】:

    标签: java graphics2d ikvm


    【解决方案1】:

    我们在 IKVM 中发现了问题(它为每个字形的曲线中的每个点重新创建一个数组一次 - 因此实际上是数百万个数组创建)。

    我们在 IKVM 中修复了这个问题,现在它在 IKVM 下也可以快速点亮。如果您遇到同样的问题,我们会在 https://www.nuget.org/packages/IKVM.WINDWARD/ 上进行此修复。

    【讨论】:

      猜你喜欢
      • 2014-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2020-04-22
      • 2015-05-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多