pangomm 2.54.0
|
Pango::Renderer is a base class that contains the necessary logic for rendering a Pango::Layout or Pango::LayoutLine. More...
#include <pangomm/renderer.h>
Public Types | |
enum class | Part { FOREGROUND , BACKGROUND , UNDERLINE , STRIKETHROUGH , OVERLINE } |
Public Member Functions | |
Renderer (Renderer &&src) noexcept | |
Renderer & | operator= (Renderer &&src) noexcept |
~Renderer () noexcept override | |
PangoRenderer * | gobj () |
Provides access to the underlying C GObject. | |
const PangoRenderer * | gobj () const |
Provides access to the underlying C GObject. | |
PangoRenderer * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
void | draw_layout (const Glib::RefPtr< Layout > &layout, int x, int y) |
Draws layout with the specified Pango::Renderer . | |
void | draw_layout_line (const Glib::RefPtr< LayoutLine > &line, int x, int y) |
Draws line with the specified Pango::Renderer . | |
void | draw_glyphs (const Glib::RefPtr< Font > &font, const GlyphString &glyphs, int x, int y) |
Draws the glyphs in glyphs with the specified Pango::Renderer . | |
void | draw_glyph_item (const Glib::ustring &text, const GlyphItem &glyph_item, int x, int y) |
Draws the glyphs in glyph_item with the specified Pango::Renderer , embedding the text associated with the glyphs in the output if the output format supports it. | |
void | draw_rectangle (Part part, int x, int y, int width, int height) |
Draws an axis-aligned rectangle in user space coordinates with the specified Pango::Renderer . | |
void | draw_error_underline (int x, int y, int width, int height) |
Draw a squiggly line that approximately covers the given rectangle in the style of an underline used to indicate a spelling error. | |
void | draw_trapezoid (Part part, double y1, double x11, double x21, double y2, double x12, double x22) |
Draws a trapezoid with the parallel sides aligned with the X axis using the given Pango::Renderer ; coordinates are in device space. | |
void | draw_glyph (const Glib::RefPtr< Font > &font, Glyph glyph, double x, double y) |
Draws a single glyph with coordinates in device space. | |
void | activate () |
Does initial setup before rendering operations on renderer. | |
void | deactivate () |
Cleans up after rendering operations on renderer. | |
void | part_changed (Part part) |
Informs Pango that the way that the rendering is done for part has changed. | |
void | set_color (Part part, const Color &color) |
Sets the color for part of the rendering. | |
Color | get_color (Part part) const |
Gets the current rendering color for the specified part. | |
void | set_alpha (Part part, guint16 alpha) |
Sets the alpha for part of the rendering. | |
guint16 | get_alpha (Part part) const |
Gets the current alpha for the specified part. | |
void | set_matrix (const Matrix &matrix) |
Sets the transformation matrix that will be applied when rendering. | |
Matrix | get_matrix () const |
Gets the transformation matrix that will be applied when rendering. | |
Glib::RefPtr< Layout > | get_layout () |
Gets the layout currently being rendered using renderer. | |
Glib::RefPtr< const Layout > | get_layout () const |
Gets the layout currently being rendered using renderer. | |
Glib::RefPtr< LayoutLine > | get_layout_line () |
Gets the layout line currently being rendered using renderer. | |
Glib::RefPtr< const LayoutLine > | get_layout_line () const |
Gets the layout line currently being rendered using renderer. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Protected Member Functions | |
virtual void | draw_glyphs_vfunc (const Glib::RefPtr< Font > &font, const GlyphString &glyphs, int x, int y) |
virtual void | draw_rectangle_vfunc (Part part, int x, int y, int width, int height) |
virtual void | draw_error_underline_vfunc (int x, int y, int width, int height) |
virtual void | draw_shape_vfunc (const AttrShape &attr, int x, int y) |
virtual void | draw_trapezoid_vfunc (Part part, double y1, double x11, double x21, double y2, double x12, double x22) |
virtual void | draw_glyph_vfunc (const Glib::RefPtr< Font > &font, Glyph glyph, double x, double y) |
virtual void | part_changed_vfunc (Part part) |
virtual void | begin_vfunc () |
virtual void | end_vfunc () |
virtual void | prepare_run_vfunc (const GlyphItem &run) |
virtual void | draw_glyph_item_vfunc (const Glib::ustring &text, const GlyphItem &glyph_item, int x, int y) |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Pango::Renderer > | wrap (PangoRenderer *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Pango::Renderer is a base class that contains the necessary logic for rendering a Pango::Layout or Pango::LayoutLine.
By subclassing Pango::Renderer and overriding operations such as draw_glyphs and draw_rectangle, renderers for particular font backends and destinations can be created.
|
strong |
|
noexcept |
|
overridenoexcept |
void Pango::Renderer::activate | ( | ) |
Does initial setup before rendering operations on renderer.
deactivate() should be called when done drawing. Calls such as draw_layout() automatically activate the layout before drawing on it.
Calls to activate() and deactivate() can be nested and the renderer will only be initialized and deinitialized once.
void Pango::Renderer::deactivate | ( | ) |
Draw a squiggly line that approximately covers the given rectangle in the style of an underline used to indicate a spelling error.
The width of the underline is rounded to an integer number of up/down segments and the resulting rectangle is centered in the original rectangle.
This should be called while renderer is already active. Use activate() to activate a renderer.
|
protectedvirtual |
void Pango::Renderer::draw_glyph | ( | const Glib::RefPtr< Font > & | font, |
Glyph | glyph, | ||
double | x, | ||
double | y | ||
) |
Draws a single glyph with coordinates in device space.
font | A Pango::Font . |
glyph | The glyph index of a single glyph. |
x | X coordinate of left edge of baseline of glyph. |
y | Y coordinate of left edge of baseline of glyph. |
void Pango::Renderer::draw_glyph_item | ( | const Glib::ustring & | text, |
const GlyphItem & | glyph_item, | ||
int | x, | ||
int | y | ||
) |
Draws the glyphs in glyph_item with the specified Pango::Renderer
, embedding the text associated with the glyphs in the output if the output format supports it.
This is useful for rendering text in PDF.
Note that this method does not handle attributes in glyph_item. If you want colors, shapes and lines handled automatically according to those attributes, you need to use draw_layout_line() or draw_layout().
Note that text is the start of the text for layout, which is then indexed by glyph_item->item->offset
.
If text is nullptr
, this simply calls draw_glyphs().
The default implementation of this method simply falls back to draw_glyphs().
text | The UTF-8 text that glyph_item refers to. |
glyph_item | A Pango::GlyphItem . |
x | X position of left edge of baseline, in user space coordinates in Pango units. |
y | Y position of left edge of baseline, in user space coordinates in Pango units. |
|
protectedvirtual |
|
protectedvirtual |
void Pango::Renderer::draw_glyphs | ( | const Glib::RefPtr< Font > & | font, |
const GlyphString & | glyphs, | ||
int | x, | ||
int | y | ||
) |
Draws the glyphs in glyphs with the specified Pango::Renderer
.
font | A Pango::Font . |
glyphs | A Pango::GlyphString . |
x | X position of left edge of baseline, in user space coordinates in Pango units. |
y | Y position of left edge of baseline, in user space coordinates in Pango units. |
|
protectedvirtual |
Draws layout with the specified Pango::Renderer
.
This is equivalent to drawing the lines of the layout, at their respective positions relative to x, y.
layout | A Pango::Layout . |
x | X position of left edge of baseline, in user space coordinates in Pango units. |
y | Y position of left edge of baseline, in user space coordinates in Pango units. |
void Pango::Renderer::draw_layout_line | ( | const Glib::RefPtr< LayoutLine > & | line, |
int | x, | ||
int | y | ||
) |
Draws line with the specified Pango::Renderer
.
This draws the glyph items that make up the line, as well as shapes, backgrounds and lines that are specified by the attributes of those items.
line | A Pango::LayoutLine . |
x | X position of left edge of baseline, in user space coordinates in Pango units. |
y | Y position of left edge of baseline, in user space coordinates in Pango units. |
Draws an axis-aligned rectangle in user space coordinates with the specified Pango::Renderer
.
This should be called while renderer is already active. Use activate() to activate a renderer.
part | Type of object this rectangle is part of. |
x | X position at which to draw rectangle, in user space coordinates in Pango units. |
y | Y position at which to draw rectangle, in user space coordinates in Pango units. |
width | Width of rectangle in Pango units. |
height | Height of rectangle in Pango units. |
|
protectedvirtual |
|
protectedvirtual |
void Pango::Renderer::draw_trapezoid | ( | Part | part, |
double | y1, | ||
double | x11, | ||
double | x21, | ||
double | y2, | ||
double | x12, | ||
double | x22 | ||
) |
Draws a trapezoid with the parallel sides aligned with the X axis using the given Pango::Renderer
; coordinates are in device space.
part | Type of object this trapezoid is part of. |
y1 | Y coordinate of top of trapezoid. |
x11 | X coordinate of left end of top of trapezoid. |
x21 | X coordinate of right end of top of trapezoid. |
y2 | Y coordinate of bottom of trapezoid. |
x12 | X coordinate of left end of bottom of trapezoid. |
x22 | X coordinate of right end of bottom of trapezoid. |
|
protectedvirtual |
Gets the current alpha for the specified part.
part | The part to get the alpha for. |
Gets the current rendering color for the specified part.
part | The part to get the color for. |
nullptr
if it hasn't been set and should be inherited from the environment. Glib::RefPtr< Layout > Pango::Renderer::get_layout | ( | ) |
Gets the layout currently being rendered using renderer.
Calling this function only makes sense from inside a subclass's methods, like in its draw_shape vfunc, for example.
The returned layout should not be modified while still being rendered.
nullptr
if no layout is being rendered using renderer at this time. Gets the layout currently being rendered using renderer.
Calling this function only makes sense from inside a subclass's methods, like in its draw_shape vfunc, for example.
The returned layout should not be modified while still being rendered.
nullptr
if no layout is being rendered using renderer at this time. Glib::RefPtr< LayoutLine > Pango::Renderer::get_layout_line | ( | ) |
Gets the layout line currently being rendered using renderer.
Calling this function only makes sense from inside a subclass's methods, like in its draw_shape vfunc, for example.
The returned layout line should not be modified while still being rendered.
nullptr
if no layout line is being rendered using renderer at this time. Glib::RefPtr< const LayoutLine > Pango::Renderer::get_layout_line | ( | ) | const |
Gets the layout line currently being rendered using renderer.
Calling this function only makes sense from inside a subclass's methods, like in its draw_shape vfunc, for example.
The returned layout line should not be modified while still being rendered.
nullptr
if no layout line is being rendered using renderer at this time. Matrix Pango::Renderer::get_matrix | ( | ) | const |
Gets the transformation matrix that will be applied when rendering.
See set_matrix().
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
PangoRenderer * Pango::Renderer::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Informs Pango that the way that the rendering is done for part has changed.
This should be called if the rendering changes in a way that would prevent multiple pieces being joined together into one drawing call. For instance, if a subclass of Pango::Renderer
was to add a stipple option for drawing underlines, it needs to call
When the stipple changes or underlines with different stipples might be joined together. Pango automatically calls this for changes to colors. (See set_color())
part | The part for which rendering has changed. |
Sets the alpha for part of the rendering.
Note that the alpha may only be used if a color is specified for part as well.
part | The part to set the alpha for. |
alpha | An alpha value between 1 and 65536, or 0 to unset the alpha. |
Sets the color for part of the rendering.
Also see set_alpha().
part | The part to change the color of. |
color | The new color or nullptr to unset the current color. |
Sets the transformation matrix that will be applied when rendering.
matrix | A Pango::Matrix , or nullptr to unset any existing matrix (No matrix set is the same as setting the identity matrix.). |
|
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. |