Change Font and Color for TextLayer PSD

The issues you have found earlier (filed as PSDNET-806) have been fixed in this update.

Hi @mudassir.fayyaz and @aspose.notifier,

 ITextPortion firstPortion = textLayer.TextData.Items[0];
                firstPortion.Style.FontName = FontSettings.GetAdobeFontName("Lobster");

FontSettings.GetAdobeFontName(“Lobster”) is always return null although I have install this font to “C:\Windows\Fonts”.

Lobster (1).zip (143.4 KB)

Please help me to check.

Thanks,
Duy

@nlduy157

For sake of your reference, you can please try using following complete example.

            string outputFilePng = "result_fontEditTest.png";
            string outputFilePsd = "fontEditTest.psd";

            void AssertAreEqual(object expected, object actual)
            {
                if (!object.Equals(expected, actual))
                {
                    throw new Exception("Objects are not equal.");
                }
            }

            using (var image = new PsdImage(500, 500))
            {
                FillLayer backgroundFillLayer = FillLayer.CreateInstance(FillType.Color);
                ((IColorFillSettings)backgroundFillLayer.FillSettings).Color = Color.White;
                image.AddLayer(backgroundFillLayer);

                TextLayer textLayer = image.AddTextLayer("Text 1", new Rectangle(10, 35, image.Width, 35));

                ITextPortion firstPortion = textLayer.TextData.Items[0];
                firstPortion.Style.FontName = FontSettings.GetAdobeFontName("Comic Sans MS");

                var secondPortion = textLayer.TextData.ProducePortion();
                secondPortion.Text = "Text 2";
                secondPortion.Paragraph.Apply(firstPortion.Paragraph);
                secondPortion.Style.Apply(firstPortion.Style);
                secondPortion.Style.FontName = FontSettings.GetAdobeFontName("Arial");

                textLayer.TextData.AddPortion(secondPortion);
                textLayer.TextData.UpdateLayerData();

                image.Save(outputFilePng, new PngOptions());
                image.Save(outputFilePsd);
            }

            using (var image = (PsdImage)Image.Load(outputFilePsd))
            {
                TextLayer textLayer = (TextLayer)image.Layers[2];

                string adobeFontName1 = FontSettings.GetAdobeFontName("Comic Sans MS");
                string adobeFontName2 = FontSettings.GetAdobeFontName("Arial");

                AssertAreEqual(adobeFontName1, textLayer.TextData.Items[0].Style.FontName);
                AssertAreEqual(adobeFontName2, textLayer.TextData.Items[1].Style.FontName);
            }

Can you please share the source font and used working example so that we may try to verify the same on our end.

Hi @mudassir.fayyaz
When I update text layer to new Font , I have problem with some fonts.
Font Errors : Mrs Saint Delafield, Mr De Haviland, Allura, Great Vibes, Kaushan Script , Parisienne, Patua One, Playball, Yellowtail, Lobster, Vidaloka.
I have downloaded fonts and installed it to my local
Font.7z (387.4 KB)

  • I also attached 11 images for 11 fonts:
    example Allura.jpg (191.0 KB)
  • Problems : Fonts after rendering by aspose have the isse with charactor : L , ‘,’ or not space between character in text. Please see image as attached above :
    Font error.7z (1.7 MB)
  • This is my code that I implement to change font ( update lasted version )
    ChangeFontTextLayer.7z (7.3 MB)

Please help me to take a look as a high priority.

Thanks,
Duy

@nlduy157

This issue require further investigation and a ticket with ID PSDNET-948 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

Hi @mudassir.fayyaz,

Can you share with me ETA for issue PSDNET-948 ?

Thanks,
Duy

@nlduy157

This issue has just been created and is pending for investigation in issues queue. We will share the good news with you as soon as the issue will be addressed.

Hi @mudassir.fayyaz,
Great, I hope can get your good news soon !

Thanks,
Duy

@nlduy157

We will keep you posted for updates as soon as they will be shared.

Hi @mudassir.fayyaz,

Can I get any update ?

Thanks,
Duy

@nlduy157

I regret to share that at present the issue is still unresolved. We request for your patience and will share the good news with you as soon as it will be fixed.

Hi @mudassir.fayyaz,
I hope you are well !.

I can see status ticket PSDNET-948 has been resolved. Could you please share with me when I can get new release version? I really need your update to fix my issues.

Thanks,
Duy

@nlduy157

Can you please try using the following sample code using the latest version of Aspose.PSD for .NET.

string sourceFileName = "fontExamples948.psd";
            string testFontsFoler = "Fonts";
            string outputPng = "output.png";

            FontSettings.SetFontsFolder(testFontsFoler);

            using (PsdImage image = (PsdImage)Aspose.PSD.Image.Load(sourceFileName))
            {
                foreach (var layer in image.Layers)
                {
                    var textLayer = layer as TextLayer;
                    if (textLayer != null)
                    {
                        ITextPortion textPortion = textLayer.TextData.Items[0];
                        textPortion.Style.FillColor = Color.BlueViolet;

                        textLayer.TextData.UpdateLayerData();
                    }
                }

                image.Save(outputPng, new PngOptions());
            }

Hi @mudassir.fayyaz

How to detect the text in TextLayer is vertical ?

image.png (22.9 KB)

@nlduy157

We need to verify this on our end. If I am right, you want to check if the text inside TexLayer is rotated or want to set rotation.

@mudassir.fayyaz,

I want to check the Text in textlayer is rotated.
How can I detected by code ?

@nlduy157

I regret to share that the requested feature is unavailable in API at the moment. A ticket with ID PSDNET-1014 has been created in our issue tracking system to provide the requested support. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

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

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