While complete access to the layout capabilities of Pango is provided
using the detailed interfaces for itemization and shaping, using
that functionality directly involves writing a fairly large amount
of code. pango.layout.Layout provides a high-level driver for formatting
entire paragraphs of text at once. This includes paragraph-level
functionality such as line breaking, justification, alignment and
ellipsization.
A pango.layout.Layout is initialized with a pango.context.Context, UTF-8 string
and set of attributes for that string. Once that is done, the set of
formatted lines can be extracted from the object, the layout can be
rendered, and conversion between logical character positions within
the layout's text, and the physical position of the resulting glyphs
can be made.
There are a number of parameters to adjust the formatting of a
pango.layout.Layout. The following image shows adjustable parameters
(on the left) and font metrics (on the right):
A pango.layout.Layout structure represents an entire paragraph of text.
While complete access to the layout capabilities of Pango is provided using the detailed interfaces for itemization and shaping, using that functionality directly involves writing a fairly large amount of code. pango.layout.Layout provides a high-level driver for formatting entire paragraphs of text at once. This includes paragraph-level functionality such as line breaking, justification, alignment and ellipsization.
A pango.layout.Layout is initialized with a pango.context.Context, UTF-8 string and set of attributes for that string. Once that is done, the set of formatted lines can be extracted from the object, the layout can be rendered, and conversion between logical character positions within the layout's text, and the physical position of the resulting glyphs can be made.
There are a number of parameters to adjust the formatting of a pango.layout.Layout. The following image shows adjustable parameters (on the left) and font metrics (on the right):
<picture> <source srcset="layout-dark.png" media="(prefers-color-scheme: dark)"> <img alt="Pango Layout Parameters" src="layout-light.png"> </picture>
The following images demonstrate the effect of alignment and justification on the layout of text:
| | | | --- | --- | |
|
|
|
|
|
|
|
|