2cf84c9c2c643f157a7b389a937dc21.jpg (125.1 KB)
d8b45cf8239c244632c811e5c46a8a5.jpg (121.7 KB)
仅仅只是修改文字图层内容,没有去改变其他东西
相关文件请通过链接下载: http://103.40.13.9:55287/s/88b0ff6c3feb42469f
2cf84c9c2c643f157a7b389a937dc21.jpg (125.1 KB)
d8b45cf8239c244632c811e5c46a8a5.jpg (121.7 KB)
仅仅只是修改文字图层内容,没有去改变其他东西
相关文件请通过链接下载: http://103.40.13.9:55287/s/88b0ff6c3feb42469f
在使用Aspose.PSD 24.12修改PSD文件中的文字图层内容时,如果发现字体样式丢失,可能是由于未正确更新文本属性或未保存文本样式的设置。您可以通过以下步骤来确保文本样式的保留:
获取文本属性:在更新文本之前,首先获取当前文本图层的属性,包括字体、大小、颜色等。这可以通过TextLayer
类来实现。
更新文本内容:使用TextLayer.UpdateText
方法来更新文本内容。确保在更新文本之前,您已经保存了原有的文本样式。
设置文本样式:在更新文本后,您可以重新应用之前获取的文本样式,以确保样式不丢失。
以下是一个示例代码片段,展示如何获取和更新文本图层的内容及样式:
using Aspose.PSD;
using Aspose.PSD.FileFormats.Psd;
using Aspose.PSD.FileFormats.Psd.Layers;
// 加载PSD文件
using (var image = Image.Load("input.psd"))
{
// 获取文本图层
var textLayer = image.Layers.OfType<TextLayer>().FirstOrDefault();
if (textLayer != null)
{
// 获取当前文本属性
var originalText = textLayer.Text;
var originalFont = textLayer.Font;
var originalSize = textLayer.FontSize;
// 更新文本内容
textLayer.UpdateText("新的文本内容");
// 重新应用原有的文本样式
textLayer.Font = originalFont;
textLayer.FontSize = originalSize;
// 保存修改后的PSD文件
image.Save("output.psd");
}
}
请确保在更新文本时,您正确处理了文本样式的获取和设置,以避免样式丢失的问题。如果问题仍然存在,建议检查Aspose.PSD的文档,了解更多关于文本图层的操作和属性设置的信息。
如果您需要更详细的指导或示例,可以参考Aspose的官方文档,特别是关于文本图层的部分。
Sources:
[1]: Working With Text Layers - Aspose Documentation
安装了的,我的字体包也附带在链接里面了
@summerxiong
I’ll write you back after the investigation.
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): PSDNET-2310
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.
I am testing whether this software meets my requirements and I would like to know approximately how long it will take to resolve the issue. I need to report the call results to my boss
@summerxiong 它仍在工作中。调查完毕后,我会在 1-2 天内给您写信。快速回答:通常可以使用以下代码解决此类问题:
FontSettings.SetFontsFolder(testFontsFolder); // testFontsFolder is a folder with all fonts that you need for work
FontSettings.UpdateFonts();
@summerxiong please try java version of this method: FontSettings | Aspose.PSD for Java API Reference (the first character should be lower case)
I have tried this method, but it has not been effective either
Did you find the problem?
Has there been any progress so far
Did you find the problem
@summerxiong
After investigation we opened additional task - optimizing of stroke effect rendering.
But I wasn’t able to reproduce issue with font.
string srcFile = @"SomeFolder\test2.psd";
string outFile = @"SomeFolder\test2_out.png";
// SomeFolder is a place where provided font is stored.
FontSettings.SetFontsFolder(@"SomeFolder"); // testFontsFolder is a folder with all fonts that you need for work
FontSettings.UpdateFonts();
using (var psdImage = (PsdImage)Image.Load(srcFile, new PsdLoadOptions() { }))
{
psdImage.Save(outFile, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
// The result is file with a correct font
}
Could you please provide additional details, what’s OS and .NET version of Aspose.PSD if used?
For the optimization we opened the following task:
Issue ID(s): PSDNET-2354
You can obtain Paid Support if you need support on a priority basis, along with the direct access to our Paid Support management team.