'How to fit text to the full size of a rectangle?

My image

enter image description here

I want

enter image description here

I need the text to be the full size of the rectangle

for i, el in enumerate(data.splitlines()):
if i == 0:
    continue
el = el.split()
try:
    x, y, w, h = int(el[6]), int(el[7]), int(el[8]), int(el[9])
    if len(el) > 11:
        a = cv2.rectangle(img, (x, y), (w + x, h + y), (190, 190, 190), -1)
    #a = cv2.rectangle(img, (x,y), (w + x, h + y), (0, 0, 255), 2)
    font = cv2.FONT_HERSHEY_COMPLEX

    text = el[11]
    cv2.putText(img, translation.text, (x, y+30), font, 1, (0,0,0), 3)
    cv2.putText(img, translation.text, (x, y+30), font, 1, (255, 255, 255), 2)
except IndexError:
    continue


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source