pangomm 2.54.0
|
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. | |
const PangoGlyphString * | gobj () const |
Provides access to the underlying C instance. | |
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. | |
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 ¶graph_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< int > | get_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< GlyphInfo > | get_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 | |
PangoGlyphString * | gobject_ |
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. | |
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.
Pango::GlyphString::GlyphString | ( | ) |
|
explicit |
Pango::GlyphString::GlyphString | ( | const GlyphString & | other | ) |
|
noexcept |
|
noexcept |
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.
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(). |
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.
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. |
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.
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. |
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).
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. |
std::vector< GlyphInfo > Pango::GlyphString::get_glyphs | ( | ) | const |
Gharacter positions are computed by dividing up each cluster into equal portions.
Computes the extents of the glyph string as drawn.
font | A Pango::Font. |
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.
start | The start index. |
end | The end index. |
font | A Panog::Font |
Computes the logical extents of a sub-portion of the glyph string.
font | A Pango::Font. |
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.
start | The start index. |
end | The end index. |
font | A Pango::Font. |
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.
text | The text corresponding to the glyphs. |
embedding_level | The embedding level of the string. |
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.
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.
|
inline |
Provides access to the underlying C instance.
|
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.
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. |
GlyphString & Pango::GlyphString::operator= | ( | const GlyphString & | other | ) |
|
noexcept |
Resize a glyph string to the given length.
new_len | The new length of the string. |
|
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.
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. |
|
related |
lhs | The left-hand side |
rhs | The right-hand side |
|
related |
A Glib::wrap() method for this object.
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. |
|
protected |