font.rtl = True disturbs font.size in docx library

Viewed 65

i have this piece of code where i want to use font size 8 for a normal style paragraph and arabic text (where right to left and alignment right are important).

Once font.rtl = True, the style loses again the font.size that was assigned.

If font.rtl = False the font size comes out correct but the text is written in the wrong order

from docx import Document
from docx.shared import Pt
from docx.enum.text import WD_TAB_ALIGNMENT,WD_ALIGN_PARAGRAPH
style = 'Normal'
size = 8
text = " كلام عربي" 
doc = Document()
doc.styles[style].font.size = Pt(size)
**doc.styles[style].font.rtl = True**
p = doc.add_paragraph(text,style = style)
p.paragraph_format.alignment=WD_ALIGN_PARAGRAPH.RIGHT
doc.save("test.docx")

output in the word is كلام عربي if font.rtl = True but with font size = 11

and it is wrong ordered like عربي كلام if font.rtl = False but with the right font size (8)

Any clue?

0 Answers
Related