diff --git a/phlogo/__init__.py b/phlogo/__init__.py index d0b52e0..b98149d 100644 --- a/phlogo/__init__.py +++ b/phlogo/__init__.py @@ -18,16 +18,18 @@ def gabung(arg): im,text1=add_corners(arg[0], 17),arg[1] op=Image.new("RGB",(40,20),color=(0,0,0)) draw=ImageDraw.Draw(op) - size=font.getsize(text1) - baru=Image.new("RGB",(im.width+size[0]+210+20+130,600), color=(0,0,0)) + size=round(font.getlength(text1)) + baru=Image.new("RGB",(im.width+size+210+20+130,600), color=(0,0,0)) draw=ImageDraw.Draw(baru) draw.text((150,250), text1,(255,255,255),font=font) - baru.paste(im, (150+size[0]+20,230+10), im.convert("RGBA")) + baru.paste(im, (150+size+20,230+10), im.convert("RGBA")) return baru return gabung(fun) def generate(text1, text2): - panjangText=font.getsize(text2) - oren=Image.new("RGBA",(panjangText[0]+20,140),color=(240, 152, 0)) + panjangTextBbox=font.getbbox(text2) + panjangTextLength=round(font.getlength(text2)) + panjangTextHeight=(round(panjangTextBbox[3])+10)-round(panjangTextBbox[1]) + oren=Image.new("RGBA",(panjangTextLength+20,140),color=(240, 152, 0)) draw=ImageDraw.Draw(oren) - draw.text((10,int((oren.height-panjangText[1])/2)-10),text2, (0,0,0),font=font) - return Gabung([oren, text1]) \ No newline at end of file + draw.text((10,int((oren.height-panjangTextHeight)/2)-10),text2, (0,0,0),font=font) + return Gabung([oren, text1])