Browse Source

Don't fail svg icon painting if svg is malformed

pull/336/head
Jannis Weis 2 years ago
parent
commit
818b213130
No known key found for this signature in database
GPG Key ID: 7C9D8D4B558049AB
  1. 11
      property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/DarkSVGIcon.java

11
property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/DarkSVGIcon.java

@ -152,9 +152,9 @@ public class DarkSVGIcon
@Override
public Image createImage(final Dimension size) {
ensureLoaded(false);
BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) bi.getGraphics();
try {
BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) bi.getGraphics();
g.setRenderingHint(
RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(
@ -162,11 +162,12 @@ public class DarkSVGIcon
Object aaHint = UIManager.get(RenderingHints.KEY_TEXT_ANTIALIASING);
if (aaHint != null) g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, aaHint);
svgDocumentHolder.svgDocument.render(null, g, new ViewBox(0, 0, size.width, size.height));
g.dispose();
return bi;
} catch (final RuntimeException e) {
throw new RuntimeException("Exception while painting '" + getURI().toASCIIString() + "'.", e);
LOGGER.log(Level.SEVERE, "Exception while painting '" + getURI().toASCIIString() + "'.", e);
} finally {
g.dispose();
}
return bi;
}
protected String getName(final URI uri) {

Loading…
Cancel
Save