Enum Class Gravity

java.lang.Object
java.lang.Enum<Gravity>
org.gnome.pango.Gravity
All Implemented Interfaces:
Serializable, Comparable<Gravity>, Constable, Enumeration

@Generated("org.javagi.JavaGI") public enum Gravity extends Enum<Gravity> implements Enumeration

PangoGravity represents the orientation of glyphs in a segment of text.

This is useful when rendering vertical text layouts. In those situations, the layout is rotated using a non-identity Pango.Matrix, and then glyph orientation is controlled using PangoGravity.

Not every value in this enumeration makes sense for every usage of PangoGravity; for example, AUTO only can be passed to Context.setBaseGravity(Gravity) and can only be returned by Context.getBaseGravity().

See also: Pango.GravityHint

Since:
1.16
  • Enum Constant Details

    • SOUTH

      public static final Gravity SOUTH
      Glyphs stand upright (default)
    • EAST

      public static final Gravity EAST
      Glyphs are rotated 90 degrees counter-clockwise.
    • NORTH

      public static final Gravity NORTH
      Glyphs are upside-down.
    • WEST

      public static final Gravity WEST
      Glyphs are rotated 90 degrees clockwise.
    • AUTO

      public static final Gravity AUTO
      Gravity is resolved from the context matrix
  • Method Details

    • values

      public static Gravity[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Gravity valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • of

      public static Gravity of(int value)
      Create a new Gravity for the provided value
      Parameters:
      value - the enum value
      Returns:
      the enum for the provided value
    • getValue

      public int getValue()
      Get the numeric value of this enum
      Specified by:
      getValue in interface Enumeration
      Returns:
      the enum value
    • of

      public static Gravity of(MemorySegment address)
      Create a new Gravity for the value in the provided memory address.
      Parameters:
      address - the memory address holding a enum value
      Returns:
      the enum for the value in the provided memory address
    • getType

      public static @Nullable Type getType()
      Get the GType of the Gravity class.
      Returns:
      the GType
    • getForMatrix

      public static Gravity getForMatrix(@Nullable Matrix matrix)
      Finds the gravity that best matches the rotation component in a PangoMatrix.
      Parameters:
      matrix - a PangoMatrix
      Returns:
      the gravity of matrix, which will never be AUTO, or SOUTH if matrix is null
      Since:
      1.16
    • getForScript

      public static Gravity getForScript(Script script, Gravity baseGravity, GravityHint hint)

      Returns the gravity to use in laying out a PangoItem.

      The gravity is determined based on the script, base gravity, and hint.

      If baseGravity is AUTO, it is first replaced with the preferred gravity of script. To get the preferred gravity of a script, pass AUTO and GravityHint.STRONG in.

      Parameters:
      script - PangoScript to query
      baseGravity - base gravity of the paragraph
      hint - orientation hint
      Returns:
      resolved gravity suitable to use for a run of text with script
      Since:
      1.16
    • getForScriptAndWidth

      public static Gravity getForScriptAndWidth(Script script, boolean wide, Gravity baseGravity, GravityHint hint)

      Returns the gravity to use in laying out a single character or PangoItem.

      The gravity is determined based on the script, East Asian width, base gravity, and hint,

      This function is similar to getForScript(Script, Gravity, GravityHint) except that this function makes a distinction between narrow/half-width and wide/full-width characters also. Wide/full-width characters always stand upright, that is, they always take the base gravity, whereas narrow/full-width characters are always rotated in vertical context.

      If baseGravity is AUTO, it is first replaced with the preferred gravity of script.

      Parameters:
      script - PangoScript to query
      wide - true for wide characters as returned by g_unichar_iswide()
      baseGravity - base gravity of the paragraph
      hint - orientation hint
      Returns:
      resolved gravity suitable to use for a run of text with script and wide.
      Since:
      1.26
    • toRotation

      public double toRotation()

      Converts a PangoGravity value to its natural rotation in radians.

      Note that Matrix.rotate(double) takes angle in degrees, not radians. So, to call Pango.Matrix,rotate with the output of this function you should multiply it by (180. / G_PI).

      Returns:
      the rotation value corresponding to gravity.
      Since:
      1.16