gpt4 book ai didi

java - 如何配置 Google AppEngine 以处理 vector 图形?

转载 作者:搜寻专家 更新时间:2023-11-01 02:01:34 25 4
gpt4 key购买 nike

在使用 Java8 的 AppEngine 标准环境中尝试使用 SVG 时出现下一个错误。当我尝试使用 slide.draw(graphics2D) 等 POI 在 XSLFSlide 上绘制 SVG 或使用 Batik 将 SVG 转换为 PNG 时,出现此错误。出现问题似乎是因为 fontconfig 找不到字体。在 debian 发行版中,它通过安装 libfontconfig1 来解决。如何在 AppEngine 上解决它?

java.lang.NullPointerException
at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774)
at sun.font.SunFontManager$2.run(SunFontManager.java:431)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.SunFontManager.<init>(SunFontManager.java:376)
at sun.awt.FcFontManager.<init>(FcFontManager.java:35)
at sun.awt.X11FontManager.<init>(X11FontManager.java:57)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:443)
at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.awt.Font.getFont2D(Font.java:491)
at java.awt.Font.canDisplay(Font.java:1980)
at org.apache.poi.sl.draw.DrawTextParagraph.canDisplayUpTo(DrawTextParagraph.java:756)
at org.apache.poi.sl.draw.DrawTextParagraph.getAttributedString(DrawTextParagraph.java:640)
at org.apache.poi.sl.draw.DrawTextParagraph.breakText(DrawTextParagraph.java:248)
at org.apache.poi.sl.draw.DrawTextShape.drawParagraphs(DrawTextShape.java:159)
at org.apache.poi.sl.draw.DrawTextShape.getTextHeight(DrawTextShape.java:220)
at org.apache.poi.sl.draw.DrawTextShape.drawContent(DrawTextShape.java:102)
at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:93)
at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:71)
at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:41)
at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:307)

最佳答案

我遇到了同样的问题,并通过设置 "sun.awt.fontconfig" 系统属性明确告诉 AppEngine VM 一个特定的字体配置来解决它。尝试在源代码开头的某处插入以下代码(在使用任何字体或图形组件之前):

    String fontConfig = System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + "fontconfig.Prodimage.properties";
if (new File(fontConfig).exists())
System.setProperty("sun.awt.fontconfig", fontConfig);

关于java - 如何配置 Google AppEngine 以处理 vector 图形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45100138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com