luxuriant777 / Handwritten-Text-Generator

This project offers a simple and intuitive interface for users to input text and generate images that showcase the text in a handwritten style. The generator supports several stylistic modifications including bold, underline, and color alterations, allowing users to create personalized and visually appealing images from their text.
GNU General Public License v3.0
2 stars 0 forks source link

no attribute "textsize" on imagedraw #2

Open xLz06 opened 10 months ago

xLz06 commented 10 months ago

hi, im succesfully run the code. but when im trying to export, there's error on line 106. this the error message;

line 106, in on_export_image char_width = temp_draw.textsize(char, font=font)[0] ^^^^^^^^^^^^^^^^^^ AttributeError: 'ImageDraw' object has no attribute 'textsize'.

and this is the code ;

 def on_export_image(self, event):
        lines = self.richTextCtrl.GetValue().split('\n')
        selected_font = self.font_choice.GetStringSelection()
        max_line_width = 0
        temp_image = Image.new("RGBA", (1, 1))
        temp_draw = ImageDraw.Draw(temp_image)

        for line_no, line in enumerate(lines):
            line_width = 0
            for char in line:
                font = ImageFont.truetype(f"./fonts/{selected_font}", self.font_size)
106--->   char_width = temp_draw.textsize(char, font=font)[0]
                line_width += char_width

i've already rewrite and trying fix the problem by changing the code, but the error still the same. maybe anyone or the developer it self can help. because this is for my class project. thanksss

luxuriant777 commented 10 months ago

Hello, this could be due to using an incorrect version of the Pillow library where the attribute might be different or deprecated.

Did you install this lib with the command?

pip install Pillow