Font rendering to thumbnails broken with OpenJDK 8u232


#1

The rendering of fonts is broken with OpenJDK 8 u232. It looks like the glyphs are rendered at the wrong x-position and subsequently overlap with each other.

It looks fine with small font sizes,

  • fine with Courier New and font size 12, but not with font size 14.
  • fine with Arial and font size 10, but not with font size 12, see attachments.

Last known working JDK version: OpenJDK 8 u222.

Could be observed with

  • OS: Windows 10, CentOS 7
  • Aspose Slides Java versions: 15.11, 19.7, 19.10
  • fonts: Arial, Liberation Sans, Calibri, Times New Roman, Consolas, Courier New

Minimal working example

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.aspose.slides.FontData;
import com.aspose.slides.IAutoShape;
import com.aspose.slides.IParagraph;
import com.aspose.slides.IPortion;
import com.aspose.slides.ISlide;
import com.aspose.slides.Presentation;
import com.aspose.slides.ShapeType;

public class Main {

	public static void main(String[] args) {
		final Presentation presentation = new Presentation();
		final ISlide slide = presentation.getSlides().get_Item(0);
		final IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 160, 160, 400, 200);

		shape.getTextFrame().setText("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.");
		for (final IParagraph paragraph : shape.getTextFrame().getParagraphs()) {
			for (final IPortion portion : paragraph.getPortions()) {
				portion.getPortionFormat().setLatinFont(new FontData("Arial"));
				portion.getPortionFormat().setFontHeight(12);
			}
		}

		final File file = new File("Hello.png");
		try (final FileOutputStream outputStream = new FileOutputStream(file)) {
			System.out.println("Writing file " + file.getAbsolutePath());
			ImageIO.write(slide.getThumbnail(1, 1), "png", outputStream);
		} catch (final IOException e) {
			e.printStackTrace();
		}
	}
}

Hello_Arial_10.png (24.7 KB)
Hello_Arial_12.png (26.2 KB)


#2

@pstoehrer,

I have worked with the sample code shared and have observed the image files shared. An issue with ID SLIDESJAVA-37832 has been created in our issue tracking system to investigate and resolve the issue. This thread has been linked with the issue so that you may be notifeid once the issue will be resolved.