简体   繁体   中英

pycairo: justify text-align

I use python bindings to Cairo to render text.

My question is: Is it possible to render a string using something like text-align: justify ? Suppose I have fixed width and I want to print a paragraph.

Solved [using pangocairo]:

import pygtk
import cairo
import pango
import pangocairo
...
layout = pangocairo_context.create_layout()
...
layout.set_width(...)
layout.set_wrap(pango.WRAP_WORD)
layout.set_justify(True)
layout.set_text(text)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM