pango.Attribute — an attribute that applies to a section of text
class pango.Attribute: |
Functions |
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:
pango.ATTR_LANGUAGE | Specifies a pango.Language. |
pango.ATTR_FAMILY | Specifies a font family name list as a string. |
pango.ATTR_STYLE | Specifies a font slant style. See the pango.AttrStyle() function for more details. |
pango.ATTR_WEIGHT | Specifies a font weight. See the pango.AttrWeight() function for more detail. |
pango.ATTR_VARIANT | Specifies a font variant (normal or small caps). See the pango.AttrVariant() function for more detail. |
pango.ATTR_STRETCH | Specifies a font stretch. See the pango.AttrStretch() function for more details. |
pango.ATTR_SIZE | Specifies a font size in thousandths of a point. |
pango.ATTR_FONT_DESC | Specifies a pango.FontDescription. |
pango.ATTR_FOREGROUND | Specifies a foreground pango.Color. |
pango.ATTR_BACKGROUND | Specifies a background pango.Color. |
pango.ATTR_UNDERLINE | Specifies an underline style. See the pango.AttrUnderline() function for more details. |
pango.ATTR_STRIKETHROUGH | If TRUE the text is struck through. |
pango.ATTR_RISE | Specifies the displacement of the text from the baseline. |
pango.ATTR_SHAPE | Specifies a shape. See the pango.AttrShape() function for more details. |
pango.ATTR_SCALE | Specifies a font size scale factor. |
pango.ATTR_FALLBACK | if TRUE, fallback to other fonts is enabled. |
pango.ATTR_LETTER_SPACING | Specifies the extra space between graphemes. |
pango.ATTR_UNDERLINE_COLOR | Specifies the color of the underline. |
pango.ATTR_STRIKETHROUGH_COLOR | Specifies the color of the strikethrough. |
pango.ATTR_ABSOLUTE_SIZE | Specifies the font size in device units. |
Additional attribute types can be registered with the pango.attr_type_register() function.
|
Returns : | a new pango.Attribute object |
The copy() method returns a new pango.Attribute object that is a copy of this attribute.
|
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.
|
language : | a pango.Language object. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
family : | the string containing a font family name list. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
red : | the red component of the color in the range 0 to 65535. |
green : | the green component of the color in the range 0 to 65535. |
blue : | the blue component of the color in the range 0 to 65535. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
red : | the red component of the color in the range 0 to 65535. |
green : | the green component of the color in the range 0 to 65535. |
blue : | the blue component of the color in the range 0 to 65535. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
size : | the font size in thousandths of a point. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
style : | the font slant style. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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:
pango.STYLE_NORMAL | The font is upright. |
pango.STYLE_OBLIQUE | The font is slanted in a roman style. |
pango.STYLE_ITALIC | The font is slanted in an italic style. |
|
weight : | the font weight. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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:
pango.WEIGHT_ULTRALIGHT | The ultralight weight (= 200). |
pango.WEIGHT_LIGHT | The light weight (=300). |
pango.WEIGHT_NORMAL | The default weight (= 400). |
pango.WEIGHT_BOLD | The bold weight (= 700). |
pango.WEIGHT_ULTRABOLD | The ultrabold weight (= 800). |
pango.WEIGHT_HEAVY | The heavy weight (= 900). |
|
variant : | the font variant. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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:
pango.VARIANT_NORMAL | A normal font. |
pango.VARIANT_SMALL_CAPS | A font with the lower case characters replaced by smaller variants of the capital characters. |
|
stretch : | the font stretch style. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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:
pango.STRETCH_ULTRA_CONDENSED | The most narrow width |
pango.STRETCH_EXTRA_CONDENSED | |
pango.STRETCH_CONDENSED | |
pango.STRETCH_SEMI_CONDENSED | |
pango.STRETCH_NORMAL | The normal width. |
pango.STRETCH_SEMI_EXPANDED | |
pango.STRETCH_EXPANDED | |
pango.STRETCH_EXTRA_EXPANDED | |
pango.STRETCH_ULTRA_EXPANDED | The most expanded width |
|
desc : | a pango.FontDescription object. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
underline : | the underline style. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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:
pango.UNDERLINE_NONE | No underline should be drawn. |
pango.UNDERLINE_SINGLE | A single underline should be drawn. |
pango.UNDERLINE_DOUBLE | A double underline should be drawn. |
pango.UNDERLINE_LOW | 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. |
|
strikethrough : | if TRUE the text should be struck through. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
rise : | the displacement of the text from the baseline. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
ink_rect : | the ink rectangle of the shape. |
logical_rect : | the logical rectangle of the shape. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.
|
scale : | the font size scale factor as a float. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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:
pango.SCALE_XX_SMALL | 0.5787037037037 - the scale factor for three shrinking steps (1 / (1.2 * 1.2 * 1.2)). |
pango.SCALE_X_SMALL | 0.6444444444444 - the scale factor for two shrinking steps (1 / (1.2 * 1.2)). |
pango.SCALE_SMALL | 0.8333333333333 - the scale factor for one shrinking step (1 / 1.2). |
pango.SCALE_MEDIUM | 1.0 - The scale factor for normal size. |
pango.SCALE_LARGE | 1.2 - the scale factor for one magnification step. |
pango.SCALE_X_LARGE | 1.4399999999999 - the scale factor for two magnification steps (1.2 * 1.2). |
pango.SCALE_XX_LARGE | 1.728 - the scale factor for three magnification steps (1.2 * 1.2 * 1.2). |
|
fallback : | if TRUE, we should fall back on other fonts for characters the active font is missing. |
start_index : | the index of the start of the attribute application in the text. |
end_index : | 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.