pangomm: Pango::GlyphString Class Reference

pangomm 2.48.2

Public Member Functions | Static Public Member Functions | Protected Attributes | Related Functions | List of all members
Pango::GlyphString Class Reference

A Pango::GlyphString is used to store strings of glyphs with geometry and visual attribute information. More...

`#include <pangomm/glyphstring.h>`

## Public Member Functions
| GlyphString ()
| GlyphString (PangoGlyphString * gobject, bool make_a_copy=true)
| GlyphString (const GlyphString & other)
GlyphString & | operator= (const GlyphString & other)
| GlyphString (GlyphString && other) noexcept
GlyphString & | operator= (GlyphString && other) noexcept
| ~GlyphString () noexcept
void | swap (GlyphString & other) noexcept
PangoGlyphString * | gobj ()
| Provides access to the underlying C instance. More...
const PangoGlyphString * | gobj () const
| Provides access to the underlying C instance. More...
PangoGlyphString * | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. More...
| GlyphString (const Glib::ustring & text, const Analysis & analysis)
| Constructs a string of glyphs from a string of characters. More...
| GlyphString (const Glib::ustring & item_text, const Glib::ustring & paragraph_text, const Analysis & analysis, ShapeFlags flags=ShapeFlags::NONE)
| Constructs a string of glyphs from a string of characters. More...
void | set_size (int new_len)
| Resize a glyph string to the given length. More...
void | get_extents (const Glib::RefPtr< const Font > & font, Rectangle & ink_rect, Rectangle & logical_rect) const
| Compute the logical and ink extents of a glyph string. More...
void | get_extents (int start, int end, const Glib::RefPtr< const Font > & font, Rectangle & ink_rect, Rectangle & logical_rect) const
| Computes the extents of a sub-portion of a glyph string. More...
int | get_width () const
| Computes the logical width of the glyph string as can also be computed using extents(). More...
Rectangle | get_ink_extents (const Glib::RefPtr< const Font > & font) const
| Computes the extents of the glyph string as drawn. More...
Rectangle | get_ink_extents (int start, int end, const Glib::RefPtr< const Font > & font) const
| Computes the extents of a sub-portion of the glyph string as drawn. More...
Rectangle | get_logical_extents (const Glib::RefPtr< const Font > & font) const
| Computes the logical extents of a sub-portion of the glyph string. More...
Rectangle | get_logical_extents (int start, int end, const Glib::RefPtr< const Font > & font) const
| Computes the logical extents of a sub-portion of the glyph string. More...
std::vector< int > | get_logical_widths (const Glib::ustring & text, int embedding_level) const
| Determine the screen width corresponding to each character. More...
int | index_to_x (const Glib::ustring & text, const Analysis & analysis, int index, bool trailing) const
| Converts from character position to x position. More...
void | x_to_index (const Glib::ustring & text, const Analysis & analysis, int x_pos, int & index, bool & trailing) const
| Convert from x offset to character position. More...
std::vector< GlyphInfo > | get_glyphs () const
| Gharacter positions are computed by dividing up each cluster into equal portions. More...

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Attributes
PangoGlyphString * | gobject_

