mickleness / pumpernickel

This Java project includes classes related to desktop applications, Swing, performance, image processing, data structures, and other misc topics.
https://mickleness.github.io/pumpernickel/
MIT License
66 stars 12 forks source link

JVG: Reencode charts, avoid com.apple.laf.AquaFonts$DerivedUIResourceFont #94

Closed mickleness closed 2 years ago

mickleness commented 2 years ago

Currently on Windows when I open several of the writeups the JVG charts won't deserialize. The console includes the error below.

We definitely want to reencode the Font as we serialize the Graphics2DContext. (If I'm feeling clever I might try to think of a way to make future deserialization problems something we can mitigate on deserialization, too...)

java.lang.RuntimeException: java.lang.ClassNotFoundException: com.apple.laf.AquaFonts$DerivedUIResourceFont
    at com.pump.text.html.css.image.CssUrlImageValue.createPaintableFromDataUrl(CssUrlImageValue.java:119)
    at com.pump.text.html.QHTMLFactory.createBase64Image(QHTMLFactory.java:141)
    at com.pump.text.html.QHTMLFactory.create(QHTMLFactory.java:42)
    at java.desktop/javax.swing.text.CompositeView.loadChildren(CompositeView.java:112)
    at java.desktop/javax.swing.text.FlowView$LogicalView.loadChildren(FlowView.java:717)
    at java.desktop/javax.swing.text.CompositeView.setParent(CompositeView.java:139)
    at java.desktop/javax.swing.text.FlowView.loadChildren(FlowView.java:147)
    at java.desktop/javax.swing.text.CompositeView.setParent(CompositeView.java:139)
    at java.desktop/javax.swing.text.FlowView.setParent(FlowView.java:297)
    at java.desktop/javax.swing.text.html.ParagraphView.setParent(ParagraphView.java:75)
    at java.desktop/javax.swing.text.CompositeView.replace(CompositeView.java:219)
    at java.desktop/javax.swing.text.BoxView.replace(BoxView.java:182)
    at java.desktop/javax.swing.text.CompositeView.loadChildren(CompositeView.java:114)
    at java.desktop/javax.swing.text.CompositeView.setParent(CompositeView.java:139)
    at java.desktop/javax.swing.text.html.BlockView.setParent(BlockView.java:72)
    at com.pump.text.html.view.SwingBodyBlockView.setParent(SwingBodyBlockView.java:106)
    at java.desktop/javax.swing.text.CompositeView.replace(CompositeView.java:219)
    at java.desktop/javax.swing.text.BoxView.replace(BoxView.java:182)
    at java.desktop/javax.swing.text.View.updateChildren(View.java:1129)
    at java.desktop/javax.swing.text.View.insertUpdate(View.java:708)
    at java.desktop/javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(BasicTextUI.java:1706)
    at java.desktop/javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.java:1965)
    at java.desktop/javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:203)
    at java.desktop/javax.swing.text.DefaultStyledDocument.create(DefaultStyledDocument.java:159)
    at java.desktop/javax.swing.text.html.HTMLDocument.create(HTMLDocument.java:472)
    at java.desktop/javax.swing.text.html.HTMLDocument$HTMLReader.flushBuffer(HTMLDocument.java:3979)
    at java.desktop/javax.swing.text.html.HTMLDocument$HTMLReader.addContent(HTMLDocument.java:3918)
    at java.desktop/javax.swing.text.html.HTMLDocument$HTMLReader.addContent(HTMLDocument.java:3883)
    at java.desktop/javax.swing.text.html.HTMLDocument$HTMLReader.handleText(HTMLDocument.java:2785)
    at java.desktop/javax.swing.text.html.parser.DocumentParser.handleText(DocumentParser.java:271)
    at java.desktop/javax.swing.text.html.parser.Parser.handleText(Parser.java:409)
    at java.desktop/javax.swing.text.html.parser.Parser.startTag(Parser.java:480)
    at java.desktop/javax.swing.text.html.parser.Parser.parseTag(Parser.java:2054)
    at java.desktop/javax.swing.text.html.parser.Parser.parseContent(Parser.java:2195)
    at java.desktop/javax.swing.text.html.parser.Parser.parse(Parser.java:2372)
    at java.desktop/javax.swing.text.html.parser.DocumentParser.parse(DocumentParser.java:135)
    at java.desktop/javax.swing.text.html.parser.ParserDelegator.parse(ParserDelegator.java:113)
    at java.desktop/javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:263)
    at java.desktop/javax.swing.JEditorPane.read(JEditorPane.java:565)
    at java.desktop/javax.swing.JEditorPane$PageLoader.doInBackground(JEditorPane.java:650)
    at java.desktop/javax.swing.JEditorPane$PageLoader.doInBackground(JEditorPane.java:601)
    at java.desktop/javax.swing.SwingWorker$1.call(SwingWorker.java:304)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.desktop/javax.swing.SwingWorker.run(SwingWorker.java:343)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.ClassNotFoundException: com.apple.laf.AquaFonts$DerivedUIResourceFont
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:427)
    at java.base/java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:762)
    at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1980)
    at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1866)
    at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2159)
    at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1685)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:499)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:457)
    at com.pump.graphics.Graphics2DContext.readObject(Graphics2DContext.java:627)
    at jdk.internal.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1201)
    at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2357)
    at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2191)
    at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1685)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:499)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:457)
    at com.pump.graphics.vector.Operation.readObject(Operation.java:129)
    at jdk.internal.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1201)
    at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2357)
    at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2191)
    at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1685)
    at java.base/java.io.ObjectInputStream.readArray(ObjectInputStream.java:2087)
    at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1673)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:499)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:457)
    at com.pump.graphics.vector.VectorImage.readObject(VectorImage.java:178)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1201)
    at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2357)
    at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2191)
    at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1685)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:499)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:457)
    at com.pump.graphics.vector.VectorImage.<init>(VectorImage.java:72)
    at com.pump.text.html.css.image.CssUrlImageValue.createPaintableFromDataUrl(CssUrlImageValue.java:115)
    ... 46 more