pango.Attributean attribute that applies to a section of textSynopsispango.AttributecopyFunctionspango.attr_type_registernamepango.AttrLanguagelanguagestart_index0end_index1pango.AttrFamilyfamilystart_index0end_index1pango.AttrForegroundredgreenbluestart_index0end_index1pango.AttrBackgroundredgreenbluestart_index0end_index1pango.AttrSizesizestart_index0end_index1pango.AttrStylestylestart_index0end_index1pango.AttrWeightweightstart_index0end_index1pango.AttrVariantvariantstart_index0end_index1pango.AttrStretchstretchstart_index0end_index1pango.AttrFontDescdescstart_index0end_index1pango.AttrUnderlineunderlinestart_index0end_index1pango.AttrStrikethroughstrikethroughstart_index0end_index1pango.AttrRiserisestart_index0end_index1pango.AttrShapeink_rectlogical_rectstart_index0end_index1pango.AttrScalescalestart_index0end_index1pango.AttrFallbackfallbackstart_index0end_index1pango.AttrSizeAbsolutesizestart_index0end_index1pango.AttrUnderlineColorredgreenbluestart_index0end_index1pango.AttrStrikethroughColorredgreenbluestart_index0end_index1pango.AttrLetterSpacingletter_spacingstart_index0end_index1AttributesAll 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.
DescriptionThe 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.Methodspango.Attribute.copycopyReturns :a new pango.Attribute
objectThe copy() method returns a new pango.Attribute
object that is a copy of this attribute.Functionspango.attr_type_registerpango.attr_type_registernamename :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.AttrLanguagepango.AttrLanguagelanguagestart_index0end_index1language :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.AttrFamilypango.AttrFamilyfamilystart_index0end_index1family :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.AttrForegroundpango.AttrForegroundredgreenbluestart_index0end_index1red :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.AttrBackgroundpango.AttrBackgroundredgreenbluestart_index0end_index1red :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.AttrSizepango.AttrSizesizestart_index0end_index1size :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
objectThe 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.AttrStylepango.AttrStylestylestart_index0end_index1style :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
objectThe 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.AttrWeightpango.AttrWeightweightstart_index0end_index1weight :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
objectThe 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.AttrVariantpango.AttrVariantvariantstart_index0end_index1variant :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
objectThe 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.AttrStretchpango.AttrStretchstretchstart_index0end_index1stretch :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
objectThe 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 widthpango.STRETCH_EXTRA_CONDENSEDpango.STRETCH_CONDENSEDpango.STRETCH_SEMI_CONDENSEDpango.STRETCH_NORMALThe normal width.pango.STRETCH_SEMI_EXPANDEDpango.STRETCH_EXPANDEDpango.STRETCH_EXTRA_EXPANDEDpango.STRETCH_ULTRA_EXPANDEDThe most expanded widthpango.AttrFontDescpango.AttrFontDescdescstart_index0end_index1desc :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
objectThe 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.AttrUnderlinepango.AttrUnderlineunderlinestart_index0end_index1underline :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
objectThe 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.AttrStrikethroughpango.AttrStrikethroughstrikethroughstart_index0end_index1strikethrough :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
objectThe 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.AttrRisepango.AttrRiserisestart_index0end_index1rise :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
objectThe 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.AttrShapepango.AttrShapeink_rectlogical_rectstart_index0end_index1ink_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
objectThe 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.AttrScalepango.AttrScalescalestart_index0end_index1scale :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
objectThe 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.AttrFallbackpango.AttrFallbackfallbackstart_index0end_index1fallback :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
objectThis 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.