Dont use -liga for font if no libraqm installed

This commit is contained in:
kijai 2024-01-13 19:24:14 +02:00
parent e1391ddf9f
commit d9594bd391

View File

@ -618,7 +618,10 @@ class CreateTextMask:
text_height = font_size
text_center_x = text_x + text_width / 2
text_center_y = text_y + text_height / 2
draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga'])
try:
draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga'])
except:
draw.text((text_x, text_y), text, font=font, fill=font_color)
if start_rotation != end_rotation:
image = image.rotate(rotation, center=(text_center_x, text_center_y))
rotation += rotation_increment
@ -1386,7 +1389,10 @@ class ImageBatchTestPattern:
text_x = (width - text_width / 2) // 2
text_y = (height - text_height) // 2
draw.text((text_x, text_y), str(number + start_from), font=font, fill=color, features=['-liga'])
try:
draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga'])
except:
draw.text((text_x, text_y), text, font=font, fill=font_color)
# Convert the image to a numpy array and normalize the pixel values
image = np.array(image).astype(np.float32) / 255.0
@ -2759,7 +2765,11 @@ class AddLabel:
label_image = Image.new("RGB", (width, height), label_color)
draw = ImageDraw.Draw(label_image)
font = ImageFont.truetype(font_path, font_size)
draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga'])
try:
draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga'])
except:
draw.text((text_x, text_y), text, font=font, fill=font_color)
label_image = np.array(label_image).astype(np.float32) / 255.0
label_image = torch.from_numpy(label_image)[None, :, :, :]
# Duplicate the label image for the entire batch