pango.Attribute — an attribute that applies to a section of text
class pango.Attribute: |
Functionsdef pango.attr_type_register(name)def pango.AttrLanguage(language,start_index=0,end_index=1)def pango.AttrFamily(family,start_index=0,end_index=1)def pango.AttrForeground(red,green,blue,start_index=0,end_index=1)def pango.AttrBackground(red,green,blue,start_index=0,end_index=1)def pango.AttrSize(size,start_index=0,end_index=1)def pango.AttrStyle(style,start_index=0,end_index=1)def pango.AttrWeight(weight,start_index=0,end_index=1)def pango.AttrVariant(variant,start_index=0,end_index=1)def pango.AttrStretch(stretch,start_index=0,end_index=1)def pango.AttrFontDesc(desc,start_index=0,end_index=1)def pango.AttrUnderline(underline,start_index=0,end_index=1)def pango.AttrStrikethrough(strikethrough,start_index=0,end_index=1)def pango.AttrRise(rise,start_index=0,end_index=1)def pango.AttrShape(ink_rect,logical_rect,start_index=0,end_index=1)def pango.AttrScale(scale,start_index=0,end_index=1)def pango.AttrFallback(fallback,start_index=0,end_index=1)def pango.AttrSizeAbsolute(size,start_index=0,end_index=1)def pango.AttrUnderlineColor(red,green,blue,start_index=0,end_index=1)def pango.AttrStrikethroughColor(red,green,blue,start_index=0,end_index=1)def pango.AttrLetterSpacing(letter_spacing,start_index=0,end_index=1)
All pango.Attribute
objects support the following three attributes.
|
In addition each pango.Attribute
type supports one or more additional attributes that are specific to the
type:
|
The pango.Attribute
object contains an attribute that applies to a section of text. The
predefined attribute types are:
| Specifies a pango.Language. |
| Specifies a font family name list as a string. |
| Specifies a font slant style. See the pango.AttrStyle()
function for more details. |
| Specifies a font weight. See the pango.AttrWeight()
function for more detail. |
| Specifies a font variant (normal or small caps). See the
pango.AttrVariant()
function for more detail. |
| Specifies a font stretch. See the pango.AttrStretch()
function for more details. |
| Specifies a font size in thousandths of a point. |
| Specifies a pango.FontDescription. |
| Specifies a foreground pango.Color. |
| Specifies a background pango.Color. |
| Specifies an underline style. See the pango.AttrUnderline()
function for more details. |
| If True the text is struck
through. |
| Specifies the displacement of the text from the baseline. |
| Specifies a shape. See the pango.AttrShape()
function for more details. |
| Specifies a font size scale factor. |
| if True, fallback to other fonts is
enabled. |
| Specifies the extra space between graphemes. |
| Specifies the color of the underline. |
| Specifies the color of the strikethrough. |
| Specifies the font size in device units. |
Additional attribute types can be registered with the pango.attr_type_register()
function.
def copy()Returns : | a new pango.Attribute
object |
The copy() method returns a new pango.Attribute
object that is a copy of this attribute.
def pango.attr_type_register(name)
| a name for the type. (Currently not used.) |
Returns : | the new attribute type ID integer. |
The attr_type_register() function returns a
new attribute type ID integer value.
def pango.AttrLanguage(language, start_index=0, end_index=1)
| a pango.Language
object. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object. |
The AttrLanguage() function creates a new
pango.Attribute
object of the type pango.ATTR_LANGUAGE with the pango.Language
specified by language and the text range specified by
start_index and
end_index.
def pango.AttrFamily(family, start_index=0, end_index=1)
| the string containing a font family name list. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object. |
The AttrFamily() function creates a new
pango.Attribute
object of the type pango.ATTR_FAMILY with the font family
name list specified by the string family and the text
range specified by start_index and
end_index.
def pango.AttrForeground(red, green, blue, start_index=0, end_index=1)
| the red component of the color in the range 0 to 65535. |
| the green component of the color in the range 0 to 65535. |
| the blue component of the color in the range 0 to 65535. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object. |
The AttrForeground() function creates a new
pango.Attribute
of the type pango.ATTR_FOREGROUND with the RGB color
specified by red, green and
blue and the text range specified by
start_index and
end_index.
def pango.AttrBackground(red, green, blue, start_index=0, end_index=1)
| the red component of the color in the range 0 to 65535. |
| the green component of the color in the range 0 to 65535. |
| the blue component of the color in the range 0 to 65535. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object. |
The AttrBackground() function creates a new
pangoAttribute of the type pango.ATTR_BACKGROUND with the
RGB color specified by red,
green and blue and the text
range specified by start_index and
end_index.
def pango.AttrSize(size, start_index=0, end_index=1)
| the font size in thousandths of a point. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrSize() function creates a new pango.Attribute
object of the type pango.ATTR_SIZE with the font size
specified by size and the text range specified by
start_index and
end_index.
def pango.AttrStyle(style, start_index=0, end_index=1)
| the font slant style. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrStyle() function creates a new
pango.Attribute
object of the type pango.ATTR_STYLE with the font slant
style specified by style and the text range specified
by start_index and end_index.
The value of style must be one of:
| The font is upright. |
| The font is slanted in a roman style. |
| The font is slanted in an italic style. |
def pango.AttrWeight(weight, start_index=0, end_index=1)
| the font weight. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrWeight() function creates a new
pango.Attribute
object of the type pango.ATTR_WEIGHT with the font weight
specified by weight and the text range specified by
start_index and end_index. The
value of style must be one of:
| The ultralight weight (= 200). |
| The light weight (=300). |
| The default weight (= 400). |
| The bold weight (= 700). |
| The ultrabold weight (= 800). |
| The heavy weight (= 900). |
def pango.AttrVariant(variant, start_index=0, end_index=1)
| the font variant. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrVariant() function creates a new
pango.Attribute
object of the type pango.ATTR_VARIANT with the font
variant specified by variant and the text range
specified by start_index and
end_index. The value of
variant must be one of:
| A normal font. |
| A font with the lower case characters replaced by smaller variants of the capital characters. |
def pango.AttrStretch(stretch, start_index=0, end_index=1)
| the font stretch style. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrStretch() function creates a new
pango.Attribute
object of the type pango.ATTR_STRETCH with the font
stretch style specified by stretch and the text range
specified by start_index and
end_index. The value of
stretch must be one of:
| The most narrow width |
| |
| |
| |
| The normal width. |
| |
| |
| |
| The most expanded width |
def pango.AttrFontDesc(desc, start_index=0, end_index=1)
| a pango.FontDescription
object. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrFontDesc() function creates a new
pango.Attribute
object of the type pango.ATTR_FONT_DESC with the pango.FontDescription
specified by desc and the text range specified by
start_index and
end_index.
def pango.AttrUnderline(underline, start_index=0, end_index=1)
| the underline style. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrUnderline() function creates a new
pango.Attribute
object of the type pango.ATTR_UNDERLINE with the
underline style specified by underline and the text
range specified by start_index and
end_index. The value of
underline must be one of:
| No underline should be drawn. |
| A single underline should be drawn. |
| A double underline should be drawn. |
| A single underline should be drawn at a position
beneath the ink extents of the text being underlined. This should be used
only for underlining single characters, such as for keyboard accelerators.
pango.UNDERLINE_SINGLE should be used for extended
portions of text. |
def pango.AttrStrikethrough(strikethrough, start_index=0, end_index=1)
| if True the text should be
struck through. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrStrikethrough() function creates a
new pango.Attribute
object of the type pango.ATTR_STRIKETHROUGH with the
value specified by strikethrough and the text range
specified by start_index and
end_index. If strikethough is True
the text should be struck through.
def pango.AttrRise(rise, start_index=0, end_index=1)
| the displacement of the text from the baseline. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrRise() function creates a new pango.Attribute
object of the type pango.ATTR_RISE with the text
displacement from the baseline specified by rise and
the text range specified by start_index and
end_index.
def pango.AttrShape(ink_rect, logical_rect, start_index=0, end_index=1)
| the ink rectangle of the shape. |
| the logical rectangle of the shape. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrShape() function creates a new
pango.Attribute
object of the type pango.ATTR_SHAPE with the shape
rectangles specified by ink_rect and
logical_rect and the text range specified by
start_index and end_index. A
shape is used to impose a particular ink and logical rect on the result of
shaping a particular glyph. This might be used, for instance, for embedding
a picture or a widget inside a pango.Layout.
def pango.AttrScale(scale, start_index=0, end_index=1)
| the font size scale factor as a float. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
The AttrScale() function creates a new
pango.Attribute
object of the type pango.ATTR_SCALE with the font size
scale factor specified by scale and the text range
specified by start_index and
end_index. The value of scale
can also be one of the following pre-defined values:
| 0.5787037037037 - the scale factor for three shrinking steps (1 / (1.2 * 1.2 * 1.2)). |
| 0.6444444444444 - the scale factor for two shrinking steps (1 / (1.2 * 1.2)). |
| 0.8333333333333 - the scale factor for one shrinking step (1 / 1.2). |
| 1.0 - The scale factor for normal size. |
| 1.2 - the scale factor for one magnification step. |
| 1.4399999999999 - the scale factor for two magnification steps (1.2 * 1.2). |
| 1.728 - the scale factor for three magnification steps (1.2 * 1.2 * 1.2). |
def pango.AttrFallback(fallback, start_index=0, end_index=1)
| if True, we should fall back
on other fonts for characters the active font is
missing. |
| the index of the start of the attribute application in the text. |
| the index of the end of the attribute application in the text. |
Returns : | a new pango.Attribute
object |
This function is available in PyGTK 2.4 and above.
The AttrFallback() function creates a new
pango.Attribute
object of the type pango.ATTR_FALLBACK. If fallback is
True other fonts on the system can be used to provide
characters missing from the current font. Otherwise, only characters from
the closest matching font can be used.