layer.UpdateText error psdImage.Save error

@lsl there is manual way to fix it.

Please try to remove these files:
“C:\ProgramData\AsposeImagingFontsInfoJson.cache”
“C:\ProgramData\AsposeImagingFontsInfo.cache”
“C:\Users<yourusername>\AppData\Local\AsposeImagingFontsInfoJson.cache”
“C:\Users<yourusername>\AppData\Local\AsposeImagingFontsInfo.cache”

Versions up to 23.11 can corrupt font cache file.

I clean all the cache file , exception as below

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Aspose.PSD.FontParsing.OpenType.Serialization.OpenTypeFontInfo..ctor )
   at .(String[] )
   at .(Boolean )
   at .(String )
   at .(String )
   at .(String )
   at .(String , Boolean )
   at ⸮.(ITextStyle )
   at ⸮.(ITextPortion )
   at ⸮.(ITextPortion[] )
   at ⸮.(ITextPortion[] , SizeF )
   at ⸮.()
   at ⸮.(Boolean )
   at .UpdateLayerData()
   at ⸮.(String , Point , Single , Color)
   at .(Object )
   at .(Object )
   at .(MethodBase , Boolean )
   at ( ,  )
   at ()
   at .(Boolean )
   at .(Object )
   at .(Object )
   at .()
   at .(Object , UInt32 )
   at .(Boolean )
   at .(Object[] , Type[] , Type[] , Object[])
   at .(Stream , String , Object[] , Type[], Type[] , Object[] )
   at .(Stream , String , Object[] )
   at .(Stream , String , Object[] )
   at ⸮.UpdateText(String , Point , Single , Color)
   at Aspose.PSD.FileFormats.Psd.Layers.TextLayer.UpdateText(String text)

The font is installed normally on my computer, and Photoshop can edit it normally

image.png (5.4 KB)

at my test, it broken at
this.Style = OpenTypeFontInfo.\u0002(u0006_u0005_u0003_u2.\u0002()); in class Aspose.PSD.FontParsing.OpenType.Serialization
This is our own font that can recognize edited content normally in Photoshop,Do you need me to send you the font?

@lsl yes, please. Could you plese send to me font for the investigation

@lsl
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-1855

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.

font.zip (2.7 MB)

this is the font ,3q

@lsl I’ve added the font to the task. This task is planned for the next releases. If there will be any additional news, I’ll write you here.

The issues you have found earlier (filed as PSDNET-1855) have been fixed in this update. This message was posted using Bugs notification tool by yaroslav.lisovskyi

I use psd 24.5

 var layer = psdImage.Layers[3] as TextLayer;
 layer.UpdateText("xxxx");

above code will throw exception {System.IndexOutOfRangeException: Index was outside the bounds of the array. at ..(String , FontStyle , Dictionary2 )}`

after my search

		// Token: 0x06000859 RID: 2137 RVA: 0x00029F74 File Offset: 0x00028174
		public FontFamily \u0002(string \u0002, Aspose.PSD.FontStyle \u0003, Dictionary<string, OpenTypeFontInfo> \u0005)
		{
			foreach (KeyValuePair<string, OpenTypeFontInfo[]> keyValuePair in this.\u0003.ToArray<KeyValuePair<string, OpenTypeFontInfo[]>>())
			{
				foreach (OpenTypeFontInfo openTypeFontInfo in keyValuePair.Value)
				{
					if ((openTypeFontInfo.PostScriptName == \u0002 || openTypeFontInfo.FontName == \u0002) && openTypeFontInfo.Style == \u0003 && !\u0005.ContainsKey(\u0002))
					{
//this.\u0002[openTypeFontInfo.PostScriptName].Families.Count ==0 , so throw exception
						return this.\u0002[openTypeFontInfo.PostScriptName].Families[0];
					}
				}
			}
			return null;
		}

@lsl could you please specify OS and .net version of Aspose.PSD that you use.

win11 x64 23h2 .net8 aspose.psd 24.5

layer.UpdateText error psdImage.Save error - #11 by lsl this font

We reproduced this issue, but we need additional time for the investigation. This issue appears only on blank new project if Aspose.PSD referenced as Nuget Package. Our internal tests passed succesfully.

@lsl
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-2071

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.

@lsl could you please share the additional refences for your project and check this article:

Should be added additional packages like:

and Newtonsoft.JSON.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="aspose.lic" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Include="aspose.lic" />
  </ItemGroup>

  <ItemGroup>
 
    <PackageReference Include="Aspose.PSD" Version="24.5.0" />
 
  </ItemGroup>

</Project>

only new .net8 console project System.Text.Encoding.CodePages include default by <Project Sdk="Microsoft.NET.Sdk">

@lsl as a temporary workaround. Is it possible for you to use Aspose.PSD 24.5, but for .NET 6? We will try to fix the issue with .net7 and .net8 ASAP.

The issues you have found earlier (filed as PSDNET-2071) have been fixed in this update. This message was posted using Bugs notification tool by yaroslav.lisovskyi

I update to Aspose.PSD 24.9 , now it can open the #1 psd, update text and save as jpg . but the rendering results are different with ps, can you have a check or is it something with Layer Style - PSD .net ?

@lsl at this moment Aspose.PSD doesn’t support Bevel & Emboss Effect.

The closest result to the PS rendering you can get with the following code:

        using (PsdImage psdImage = (PsdImage)Image.Load(srcFile, new PsdLoadOptions() { LoadEffectsResource = true}))
        {
            psdImage.Save(outFilePng, new PngOptions());
       }

1.jpg (53.2 KB)

@lsl
I added ticket(s) about Bevel&Emboss to this topic. They can be found in our internal issue tracking system and will be delivered according to the terms mentioned in Free Support Policies.

Issue ID(s): PSDNET-263,PSDNET-506

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.