java-gnome version 4.0.19

org.gnome.pango
Class Attribute

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.gnome.glib.Boxed
          extended by org.gnome.pango.Attribute
Direct Known Subclasses:
BackgroundColorAttribute, FallbackAttribute, FontDescriptionAttribute, ForegroundColorAttribute, RiseAttribute, SizeAttribute, StyleAttribute, UnderlineAttribute, UnderlineColorAttribute, VariantAttribute, WeightAttribute

public abstract class Attribute
extends Boxed

A (single) specific formatting or font to be applied to a range of Text.

Examples of setting up Attributes include:

 attr = new StyleAttribute(Style.ITALIC);
 
although many settings can be compounded by setting a FontDescription:
 desc = new FontDescription("DejaVu Serif, 9pt");
 attr = new FontDescriptionAttribute(desc);
 
in general it's one Attribute per characteristic. You then aggregate these together in an AttributeList and then apply them to a Layout. See AttributeList for an example of using these on discrete parts of text.

WARNING:
When coding with Attributes be aware of the following restrictions:

The different text attribute manipulations you can do are analogous to those found on FontDescription and TextTag. Indeed, Pango's Attributes are the underlying mechanism powering TextView and Label's rendering of rich markup.

Pango Attributes have an internal ugliness which is that each one needs to be told the offsets of text it applies to. The problem is that these are in terms of UTF-8 bytes, which not something we have access to from Java (nor would we want to expose such in our public API). We take care of setting the start and end points properly when you call setAttributes(), but you have to have already set the text into the Layout for us to be able to do so, obviously.

Since:
4.0.10
Author:
Andrew Cowie

Method Summary
 void setIndices(int offset, int width)
          Given the text already in a Pango Layout, a starting position, and a width, set the indexes of this Attribute accordingly.
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setIndices

public void setIndices(int offset,
                       int width)
Given the text already in a Pango Layout, a starting position, and a width, set the indexes of this Attribute accordingly. offset and width are in terms of Java characters. The result of this call is that the start_index and end_index properties of the specified Attribute will be set.

By default an Attribute added to an AttributeList covers all the text in whatever that AttributeList is applied to. If that's not what you want, you need to tell each Attribute what range it covers using this method.

Since:
4.0.11


java-gnome