请问如何更换PSD文件中某一行文本的字体呢?
我用调用字体方法出错:
PsdLoadOptions loadOptions = new PsdLoadOptions(); loadOptions.setDefaultReplacementFont(“Arial”);
image.png (21.5 KB)
OS 版本:Windows 10 专业版
Aspose版本:23.4
请尝试以下代码 (ITextStyle - Aspose.PSD for Java - API Reference):
String[] specificFontNames = new String[] { "Chiller", "Algerian", "Blackadder ITC", "Bauhaus 93", "Californian FB", "Courier New", "Berlin Sans FB Demi", "Informal Roman", "Segoe Print", "Times New Roman", };
String[] generalFontNames = new String[] { "Arial", "Comic Sans MS", "Courier New", "Georgia", "Impact", "Lucida Console", "Lucida Sans Unicode", "Palatino Linotype", "Tahoma", "Microsoft Sans Serif", };
String outputFilePsd = "fontEditTest.psd";
final PsdImage image = new PsdImage(500, 500);
try /*JAVA: was using*/
{
for (int i = 0; i < specificFontNames.length; i++)
{
String fontName = specificFontNames[i];
TextLayer textLayer = image.addTextLayer(fontName, new Rectangle(10, (i + 1) * layerHeight, image.getWidth(), layerHeight));
ITextPortion firstPortion = textLayer.getTextData().getItems()[0];
firstPortion.getStyle().setFontSize(24);
firstPortion.getStyle().setFontName(FontSettings.getAdobeFontName(fontName));
firstPortion.setText(firstPortion.getText().trim());
ITextPortion secondPortion = textLayer.getTextData().producePortion();
secondPortion.setText(" - other font");
secondPortion.getParagraph().apply(firstPortion.getParagraph());
secondPortion.getStyle().apply(firstPortion.getStyle());
secondPortion.getStyle().setFontName(FontSettings.getAdobeFontName(generalFontNames[i]));
textLayer.getTextData().addPortion(secondPortion);
textLayer.getTextData().updateLayerData();
}
image.save(outputFilePsd);
}
finally { if (image != null) (image).dispose(); }
@junjun.pan
这是一个已知的错误,我已将其附加到您的票证中。该问题将在 Aspose.PSD for Java 23.6 的下一版本中修复,预计 2 周后。在此之前,您可以尝试旧版本的 Aspose.PSD for Java。我们会尽力更快地解决这个问题
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PSDJAVA-457
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
请问可以编辑倾斜文本吗?
如果可以,编辑文本的时候任何设置倾斜角度?
@junjun.pan
请用 ITextStyle - Aspose.PSD for Java - API Reference
例子: TextPortions[3].getStyle().setFauxItalic(true); // edit text style of “Italic\r”