org.gnome.pango

## Class FontDescription

- Object
- - org.freedesktop.bindings.Pointer
  - - org.gnome.glib.Boxed
    - - 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

    Constructors
    Constructor and Description
    `FontDescription()` Create a blank FontDescription with all fields unset.
    `FontDescription(String str)` Create a FontDescription from a textual description.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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:
      - `family` is a comma separated list of one or more font families. The trailing `','` on the family list is optional but a good idea when a font family you're targeting includes a space in its name;
      - `options` is a whitespace separated list of words each describing a style, variant, weight, stretch, or gravity; and
      - `size` is the vertical size of the font, expressed in points You can use a suffix "px" to specify pixels instead, although this is only applicable if you're drawing to the screen or to an image backend.

      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:

      - `"Sans Bold 24"`
        Your system's sans-serif application font at a size that'll probably be about right for a headline.

      - `"Monospace 10"`
        Your system's terminal font. Note that it's `Monospace`, not `Monospaced`!

      - `"Liberation Serif 12"`
        These are an excellent series of fonts obtained for the global community by Red Hat as libre replacements for the common, but nevertheless encumbered non-free Arial, Courier, and Times fonts. Liberation Serif in particular is ideal for output being sent to printed paper.

      - `"DejaVu Sans, Book 9"`
        An upgraded version of Bitstream Vera. DejaVu Sans is optimized as a screen font (and hopefully is what you have set as your application font in your `gnome-appearance-properties`). "Book" version is the term used in DejaVu for what other fonts call "Normal".

      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`