## Related Functions
(Note that these are not member functions.)
void | swap (GlyphString & lhs, GlyphString & rhs) noexcept
Pango::GlyphString | wrap (PangoGlyphString * object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

A Pango::GlyphString is used to store strings of glyphs with geometry and visual attribute information.

It can be measured or drawn to the screen.

## Constructor & Destructor Documentation

## ◆ GlyphString() [1/6]

Pango::GlyphString::GlyphString | ( |  | ) |

## ◆ GlyphString() [2/6]

Pango::GlyphString::GlyphString | ( | PangoGlyphString * | gobject,
|  | bool | make_a_copy = `true`
| ) |  |
| explicit

## ◆ GlyphString() [3/6]

Pango::GlyphString::GlyphString | ( | const GlyphString & | other | ) |

## ◆ GlyphString() [4/6]

Pango::GlyphString::GlyphString | ( | GlyphString && | other | ) |
| noexcept

## ◆ ~GlyphString()

Pango::GlyphString::~GlyphString | ( |  | ) |
| noexcept

## ◆ GlyphString() [5/6]

Pango::GlyphString::GlyphString | ( | const Glib::ustring & | text,
|  | const Analysis & | analysis
| ) |  |

Constructs a string of glyphs from a string of characters.

Given a segment of text and the corresponding Pango::Analysis structure returned from Pango::Context::itemize(), convert the characters into glyphs. You may also pass in only a substring of the item.

It is recommended that you use the constructor with item_text and paragraph_text parameters instead, since that API allows for shaping interaction happening across text item boundaries.

Parameters

  text | The text to process. You must pass the same string into those member functions expecting a const Glib::ustring&.
  analysis | The analysis information returned from Pango::Context::itemize().

## ◆ GlyphString() [6/6]

Pango::GlyphString::GlyphString | ( | const Glib::ustring & | item_text,
|  | const Glib::ustring & | paragraph_text,
|  | const Analysis & | analysis,
|  | ShapeFlags | flags = `ShapeFlags::NONE`
| ) |  |

Constructs a string of glyphs from a string of characters.

Given a segment of text and the corresponding Pango::Analysis structure returned from Pango::Context::itemize(), convert the characters into glyphs. You may also pass in only a substring of the item.

This is similar to the constructor with only one text parameter, except it also takes flags and the full paragraph text as input, which will then be used to perform certain cross-item shaping interactions. If you have access to the broader text of which item_text is a part, provide the broader text as paragraph_text.

Since pangomm 2.44:

Parameters

  item_text | Valid UTF-8 text to shape.
  paragraph_text | Text of the paragraph (see details).
  analysis | The analysis information returned from Pango::Context::itemize().
  flags | Flags influencing the shaping process.

## Member Function Documentation

## ◆ get_extents() [1/2]

void Pango::GlyphString::get_extents | ( | const Glib::RefPtr< const Font > & | font,
|  | Rectangle & | ink_rect,
|  | Rectangle & | logical_rect
| ) |  | const

Compute the logical and ink extents of a glyph string.

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

Parameters

  font | A Pango::Font.
  ink_rect | Rectangle used to store the extents of the glyph string as drawn.
  logical_rect | Rectangle used to store the logical extents of the glyph string.

## ◆ get_extents() [2/2]

void Pango::GlyphString::get_extents | ( | int | start,
|  | int | end,
|  | const Glib::RefPtr< const Font > & | font,
|  | Rectangle & | ink_rect,
|  | Rectangle & | logical_rect
| ) |  | const

Computes the extents of a sub-portion of a glyph 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).

Parameters

  start | Start index.
  end | End index (the range is the set of bytes with indices such that start <= index < end).
  font | A Pango::Font.
  ink_rect | Rectangle used to store the extents of the glyph string range as drawn.
  logical_rect | Rectangle used to store the logical extents of the glyph string range.

## ◆ get_glyphs()

std::vector<GlyphInfo> Pango::GlyphString::get_glyphs | ( |  | ) | const

Gharacter positions are computed by dividing up each cluster into equal portions.

Returns
  An array of Pango::GlyphInfo objects.

## ◆ get_ink_extents() [1/2]

Rectangle Pango::GlyphString::get_ink_extents | ( | const Glib::RefPtr< const Font > & | font | ) | const

Computes the extents of the glyph string as drawn.

Parameters

  font | A Pango::Font.

Returns
  The extents of the glyph string as drawn.

## ◆ get_ink_extents() [2/2]

Rectangle Pango::GlyphString::get_ink_extents | ( | int | start,
|  | int | end,
|  | const Glib::RefPtr< const Font > & | font
| ) |  | const

Computes the extents of a sub-portion of the glyph string as drawn.

