pangomm: 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)
 
GlyphStringoperator= (const GlyphString& other)
 
 GlyphString (GlyphString&& other) noexcept
 
GlyphStringoperator= (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< GlyphInfoget_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

Pango::GlyphString::GlyphString ( )
Pango::GlyphString::GlyphString ( PangoGlyphString *  gobject,
bool  make_a_copy = true 
)
explicit
Pango::GlyphString::GlyphString ( const GlyphString other)
Pango::GlyphString::GlyphString ( GlyphString&&  other)
noexcept
Pango::GlyphString::~GlyphString ( )
noexcept
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
textThe text to process. You must pass the same string into those member functions expecting a const Glib::ustring&.
analysisThe analysis information returned from Pango::Context::itemize().
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_textValid UTF-8 text to shape.
paragraph_textText of the paragraph (see details).
analysisThe analysis information returned from Pango::Context::itemize().
flagsFlags influencing the shaping process.

Member Function Documentation

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
fontA Pango::Font.
ink_rectRectangle used to store the extents of the glyph string as drawn.
logical_rectRectangle used to store the logical extents of the glyph string.
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
startStart index.
endEnd index (the range is the set of bytes with indices such that start <= index < end).
fontA Pango::Font.
ink_rectRectangle used to store the extents of the glyph string range as drawn.
logical_rectRectangle used to store the logical extents of the glyph string range.
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.
Rectangle Pango::GlyphString::get_ink_extents ( const Glib::RefPtr< const Font >&  font) const

Computes the extents of the glyph string as drawn.

Parameters
fontA Pango::Font.
Returns
The extents of the glyph string as drawn.
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
startThe start index.
endThe end index.
fontA Panog::Font
Returns
The extents of the sub-portion of the glyph string as drawn.
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
fontA Pango::Font.
Returns
The logical extents of the glyph string.
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
startThe start index.
endThe end index.
fontA Pango::Font.
Returns
The logical extents of the sub-portion of the glyph string.
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
textThe text corresponding to the glyphs.
embedding_levelThe embedding level of the string.
Returns
An array of integers representing the resulting character widths.
static GType Pango::GlyphString::get_type ( )
static

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

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.
PangoGlyphString* Pango::GlyphString::gobj ( )
inline

Provides access to the underlying C instance.

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

Provides access to the underlying C instance.

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.

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
textThe text corresponding to the glyphs.
analysisThe analysis information return from Pango::Context::itemize().
indexThe byte index within text.
trailingWhether we should compute the result for the beginning or end of the character.
Returns
The x position.
GlyphString& Pango::GlyphString::operator= ( const GlyphString other)
GlyphString& Pango::GlyphString::operator= ( GlyphString&&  other)
noexcept
void Pango::GlyphString::set_size ( int  new_len)

Resize a glyph string to the given length.

Parameters
new_lenThe new length of the string.
void Pango::GlyphString::swap ( GlyphString other)
noexcept
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
textThe text corresponding to the glyphs.
analysisThe analysis information return from Pango::Context::itemize().
x_posThe x offset (in thousands of a device unit).
indexThe location to store calculated byte index within.
trailingThe location to store a boolean indicating whether the user clicked on the leading or trailing edge of the character.

Friends And Related Function Documentation

void swap ( GlyphString lhs,
GlyphString rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side
Pango::GlyphString wrap ( PangoGlyphString *  object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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

PangoGlyphString* Pango::GlyphString::gobject_
protected