pango.Attribute

pango.Attribute — an attribute that applies to a section of text

Synopsis

class pango.Attribute:
    def copy()
Functions

    def 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)

Attributes

All pango.Attribute objects support the following three attributes.

"end_index"Read-WriteThe index of the end of the application of the attribute in the associated text.
"start_index"Read-WriteThe index of the start of the application of the attribute in the associated text.
"type"ReadThe attribute type.

In addition each pango.Attribute type supports one or more additional attributes that are specific to the type:

"value"Read   ATTR_LANGUAGEThe pango.Language.
"value"ReadATTR_FAMILYThe string containing the font family name list (e.g. "normal,sans,serif,monospace")
"value"ReadATTR_STYLEThe font slant style. See the pango.AttrStyle() function for more details.
"value"ReadATTR_WEIGHTThe font weight. See the pango.AttrWeight() function for more detail.
"value"ReadATTR_VARIANTThe font variant. See the pango.AttrVariant() function for more detail.
"value"ReadATTR_STRETCHThe font stretch. See the pango.AttrStretch() function for more details.
"value"ReadATTR_SIZEThe font size in thousandths of a point.
"desc"ReadATTR_FONT_DESCThe pango.FontDescription object.
"color"ReadATTR_FOREGROUNDThe foreground pango.Color object.
"color"ReadATTR_BACKGROUNDThe background pango.Color object.
"value"ReadATTR_UNDERLINEThe underline style. See the pango.AttrUnderline() function for more details.
"value"ReadATTR_STRIKETHROUGHTRUE if the text is struck through.
"value"ReadATTR_RISEThe displacement of the text from the baseline.
"ink_rect"ReadATTR_SHAPEThe 4-tuple specifying the ink rectangle. See the pango.AttrShape() function for more details.
"logical_rect"ReadATTR_SHAPEThe 4-tuple specifying the logical rectangle. See the pango.AttrShape() function for more details.
"value"ReadATTR_SCALEThe font size scale factor as a float.
"value"ReadATTR_FALLBACKTRUE if font fallback is enabled.
"value"ReadATTR_LETTER_SPACINGThe extra space between graphemes.
"color"ReadATTR_UNDERLINE_COLORThe pango.Color object used for the color of the underline.
"color"ReadATTR_STRIKETHROUGH_COLORThe pango.Color object used for the color of the strikethrough.
"value"ReadATTR_ABSOLUTE_SIZEThe font size in device units.

Description

The pango.Attribute object contains an attribute that applies to a section of text. The predefined attribute types are:

pango.ATTR_LANGUAGESpecifies a pango.Language.
pango.ATTR_FAMILYSpecifies a font family name list as a string.
pango.ATTR_STYLESpecifies a font slant style. See the pango.AttrStyle() function for more details.
pango.ATTR_WEIGHTSpecifies a font weight. See the pango.AttrWeight() function for more detail.
pango.ATTR_VARIANTSpecifies a font variant (normal or small caps). See the pango.AttrVariant() function for more detail.
pango.ATTR_STRETCHSpecifies a font stretch. See the pango.AttrStretch() function for more details.
pango.ATTR_SIZESpecifies a font size in thousandths of a point.
pango.ATTR_FONT_DESCSpecifies a pango.FontDescription.
pango.ATTR_FOREGROUNDSpecifies a foreground pango.Color.
pango.ATTR_BACKGROUNDSpecifies a background pango.Color.
pango.ATTR_UNDERLINESpecifies an underline style. See the pango.AttrUnderline() function for more details.
pango.ATTR_STRIKETHROUGHIf TRUE the text is struck through.
pango.ATTR_RISESpecifies the displacement of the text from the baseline.
pango.ATTR_SHAPESpecifies a shape. See the pango.AttrShape() function for more details.
pango.ATTR_SCALESpecifies a font size scale factor.
pango.ATTR_FALLBACKif TRUE, fallback to other fonts is enabled.
pango.ATTR_LETTER_SPACINGSpecifies the extra space between graphemes.
pango.ATTR_UNDERLINE_COLORSpecifies the color of the underline.
pango.ATTR_STRIKETHROUGH_COLORSpecifies the color of the strikethrough.
pango.ATTR_ABSOLUTE_SIZESpecifies the font size in device units.

