[FIX] cm_odex_barcode: fix arabic
This commit is contained in:
parent
887fe8e267
commit
52bacf7986
|
|
@ -49,16 +49,17 @@ class Transaction(models.Model):
|
||||||
def draw_text(draw, text, y_position, font):
|
def draw_text(draw, text, y_position, font):
|
||||||
""" Draw centered Arabic text """
|
""" Draw centered Arabic text """
|
||||||
reshaped_text = arabic_reshaper.reshape(text) # Fix Arabic character joining
|
reshaped_text = arabic_reshaper.reshape(text) # Fix Arabic character joining
|
||||||
|
bidi_text = get_display(reshaped_text) # Fix right-to-left rendering
|
||||||
|
|
||||||
# Get text size
|
# Get text size
|
||||||
text_bbox = draw.textbbox((0, 0), reshaped_text, font=font)
|
text_bbox = draw.textbbox((0, 0), bidi_text, font=font)
|
||||||
text_width = text_bbox[2] - text_bbox[0]
|
text_width = text_bbox[2] - text_bbox[0]
|
||||||
|
|
||||||
# Calculate x position for centering
|
# Calculate x position for centering
|
||||||
x_position = (image_width - text_width) // 2
|
x_position = (image_width - text_width) // 2
|
||||||
|
|
||||||
# Draw text
|
# Draw text
|
||||||
draw.text((x_position, y_position), reshaped_text, "black", font=font)
|
draw.text((x_position, y_position), bidi_text, "black", font=font)
|
||||||
|
|
||||||
# Draw centered Arabic text
|
# Draw centered Arabic text
|
||||||
draw_text(draw, "رقم المعاملة : " + (self.name or ''), 20, font)
|
draw_text(draw, "رقم المعاملة : " + (self.name or ''), 20, font)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue