Skip to content

Replace printStackTrace() in OpenHtmlGvtFont with proper logging #715

@tfo

Description

@tfo

Hello,

While analyzing a problem in our system where we use the openhtmltopdf re noticed that our logs are heavily polluted with stacktraces that are created through a e.printStackTrace() in in the OpenHtmlGvtFont class. Because of our setup we are not able to redirect STDOUT and STDERR into our logging framework. Although the corresponding exception should not happen (according to the code) it would be great if it would be logged using a proper logger and not STDERR.

`
public OpenHtmlGvtFont(byte[] fontBytes, GVTFontFamily family, float size, Float fontWeight, Float fontStyle) throws FontFormatException {
Font font;

	try {
		font = Font.createFont(Font.TRUETYPE_FONT, new ByteArrayInputStream(fontBytes)).deriveFont(toFontWeight(fontWeight) | toStyle(fontStyle) , size);
	} catch (IOException e) {
		// Shouldn't happen
		e.printStackTrace(); // Although it should not happen, it would be great to use a logger here.
		font = null;
	}

	this.baseFont = font;
	this.fontFamily = family;
}

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions