java-gnome version 4.0.19

org.gnome.pango
Class FontDescription

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.gnome.glib.Boxed
          extended by org.gnome.pango.FontDescription

public final class FontDescription
extends Boxed

An abstract description of a font. This class is used both to list what fonts are available on the system, and also for specifying the characteristics of a font you'd like to load.

The most common use is to indicate the font you want to use when drawing text:

 cr = new Context(surface);
 layout = new Layout(cr);
 
 desc = new FontDescription("Monospace, 12");
 layout.setFontDescription(desc);
 
The constructor has an extensive discussion of the format of the textual descriptions you can use when hunting for that perfect font to render with.

Since:
4.0.10
Author:
Vreixo Formoso, Andrew Cowie

Constructor Summary
FontDescription()
          Create a blank FontDescription with all fields unset.
FontDescription(String str)
          Create a FontDescription from a textual description.
 
Method Summary
 FontDescription copy()
          Make a deep copy of this FontDescription object.
 boolean equals(Object obj)
           
 String getFamily()
          The family the font that this FontDescription represents belongs to.
 double getSize()
          Get the size of this font, in device units.
 Style getStyle()
          Get the slant style of the font.
 Variant getVariant()
          Get the capitalization variant of the font.
 Weight getWeight()
          Get the weight of the font.
 int hashCode()
           
 void setFamily(String family)
          Specify the family (of related font styles) you wish to pick.
 void setSize(double size)
          Set the size of the font you are requesting.
 void setSizeAbsolute(double size)
          Set the size in raw device units (ie pixels if working on screen).
 void setStyle(Style style)
          Set the style of the font you're looking for.
 void setVariant(Variant variant)
          Set the capitalization variant of the Font.
 void setWeight(Weight weight)
          Indicate how bold or light the font should be.
 String toString()
           
 
Methods inherited from class Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FontDescription

public FontDescription()
Create a blank FontDescription with all fields unset.

FontDescription(String) is usually a better way to initialize the FontDescription, specially if you get the description from a FontSelection Widget.

Since:
4.0.10

FontDescription

public FontDescription(String str)
Create a FontDescription from a textual description. The form is:
 "family[,] options size"
 
where:

All three are optional when using FontDescription to request a font; if default values will be used for any parameters which are absent.

Font size is traditionally expressed in "points". Be aware, however, that having a "10.5" point font doesn't actually mean that lines will be precisely 10.5 points high. If you need to know their rendered size, see a resultant LayoutLine's getExtentsLogical(). You can instead follow the number with "px" to interpret the size argument as an absolute number of pixels .

Examples include:

Since:
4.0.10
Method Detail

copy

public FontDescription copy()
Make a deep copy of this FontDescription object.

Since:
4.0.11

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getFamily

public String getFamily()
The family the font that this FontDescription represents belongs to. Returns null if unset.

Since:
4.0.10

getSize

public double getSize()
Get the size of this font, in device units.

Note that this does not imply how high a line in this font will be; that is up to the Layout doing the rendering. To find out the height of a rendered line, use LayoutLine's getExtentsLogical().

Since:
4.0.10

getStyle

public Style getStyle()
Get the slant style of the font.

Since:
4.0.10

getVariant

public Variant getVariant()
Get the capitalization variant of the font.

Since:
4.0.10

getWeight

public Weight getWeight()
Get the weight of the font.

Since:
4.0.10

hashCode

public int hashCode()
Overrides:
hashCode in class Object

setFamily

public void setFamily(String family)
Specify the family (of related font styles) you wish to pick.

See the families argument to the FontDescription constructor for details.

Since:
4.0.10

setSize

public void setSize(double size)
Set the size of the font you are requesting. Size is expressed in points.

Since you can indicate the size you want when constructing with a textual description, you don't need this too often.

Since:
4.0.10

setSizeAbsolute

public void setSizeAbsolute(double size)
Set the size in raw device units (ie pixels if working on screen).

This corresponds to providing a size in a textual description such as "Sans, 10px" instead of "Sans, 10"; since you can specify it there you problably don't need this much.

Since:
Unstable

setStyle

public void setStyle(Style style)
Set the style of the font you're looking for. This is ITALIC and friends.

If you've worked with Textview then you might have seen this before as TextTag's setStyle(). Same factor.

Since:
4.0.10

setVariant

public void setVariant(Variant variant)
Set the capitalization variant of the Font. This is where SMALL_CAPS lives. Normally you'll leave it alone; not surprisingly the default is NORMAL.

Since:
4.0.10

setWeight

public void setWeight(Weight weight)
Indicate how bold or light the font should be.

Since:
4.0.10

toString

public String toString()
Overrides:
toString in class org.freedesktop.bindings.Pointer


java-gnome