Hello.
We have a simple app (testing purposes) that iterates through all the text layers of a PSD file, creates a new text Portion with empty text, adds it to the layer, and saves it.
When this code is executed on linux, for psd files that have asian text characters when we open the file resulted after the save we don’t see any text and we get the following error:
image.png (3.8 KB)
Code:
var psdImage = (PsdImage)Image.Load(psdFilePath);
foreach (var layer in psdImage.Layers)
{
if (layer is TextLayer textLayer)
{
var newPortion = textLayer.TextData.ProducePortions(
new[] { “” },
null,
null
).First();
textLayer.TextData.AddPortion(newPortion);
textLayer.TextData.UpdateLayerData();
}
}
var imageOptions = new PsdOptions(psdImage);
var psdSaveName = $“{psdSavePath}”;
psdImage.Save(psdSaveName, imageOptions);
psdImage.Dispose();
Starting from the document:
4RowsChinese.zip (112.5 KB)
We get the following document:
4RowsChineseResult.zip (16.9 KB)
On windows everything works fine, I reproduced this issue on Aspose.PSD 24.9, 24.8, 24.7 and 24.6. If we open the resulted file and double click the text layers or change the font to simsun (For example) everything seems to fix. I don’t know why this is happening.
Can you please take a look ?
Let me know if you need further information
@afaluta we had similar request this month. Please check this: https://forum.aspose.com/t/aspose-psd/286640/2
Please try to update the font in portion with the font, that is installed under your Linux environment and supports Asian Characters
// It's important to change the font to one which supports Asian Characters
var fontName = FontSettings.GetAdobeFontName("Microsoft YaHei");
portion.Style.FontName = fontName;
textData.UpdateLayerData()
Please let me know if this didn’t help.
Hello i can’t acces the link, i get a private page message. Can you please share it again with me ?
And the idea is that if i have in the original file a font with asian characters i have to use the same one in the one with the modifications so i can not always force the font.
@afaluta
@afaluta at this moment, the only way to determine if the font supports the Asian Characters is to write something and check if the text is visible. Also, the good solution will be to have the list of fonts that support the Asian characters and force the font changing in the situation when it doesn’t support needed characters.
We have opened the following new ticket(s) in our internal issue tracking system about the way to deretermine if the font supports specific characters and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PSDNET-2210
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.
Hi
Thanks for info.
I tried the small code you’ve suggested above and I get an error (Aspose.PSD.CoreExceptions.ImageFormats.PsdImageArgumentException: ‘Font name can’t be NULL, empty, or whitespace.’) on linux with every kind of chinese font I put in the GetAdobeFontName (with the one suggested by you also ). Any ideas if I can try something else ?
@afaluta please check what fonts are installed under your OS. Please also specify what’s Linux distributive you use? Do you use it locally or under the docker? Many of Linux distributives from docker, doesn’t contain any specific fonts. Did you use .NET 7 version of Aspose.PSD? Do you have installed on in your OS packages from How to Run Aspose.PSD in Docker|Documentation
Thank you.