Parameters

  start | The start index.
  end | The end index.
  font | A Panog::Font

Returns
  The extents of the sub-portion of the glyph string as drawn.

## ◆ get_logical_extents() [1/2]

Rectangle Pango::GlyphString::get_logical_extents | ( | const Glib::RefPtr< const Font > & | font | ) | const

Computes the logical extents of a sub-portion of the glyph string.

Parameters

  font | A Pango::Font.

Returns
  The logical extents of the glyph string.

## ◆ get_logical_extents() [2/2]

Rectangle Pango::GlyphString::get_logical_extents | ( | int | start,
|  | int | end,
|  | const Glib::RefPtr< const Font > & | font
| ) |  | const

Computes the logical extents of a sub-portion of the glyph string.

Parameters

  start | The start index.
  end | The end index.
  font | A Pango::Font.

Returns
  The logical extents of the sub-portion of the glyph string.

## ◆ get_logical_widths()

std::vector<int> Pango::GlyphString::get_logical_widths | ( | const Glib::ustring & | text,
|  | int | embedding_level
| ) |  | const

Determine the screen width corresponding to each character.

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

Parameters

  text | The text corresponding to the glyphs.
  embedding_level | The embedding level of the string.

Returns
  An array of integers representing the resulting character widths.

## ◆ get_type()

static GType Pango::GlyphString::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ get_width()

int Pango::GlyphString::get_width | ( |  | ) | const

Computes the logical width of the glyph string as can also be computed using extents().

However, since this only computes the width, it's much faster. This is in fact only a convenience function that computes the sum of geometry.width for each glyph in the glyphs.

Since pangomm 1.14:

Returns
  The logical width of the glyph string.

## ◆ gobj() [1/2]

PangoGlyphString* Pango::GlyphString::gobj | ( |  | ) |
| inline

Provides access to the underlying C instance.

## ◆ gobj() [2/2]

const PangoGlyphString* Pango::GlyphString::gobj | ( |  | ) | const
| inline

Provides access to the underlying C instance.

## ◆ gobj_copy()

PangoGlyphString* Pango::GlyphString::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.

## ◆ index_to_x()

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

Converts from character position to 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.

Parameters

  text | The text corresponding to the glyphs.
  analysis | The analysis information return 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.

## ◆ operator=() [1/2]

GlyphString& Pango::GlyphString::operator= | ( | const GlyphString & | other | ) |

## ◆ operator=() [2/2]

GlyphString& Pango::GlyphString::operator= | ( | GlyphString && | other | ) |
| noexcept

## ◆ set_size()

void Pango::GlyphString::set_size | ( | int | new_len | ) |

Resize a glyph string to the given length.

Parameters

  new_len | The new length of the string.

## ◆ swap()

void Pango::GlyphString::swap | ( | GlyphString & | other | ) |
| noexcept

## ◆ x_to_index()

void Pango::GlyphString::x_to_index | ( | const Glib::ustring & | text,
|  | const Analysis & | analysis,
|  | int | x_pos,
|  | int & | index,
|  | bool & | trailing
| ) |  | const

Convert from x offset to character position.

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.

Parameters

  text | The text corresponding to the glyphs.
  analysis | The analysis information return from Pango::Context::itemize().
  x_pos | The x offset (in thousands of a device unit).
  index | The location to store calculated byte index within.
  trailing | The location to store a boolean indicating whether the user clicked on the leading or trailing edge of the character.

## Friends And Related Function Documentation

## ◆ swap()

void swap | ( | GlyphString & | lhs,
|  | GlyphString & | rhs
| ) |  |
| related

Parameters

  lhs | The left-hand side
  rhs | The right-hand side

## ◆ wrap()

Pango::GlyphString wrap | ( | PangoGlyphString * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.

## Member Data Documentation

## ◆ gobject_

PangoGlyphString* Pango::GlyphString::gobject_
| protected