We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Change Font and Color for TextLayer PSD

Hi team ,

I want to change current TextLayer to new Font and Color but I don’t know how to do it. Could you please give me advise.

Thanks,
Duy

Ask.jpg (460.3 KB)

@nlduy157

I suggest you to please visit following thread link to see more about updating text layer.

Hi @mudassir.fayyaz,

Thanks for your reply.
Of course, I read the thread link as you shared before creating new thread to ask about my problem.
Thread link : Problem update Text Layer just answered how to replace new text but It cannot change new font for text. Please help me check again.

Thanks,
Duy

@nlduy157

A ticket with ID PSDNET-806 has already been added to provide the support for updating TextLayer portion font. I have associated this thread with the issue so that you may be notified once the issue will be fixed. For the time being, you can consider option of adding TextLayer that has provision of setting font.

//Creates an instance of Image
using (Aspose.PSD.Image image = new Aspose.PSD.FileFormats.Psd.PsdImage(500, 500))
{
    //Creates and initialize an instance of Graphics class
    Aspose.PSD.Graphics graphics = new Aspose.PSD.Graphics(image);

    //Clears Graphics surface
    graphics.Clear(Color.Wheat);

    //Creates an instance of Font
    Aspose.PSD.Font font = new Aspose.PSD.Font("Times New Roman", 16);

    //Create an instance of SolidBrush having Red Color
    Aspose.PSD.Brushes.SolidBrush brush = new Aspose.PSD.Brushes.SolidBrush(Color.Red);

    //Draw a String
    graphics.DrawString("Created by Aspose.PSD for .Net", font, brush, new PointF(100, 100));

    // create export options.
    Aspose.PSD.ImageOptions.GifOptions options = new Aspose.PSD.ImageOptions.GifOptions();

    // save all changes
    image.Save("C:\\temp\\output.gif", options);
}

Hi @mudassir.fayyaz,

Thanks for your reply.

I Just want to change the Font in properties TextLayer :
Current Method :
textLayer.UpdateText(“test update”, new Point(0, 0), 15.0f, Color.Purple);

As code above just only help me to Replace the Text and Color but It can’t apply for New Font.
I can’t use Graphic to add new Layer as your code propose because It will be generated new Layer as Image, not TextLayer as I expected.

Thanks,
Duy

@nlduy157

As I have shared with you that the support for updating the font is currently unavailable and concerned ticket is attached with this thread. We will share notification with you once the support will be included.

Hi @mudassir.fayyaz,

I use graphics based on Layer existing ("layer2) in PSD to rawstring with new font as below :

var newFont = new Aspose.Preformatted textPSD.Font("Fugaz One", layerToUpdateText.Font.Size, fontInfor.Style);
graphic.BeginUpdate();

            var brush = new Aspose.PSD.Brushes.SolidBrush();
                    brush.Color = Aspose.PSD.Color.Red;
                                            

                    graphic.DrawString(layerCustom.Value, newFont, brush, new RectangleF(0,0,layerToUpdateText.Width ,layerToUpdateText.Height));
                    graphic.EndUpdate();

The text in Image (layer 1) after the rendering has font size is smaller than Layer 2. I have attached the PSD file and image to explain what is layer 1 and Layer 2.

issue.7z (1.9 MB)

Could you please help me to check ?

Thanks,
Duy

@nlduy157

As I have shared with you earlier that at present the support for updating the font for text layer is not available in API and a ticket with ID PSDNET-806 has been created to provide the support. For using Graphics class option, have you tried using the sample code shared by me earlier. You are trying to update graphics.

Hi @mudassir.fayyaz,

Because I can’t change font so I create graphics with purpose I want to create new text that have the same font size text original with a new font.
Currently, Graphics can create new text with new font that I expected but The Font size created by graphics have smaller than textlayer original. Please open psd file and compare between layer 1 and layer 2 in file attached ( issue.7z that I send you in reply before.

Thanks,
Duy

@nlduy157

Can you please provide a working sample code rather than part of it as I am unable to use your code for having custom declarations. I have tried to use following code but it doesn’t see to work as per you have described. Therefore, please share a working sample code that I may test to help you further.

    public static void TestPSDFont()
    {
        String path = @"/Users/mudassirkhan/Downloads/issue/";
        //Creates an instance of Image
//        using (Aspose.PSD.Image image = new Aspose.PSD.FileFormats.Psd.PsdImage(500, 500))
        using (Aspose.PSD.Image image = Image.Load(path+ "M1PDTT26052021001.psd"))
        {
            //Creates and initialize an instance of Graphics class
            Aspose.PSD.Graphics graphics = new Aspose.PSD.Graphics(image);

            //Clears Graphics surface
            graphics.Clear(Color.Wheat);

            //Creates an instance of Font
            Aspose.PSD.Font font = new Aspose.PSD.Font("Times New Roman", 25);

         //   var newFont = new Aspose.PSD.Font("Fugaz One", 16,FontStyle.Bold);

            //Create an instance of SolidBrush having Red Color
            Aspose.PSD.Brushes.SolidBrush brush = new Aspose.PSD.Brushes.SolidBrush(Color.Red);


            //Draw a String
            graphics.DrawString("MODESTO SR", font, brush, new PointF(100, 100));

            // create export options.
            Aspose.PSD.ImageOptions.GifOptions options = new Aspose.PSD.ImageOptions.GifOptions();

            // save all changes
            image.Save(path+"output.psd", options);
        }
    }

Hi @mudassir.fayyaz,

I have made simple code and short clip to explain what I want to do. Please help me to see it in link attach file and check the issue.
Please down load zip file in link and check code + video

Thanks,
Duy

@nlduy157

Thank you for elaborating the requirements. We need to investigate this further on our en and a ticket with ID PSDNET-912 has been created in our issue tracking system to further investigate this on our end. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

Hi @mudassir.fayyaz,

Thanks. I hope I can receive your answer soon!

Thanks,
Duy

@nlduy157

We will appreciate your patience and will share the feedback with you as soon as it will be addressed.

Hi @mudassir.fayyaz,

I also have the new problem when I saved psd file.
I use the code that project attached in the drive link in reply before .
I have attached 2 file original and file generated that to you easy to compare.
The issue is very important. If basic code just open psd and and save new psd , that issue is still happening.
File Error ( generated ) .jpg (493.0 KB)
Original file.jpg (495.6 KB)

problem.7z (2.1 MB)

Thanks,
Duy

@nlduy157

Can you please share the used sample code that I may used to verify and log the issue.

Hi @mudassir.fayyaz,

I use the simple code in google drive link : https://drive.google.com/file/d/1LUdSyyM9yaCZLKnuM6_r15UxvukvQIMl/view

I think the root cause may be nugget is missing Font.

Thanks,
Duy

@nlduy157

I have created a ticket with ID PSDNET-913 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 fixed.

Hi @mudassir.fayyaz,

Could you please share with me any update ticket PSDNET-912 ? It very Urgent to me

Thanks,
Duy

@nlduy157

I regret to share that at present there are no updated. However, we request for your patience and will share feedback with you as soon as possible.