Class GlyphItem

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
LayoutRun

@Generated("org.javagi.JavaGI") public class GlyphItem extends ProxyInstance

A PangoGlyphItem is a pair of a PangoItem and the glyphs resulting from shaping the items text.

As an example of the usage of PangoGlyphItem, the results of shaping text with PangoLayout is a list of PangoLayoutLine, each of which contains a list of PangoGlyphItem.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new GlyphItem.
    Allocate a new GlyphItem.
    Create a GlyphItem proxy instance for the provided memory address.
    GlyphItem(Item item, GlyphString glyphs, int yOffset, int startXOffset, int endXOffset)
    Allocate a new GlyphItem with the fields set to the provided values.
    GlyphItem(Item item, GlyphString glyphs, int yOffset, int startXOffset, int endXOffset, Arena arena)
    Allocate a new GlyphItem with the fields set to the provided values.
  • Method Summary

    Modifier and Type
    Method
    Description
    applyAttrs(String text, AttrList list)
    Splits a shaped item (PangoGlyphItem) into multiple items based on an attribute list.
    @Nullable GlyphItem
    Make a deep copy of an existing PangoGlyphItem structure.
    void
    Frees a PangoGlyphItem and resources to which it points.
    void
    getLogicalWidths(String text, @Nullable int @Nullable [] logicalWidths)
    Given a PangoGlyphItem and the corresponding text, determine the width corresponding to each character.
    The memory layout of the native struct.
    static @Nullable Type
    Get the GType of the GlyphItem class.
    void
    letterSpace(String text, @Nullable LogAttr @Nullable [] logAttrs, int letterSpacing)
    Adds spacing between the graphemes of this GlyphItem to give the effect of typographic letter spacing.
    int
    Read the value of the field end_x_offset.
    Read the value of the field glyphs.
    Read the value of the field item.
    int
    Read the value of the field start_x_offset.
    int
    Read the value of the field y_offset.
    @Nullable GlyphItem
    split(String text, int splitIndex)
    Modifies this GlyphItem to cover only the text after splitIndex, and returns a new item that covers the text before splitIndex that used to be in orig.
    void
    writeEndXOffset(int endXOffset)
    Write a value in the field end_x_offset.
    void
    Write a value in the field glyphs.
    void
    Write a value in the field item.
    void
    writeStartXOffset(int startXOffset)
    Write a value in the field start_x_offset.
    void
    writeYOffset(int yOffset)
    Write a value in the field y_offset.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GlyphItem

      public GlyphItem(MemorySegment address)
      Create a GlyphItem proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • GlyphItem

      public GlyphItem(Arena arena)
      Allocate a new GlyphItem.
      Parameters:
      arena - to control the memory allocation scope
    • GlyphItem

      public GlyphItem()
      Allocate a new GlyphItem. The memory is allocated with Arena.ofAuto().
    • GlyphItem

      public GlyphItem(Item item, GlyphString glyphs, int yOffset, int startXOffset, int endXOffset, Arena arena)
      Allocate a new GlyphItem with the fields set to the provided values.
      Parameters:
      item - value for the field item
      glyphs - value for the field glyphs
      yOffset - value for the field yOffset
      startXOffset - value for the field startXOffset
      endXOffset - value for the field endXOffset
      arena - to control the memory allocation scope
    • GlyphItem

      public GlyphItem(Item item, GlyphString glyphs, int yOffset, int startXOffset, int endXOffset)
      Allocate a new GlyphItem with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      item - value for the field item
      glyphs - value for the field glyphs
      yOffset - value for the field yOffset
      startXOffset - value for the field startXOffset
      endXOffset - value for the field endXOffset
  • Method Details

    • getType

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

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readItem

      public Item readItem()
      Read the value of the field item.
      Returns:
      The value of the field item
    • writeItem

      public void writeItem(Item item)
      Write a value in the field item.
      Parameters:
      item - The new value for the field item
    • readGlyphs

      public GlyphString readGlyphs()
      Read the value of the field glyphs.
      Returns:
      The value of the field glyphs
    • writeGlyphs

      public void writeGlyphs(GlyphString glyphs)
      Write a value in the field glyphs.
      Parameters:
      glyphs - The new value for the field glyphs
    • readYOffset

      public int readYOffset()
      Read the value of the field y_offset.
      Returns:
      The value of the field y_offset
    • writeYOffset

      public void writeYOffset(int yOffset)
      Write a value in the field y_offset.
      Parameters:
      yOffset - The new value for the field y_offset
    • readStartXOffset

      public int readStartXOffset()
      Read the value of the field start_x_offset.
      Returns:
      The value of the field start_x_offset
    • writeStartXOffset

      public void writeStartXOffset(int startXOffset)
      Write a value in the field start_x_offset.
      Parameters:
      startXOffset - The new value for the field start_x_offset
    • readEndXOffset

      public int readEndXOffset()
      Read the value of the field end_x_offset.
      Returns:
      The value of the field end_x_offset
    • writeEndXOffset

      public void writeEndXOffset(int endXOffset)
      Write a value in the field end_x_offset.
      Parameters:
      endXOffset - The new value for the field end_x_offset
    • applyAttrs

      public SList<GlyphItem> applyAttrs(String text, AttrList list)

      Splits a shaped item (PangoGlyphItem) into multiple items based on an attribute list.

      The idea is that if you have attributes that don't affect shaping, such as color or underline, to avoid affecting shaping, you filter them out (AttrList.filter(AttrFilterFunc)), apply the shaping process and then reapply them to the result using this function.

      All attributes that start or end inside a cluster are applied to that cluster; for instance, if half of a cluster is underlined and the other-half strikethrough, then the cluster will end up with both underline and strikethrough attributes. In these cases, it may happen that item>extraAttrs for some of the result items can have multiple attributes of the same type.

      This function takes ownership of glyphItem; it will be reused as one of the elements in the list.

      Parameters:
      text - text that list applies to
      list - a PangoAttrList
      Returns:
      a list of glyph items resulting from splitting glyphItem. Free the elements using free(), the list using g_slist_free().
      Since:
      1.2
    • copy

      public @Nullable GlyphItem copy()
      Make a deep copy of an existing PangoGlyphItem structure.
      Returns:
      the newly allocated PangoGlyphItem
      Since:
      1.20
    • free

      public void free()
      Frees a PangoGlyphItem and resources to which it points.
      Since:
      1.6
    • getLogicalWidths

      public void getLogicalWidths(String text, @Nullable int @Nullable [] logicalWidths)

      Given a PangoGlyphItem and the corresponding text, determine the width corresponding to each character.

      When multiple characters compose a single cluster, the width of the entire cluster is divided equally among the characters.

      See also GlyphString.getLogicalWidths(String, int, int, int[]).

      Parameters:
      text - text that this GlyphItem corresponds to (glyph_item->item->offset is an offset from the start of text)
      logicalWidths - an array whose length is the number of characters in glyph_item (equal to glyph_item->item->num_chars) to be filled in with the resulting character widths.
      Since:
      1.26
    • letterSpace

      public void letterSpace(String text, @Nullable LogAttr @Nullable [] logAttrs, int letterSpacing)
      Adds spacing between the graphemes of this GlyphItem to give the effect of typographic letter spacing.
      Parameters:
      text - text that this GlyphItem corresponds to (glyph_item->item->offset is an offset from the start of text)
      logAttrs - logical attributes for the item (the first logical attribute refers to the position before the first character in the item)
      letterSpacing - amount of letter spacing to add in Pango units. May be negative, though too large negative values will give ugly results.
      Since:
      1.6
    • split

      public @Nullable GlyphItem split(String text, int splitIndex)

      Modifies this GlyphItem to cover only the text after splitIndex, and returns a new item that covers the text before splitIndex that used to be in orig.

      You can think of splitIndex as the length of the returned item. splitIndex may not be 0, and it may not be greater than or equal to the length of this GlyphItem (that is, there must be at least one byte assigned to each item, you can't create a zero-length item).

      This function is similar in function to pango_item_split() (and uses it internally.)

      Parameters:
      text - text to which positions in this GlyphItem apply
      splitIndex - byte index of position to split item, relative to the start of the item
      Returns:
      the newly allocated item representing text before splitIndex, which should be freed with pango_glyph_item_free().
      Since:
      1.2