Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Pango::GlyphString Class Reference

A PangoGlyphString C++ wrapper class. More...

`#include <inti/pango/glyph.h>`

Inheritance diagram for Inti::Pango::GlyphString:

List of all members.

## Public Member Functions

Constructors

- GlyphString ()
    Construct a new glyph string.
- GlyphString (const String &text, const Analysis &analysis)
    Given a segment of text and the corresponding Analysis structure returned from Pango::Context::itemize(), convert the characters in text into glyphs.
- GlyphString (PangoGlyphString *string)
    Construct a new glyph string from an existing PangoGlyphString.
- GlyphString (PangoGlyphString *string, bool copy)
    Construct a new glyph string from an existing PangoGlyphString.
- GlyphString (const GlyphString &src)
    Copy constructor.
- virtual ~GlyphString ()
    Destructor.
- GlyphString & operator= (const GlyphString &src)
    Assignment operator.

Accessors

- PangoGlyphString * pango_glyph_string () const
    Get a pointer to the PangoGlyphString structure.
- operator PangoGlyphString * () const
    Conversion operator; safely converts a GlyphString to a PangoGlyphString pointer.
- int size () const
    Returns the number of glyphs in the string.
- std::vector< GlyphInfo > glyphs () const
    Returns a vector of GlyphInfo that holds one GlyphInfo object for each glyph in the string.
- int * log_clusters () const
    For each glyph, returns the byte index of the starting character for the cluster.
- void extents (const Font &font, Rectangle *ink_rect, Rectangle *logical_rect, int start=0, int end=-1) const
    Compute the logical and ink extents of a sub-portion the glyph string, or the entire glyph string.
- void get_logical_widths (const String &text, int embedding_level, std::vector< int > &logical_widths) const
    Given a GlyphString resulting from pango_shape() and the corresponding text, determine the screen width corresponding to each character.

Methods

- void set_size (int length)
    Resize a glyph string to the given length.
- int index_to_x (const String &text, const Analysis &analysis, int index, bool trailing)
    Converts from a character position to an x position.
- void x_to_index (const String &text, const Analysis &analysis, int x_pos, int *index, bool *trailing)
    Convert from an x offset to character position.

## Detailed Description

A PangoGlyphString C++ wrapper class.

GlyphString is used to store strings of glyphs with geometry and visual attribute information. The storage for the glyph information is owned by the structure which simplifies memory management.

## Constructor & Destructor Documentation

Inti::Pango::GlyphString::GlyphString | ( | const String & | text,
|  | const Analysis & | analysis
| ) |

Given a segment of text and the corresponding Analysis structure returned from Pango::Context::itemize(), convert the characters in text into glyphs.

Parameters:

  text | The text to process.
  analysis | The Analysis structure from Pango::Context::Itemize().

You may also pass in only a substring of the item from Pango::Context::itemize(). This constructor calls pango_shape(). There is no shape() method.

Inti::Pango::GlyphString::GlyphString | ( | PangoGlyphString * | string | ) | `[explicit]`

Construct a new glyph string from an existing PangoGlyphString.

Parameters:

  string | A pointer to a PangoGlyphString.

The string can be a newly created PangoGlyphString or an existing PangoGlyphString. The glyph string object created is a temporary object. It doesn't take over the ownership of PangoGlyphString and PangoGlyphString is not freed by the destructor.

Inti::Pango::GlyphString::GlyphString | ( | PangoGlyphString * | string,
|  | bool | copy
| ) |

Construct a new glyph string from an existing PangoGlyphString.

Parameters:

  string | A pointer to a PangoGlyphString.
  copy | Whether the GlyphString object should make a copy of PangoGlyphString or not.

The string can be a newly created PangoGlyphString or an existing PangoGlyphString. If copy is true GlyphString will make a copy of PangoGlyphString. If copy is false GlyphString wont make a copy but instead takes over the ownership of PangoGlyphString. Either way, the destructor will free PangoGlyphString when the GlyphString object is destroyed. This constructor is used by G::Boxed::wrap() to wrap PangoGlyphString objects in a C++ wrapper.

Inti::Pango::GlyphString::GlyphString | ( | const GlyphString & | src | ) |

Copy constructor.

Parameters:

  src | The source GlyphString.

## Member Function Documentation

void Inti::Pango::GlyphString::extents | ( | const Font & | font,
|  | Rectangle * | ink_rect,
|  | Rectangle * | logical_rect,
|  | int | start = 0,
|  | int | end = -1
| ) | const

Compute the logical and ink extents of a sub-portion the glyph string, or the entire glyph string.

Parameters:

  font | A Font.
  ink_rect | The rectangle used to store the extents of the glyph string as drawn, or null to indicate that the result is not needed.
  logical_rect | The rectangle used to store the logical extents of the glyph string, or null to indicate that the result is not needed.
  start | The start index in bytes, or 0 for the start of the string.
  end | The end index in bytes, or -1 for the end of the string.

The extents are relative to the start of the glyph string range (the origin of their coordinate system is at the start of the range, not at the start of the entire glyph string).

See the documentation for Pango::Font::get_glyph_extents() for details about the interpretation of the rectangles.

void Inti::Pango::GlyphString::get_logical_widths | ( | const String & | text,
|  | int | embedding_level,
|  | std::vector< int > & | logical_widths
| ) | const

Given a GlyphString resulting from pango_shape() and the corresponding text, determine the screen width corresponding to each character.

Parameters:

  text | The text corresponding to the glyphs.
  embedding_level | The embedding level of the string.
  logical_widths | A reference to a vector of int to be filled in with the resulting character widths.

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

int Inti::Pango::GlyphString::index_to_x | ( | const String & | text,
|  | const Analysis & | analysis,
|  | int | index,
|  | bool | trailing
| ) |

Converts from a character position to an x position.

Parameters:

  text | The text for the run.
  analysis | The analysis information returned from Pango::Context::itemize().
  index | The byte index within text.
  trailing | Whether we should compute the result for the beginning or end of the character.

Returns:
  The x position.

X position is measured from the left edge of the run. Character positions are computed by dividing up each cluster into equal portions.

int* Inti::Pango::GlyphString::log_clusters | ( |  | ) | const

| For each glyph, returns the byte index of the starting character for the cluster. The indices are relative to the start of the text corresponding to the GlyphString.

GlyphString& Inti::Pango::GlyphString::operator= | ( | const GlyphString & | src | ) |

Assignment operator.

Parameters:

  src | The source GlyphString.

void Inti::Pango::GlyphString::set_size | ( | int | length | ) |

Resize a glyph string to the given length.

Parameters:

  length | The new length of the string.

void Inti::Pango::GlyphString::x_to_index | ( | const String & | text,
|  | const Analysis & | analysis,
|  | int | x_pos,
|  | int * | index,
|  | bool * | trailing
| ) |

Convert from an x offset to character position.

Parameters:

  text | The text for the run.
  analysis | The analysis information returned from Pango::Context::itemize().
  x_pos | The x offset (in GlyphUnit).
  index | The location to store calculated byte index within the text.
  trailing | The location to store whether the user clicked on the leading or trailing edge of the character.

Character positions are computed by dividing up each cluster into equal portions. In scripts where positioning within a cluster is not allowed (such as Thai), the returned value may not be a valid cursor position; the caller must combine the result with the logical attributes for the text to compute the valid cursor position.

The documentation for this class was generated from the following file:

- glyph.h

Main Page - Footer