pangomm 2.54.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Related Symbols | 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)
 
GlyphStringoperator= (const GlyphString &other)
 
 GlyphString (GlyphString &&other) noexcept
 
GlyphStringoperator= (GlyphString &&other) noexcept
 
 ~GlyphString () noexcept
 
void swap (GlyphString &other) noexcept
 
PangoGlyphStringgobj ()
 Provides access to the underlying C instance.
 
const PangoGlyphStringgobj () const
 Provides access to the underlying C instance.
 
PangoGlyphStringgobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
 
 GlyphString (const Glib::ustring &text, const Analysis &analysis)
 Constructs a string of glyphs from a string of characters.
 
 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.
 
void set_size (int new_len)
 Resize a glyph string to the given length.
 
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.
 
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.
 
int get_width () const
 Computes the logical width of the glyph string.
 
Rectangle get_ink_extents (const Glib::RefPtr< const Font > &font) const
 Computes the extents of the glyph string as drawn.
 
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.
 
Rectangle get_logical_extents (const Glib::RefPtr< const Font > &font) const
 Computes the logical extents of a sub-portion of the glyph string.
 
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.
 
std::vector< intget_logical_widths (const Glib::ustring &text, int embedding_level) const
 Determine the screen width corresponding to each character.
 
int index_to_x (const Glib::ustring &text, const Analysis &analysis, int index, bool trailing) const
 Converts from character position to x position.
 
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.
 
std::vector< GlyphInfoget_glyphs () const
 Gharacter positions are computed by dividing up each cluster into equal portions.
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 

Protected Attributes

PangoGlyphStringgobject_
 

Related Symbols

(Note that these are not member symbols.)

void swap (GlyphString &lhs, GlyphString &rhs) noexcept
 
Pango::GlyphString wrap (PangoGlyphString *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

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
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().

◆ 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_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

◆ 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
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.

◆ 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
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.

◆ 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
fontA 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
startThe start index.
endThe end index.
fontA 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
fontA 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
startThe start index.
endThe end index.
fontA 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
textThe text corresponding to the glyphs.
embedding_levelThe 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.

This 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
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.

◆ 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_lenThe 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
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 Symbol Documentation

◆ swap()

void swap ( GlyphString lhs,
GlyphString rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side

◆ wrap()

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

◆ gobject_

PangoGlyphString* Pango::GlyphString::gobject_
protected