代码很简单:
InputStream psdInput = TestPsd.class.getResourceAsStream("/PSD/sample2.psd");
PsdLoadOptions psdLoadOptions = new PsdLoadOptions();
psdLoadOptions.setReadOnlyMode(false);
psdLoadOptions.setLoadEffectsResource(true);
PsdImage image = (PsdImage) PsdImage.load(psdInput, psdLoadOptions);
Layer[] layers = image.getLayers();
System.out.println(“layer size:” + layers.length);
for (Layer layer : layers) {
if (layer instanceof TextLayer) {
TextLayer textLayer = (TextLayer) layer;
textLayer.updateText(“Hello World好的”);
}
JpegOptions jpegOptions = new JpegOptions();
image.save("/Users/hehe/tmp/result.jpg", jpegOptions);
期望的是这样的结果:
image.jpg (298.8 KB)
但是转换出来的却是:
image.jpg (184.0 KB)
检查过字体安装,以及 textData 对象中的 style 字体名称,也是正确的字体,但是转换结果里面的中文样式不正确。