Additional attribute types can be registered with the pango.attr_type_register() function.

Methods

pango.Attribute.copy

    def copy()
Returns :a new pango.Attribute object

The copy() method returns a new pango.Attribute object that is a copy of this attribute.

Functions

pango.attr_type_register

    def pango.attr_type_register(name)
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.

pango.AttrLanguage

    def pango.AttrLanguage(language, start_index=0, end_index=1)
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.

pango.AttrFamily

    def pango.AttrFamily(family, start_index=0, end_index=1)
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.

pango.AttrForeground

    def pango.AttrForeground(red, green, blue, start_index=0, end_index=1)
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.

pango.AttrBackground

    def pango.AttrBackground(red, green, blue, start_index=0, end_index=1)
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.

pango.AttrSize

    def pango.AttrSize(size, start_index=0, end_index=1)
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.

pango.AttrStyle

    def pango.AttrStyle(style, start_index=0, end_index=1)
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_NORMALThe font is upright.
pango.STYLE_OBLIQUEThe font is slanted in a roman style.
pango.STYLE_ITALICThe font is slanted in an italic style.

pango.AttrWeight

    def pango.AttrWeight(weight, start_index=0, end_index=1)
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_ULTRALIGHTThe ultralight weight (= 200).
pango.WEIGHT_LIGHTThe light weight (=300).
pango.WEIGHT_NORMALThe default weight (= 400).
pango.WEIGHT_BOLDThe bold weight (= 700).
pango.WEIGHT_ULTRABOLDThe ultrabold weight (= 800).
pango.WEIGHT_HEAVYThe heavy weight (= 900).

pango.AttrVariant

    def pango.AttrVariant(variant, start_index=0, end_index=1)
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_NORMALA normal font.
pango.VARIANT_SMALL_CAPSA font with the lower case characters replaced by smaller variants of the capital characters.

pango.AttrStretch

    def pango.AttrStretch(stretch, start_index=0, end_index=1)
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_CONDENSEDThe most narrow width
pango.STRETCH_EXTRA_CONDENSED
pango.STRETCH_CONDENSED
pango.STRETCH_SEMI_CONDENSED
pango.STRETCH_NORMALThe normal width.
pango.STRETCH_SEMI_EXPANDED
pango.STRETCH_EXPANDED
pango.STRETCH_EXTRA_EXPANDED
pango.STRETCH_ULTRA_EXPANDEDThe most expanded width

pango.AttrFontDesc

    def pango.AttrFontDesc(desc, start_index=0, end_index=1)
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.

pango.AttrUnderline

    def pango.AttrUnderline(underline, start_index=0, end_index=1)
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_NONENo underline should be drawn.
pango.UNDERLINE_SINGLEA single underline should be drawn.
pango.UNDERLINE_DOUBLEA double underline should be drawn.
pango.UNDERLINE_LOWA 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.

pango.AttrStrikethrough

    def pango.AttrStrikethrough(strikethrough, start_index=0, end_index=1)
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.

pango.AttrRise

    def pango.AttrRise(rise, start_index=0, end_index=1)
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.

pango.AttrShape

    def pango.AttrShape(ink_rect, logical_rect, start_index=0, end_index=1)
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.

pango.AttrScale

    def pango.AttrScale(scale, start_index=0, end_index=1)
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_SMALL0.5787037037037 - the scale factor for three shrinking steps (1 / (1.2 * 1.2 * 1.2)).
pango.SCALE_X_SMALL0.6444444444444 - the scale factor for two shrinking steps (1 / (1.2 * 1.2)).
pango.SCALE_SMALL0.8333333333333 - the scale factor for one shrinking step (1 / 1.2).
pango.SCALE_MEDIUM1.0 - The scale factor for normal size.
pango.SCALE_LARGE1.2 - the scale factor for one magnification step.
pango.SCALE_X_LARGE1.4399999999999 - the scale factor for two magnification steps (1.2 * 1.2).
pango.SCALE_XX_LARGE1.728 - the scale factor for three magnification steps (1.2 * 1.2 * 1.2).

pango.AttrFallback

    def pango.AttrFallback(fallback, start_index=0, end_index=1)
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

Note

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.