pangomm: Pango::Renderer Class Reference

Pango::Renderer is a base class that contains the necessary logic for rendering a Pango::Layout or Pango::LayoutLine. More...

#include <pangomm/renderer.h>

Inheritance diagram for Pango::Renderer:

Public Types

enum  Part {

  Part::FOREGROUND,

  Part::BACKGROUND,

  Part::UNDERLINE,

  Part::STRIKETHROUGH,

  Part::OVERLINE

}
 Pango::RenderPart defines different items to render for such purposes as setting colors. More...

 
- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 
- Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify func_destroy_notify
 

Public Member Functions

 Renderer (Renderer&& src) noexcept
 
Rendereroperator= (Renderer&& src) noexcept
 
 ~Renderer () noexcept override
 
PangoRenderer* gobj ()
 Provides access to the underlying C GObject. More...

 
const PangoRenderer* gobj () const
 Provides access to the underlying C GObject. More...

 
PangoRenderer* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...

 
void draw_layout (const Glib::RefPtr< Layout >& layout, int x, int y)
 Draws layout with the specified Pango::Renderer. More...

 
void draw_layout_line (const Glib::RefPtr< LayoutLine >& line, int x, int y)
 Draws line with the specified Pango::Renderer. More...

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

 
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 (PDF for example). More...

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

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

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

 
void draw_glyph (const Glib::RefPtr< Font >& font, Glyph glyph, double x, double y)
 Draws a single glyph with coordinates in device space. More...

 
void activate ()
 Does initial setup before rendering operations on renderer. More...

 
void deactivate ()
 Cleans up after rendering operations on renderer. More...

 
void part_changed (Part part)
 Informs Pango that the way that the rendering is done for part has changed in a way that would prevent multiple pieces being joined together into one drawing call. More...

 
void set_color (Part part, const Color& color)
 Sets the color for part of the rendering. More...

 
Color get_color (Part part) const
 Gets the current rendering color for the specified part. More...

 
void set_alpha (Part part, guint16 alpha)
 Sets the alpha for part of the rendering. More...

 
guint16 get_alpha (Part part) const
 Gets the current alpha for the specified part. More...

 
void set_matrix (const Matrix& matrix)
 Sets the transformation matrix that will be applied when rendering. More...

 
Matrix get_matrix () const
 Gets the transformation matrix that will be applied when rendering. More...

 
Glib::RefPtr< Layoutget_layout ()
 Gets the layout currently being rendered using renderer. More...

 
Glib::RefPtr< const Layoutget_layout () const
 Gets the layout currently being rendered using renderer. More...

 
Glib::RefPtr< LayoutLineget_layout_line ()
 Gets the layout line currently being rendered using renderer. More...

 
Glib::RefPtr< const LayoutLineget_layout_line () const
 Gets the layout line currently being rendered using renderer. More...

 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src) noexcept
 
 ~trackable ()
 
void add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src) noexcept
 
void remove_destroy_notify_callback (notifiable *data) const
 

Static Public Member Functions

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

 

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)
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Pango::Rendererwrap (PangoRenderer* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...

 

Detailed Description

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.

Constructor & Destructor Documentation

Pango::Renderer::Renderer ( Renderer&&  src)
noexcept
Pango::Renderer::~Renderer ( )
overridenoexcept

Member Function Documentation

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.

Since pangomm 1.8:
virtual void Pango::Renderer::begin_vfunc ( )
protectedvirtual
void Pango::Renderer::deactivate ( )

Cleans up after rendering operations on renderer.

See docs for activate().

Since pangomm 1.8:
void Pango::Renderer::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.

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

Since pangomm 1.8:
Parameters
xX coordinate of underline, in Pango units in user coordinate system.
yY coordinate of underline, in Pango units in user coordinate system.
widthWidth of underline, in Pango units in user coordinate system.
heightHeight of underline, in Pango units in user coordinate system.
virtual void Pango::Renderer::draw_error_underline_vfunc ( int  x,
int  y,
int  width,
int  height 
)
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.

Since pangomm 1.8:
Parameters
fontA Pango::Font.
glyphThe glyph index of a single glyph.
xX coordinate of left edge of baseline of glyph.
yY 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 (PDF for example).

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

Since pangomm 1.22:
Parameters
textThe UTF-8 text that glyph_item refers to, or nullptr.
glyph_itemA Pango::GlyphItem.
xX position of left edge of baseline, in user space coordinates in Pango units.
yY position of left edge of baseline, in user space coordinates in Pango units.
virtual void Pango::Renderer::draw_glyph_item_vfunc ( const Glib::ustring text,
const GlyphItem glyph_item,
int  x,
int  y 
)
protectedvirtual
virtual void Pango::Renderer::draw_glyph_vfunc ( const Glib::RefPtr< Font >&  font,
Glyph  glyph,
double  x,
double  y 
)
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.

Since pangomm 1.8:
Parameters
fontA Pango::Font.
glyphsA Pango::GlyphString.
xX position of left edge of baseline, in user space coordinates in Pango units.
yY position of left edge of baseline, in user space coordinates in Pango units.
virtual void Pango::Renderer::draw_glyphs_vfunc ( const Glib::RefPtr< Font >&  font,
const GlyphString glyphs,
int  x,
int  y 
)
protectedvirtual
void Pango::Renderer::draw_layout ( const Glib::RefPtr< Layout >&  layout,
int  x,
int  y 
)

Draws layout with the specified Pango::Renderer.

Since pangomm 1.8:
Parameters
layoutA Pango::Layout.
xX position of left edge of baseline, in user space coordinates in Pango units.
yY 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.

Since pangomm 1.8:
Parameters
lineA Pango::LayoutLine.
xX position of left edge of baseline, in user space coordinates in Pango units.
yY position of left edge of baseline, in user space coordinates in Pango units.
void Pango::Renderer::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.

This should be called while renderer is already active. Use activate() to activate a renderer.

Since pangomm 1.8:
Parameters
partType of object this rectangle is part of.
xX position at which to draw rectangle, in user space coordinates in Pango units.
yY position at which to draw rectangle, in user space coordinates in Pango units.
widthWidth of rectangle in Pango units in user space coordinates.
heightHeight of rectangle in Pango units in user space coordinates.
virtual void Pango::Renderer::draw_rectangle_vfunc ( Part  part,
int  x,
int  y,
int  width,
int  height 
)
protectedvirtual
virtual void Pango::Renderer::draw_shape_vfunc ( const AttrShape attr,
int  x,
int  y 
)
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.

Since pangomm 1.8:
Parameters
partType of object this trapezoid is part of.
y1Y coordinate of top of trapezoid.
x11X coordinate of left end of top of trapezoid.
x21X coordinate of right end of top of trapezoid.
y2Y coordinate of bottom of trapezoid.
x12X coordinate of left end of bottom of trapezoid.
x22X coordinate of right end of bottom of trapezoid.
virtual void Pango::Renderer::draw_trapezoid_vfunc ( Part  part,
double  y1,
double  x11,
double  x21,
double  y2,
double  x12,
double  x22 
)
protectedvirtual
virtual void Pango::Renderer::end_vfunc ( )
protectedvirtual
guint16 Pango::Renderer::get_alpha ( Part  part) const

Gets the current alpha for the specified part.

Since pangomm 1.38:
Parameters
partThe part to get the alpha for.
Returns
The alpha for the specified part, or 0 if it hasn't been set and should be inherited from the environment.
Color Pango::Renderer::get_color ( Part  part) const

Gets the current rendering color for the specified part.

Since pangomm 1.8:
Parameters
partThe part to get the color for.
Returns
The color for the specified part, or 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.

Since pangomm 1.20:
Returns
The layout, or nullptr if no layout is being rendered using renderer at this time.
Glib::RefPtr<const Layout> Pango::Renderer::get_layout ( ) const

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.

Since pangomm 1.20:
Returns
The layout, or 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.

Since pangomm 1.20:
Returns
The layout line, or 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.

Since pangomm 1.20:
Returns
The layout line, or 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().

Returns
The matrix. If no matrix has been set, an identity matrix is returned.
static GType Pango::Renderer::get_type ( )
static

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

PangoRenderer* Pango::Renderer::gobj ( )
inline

Provides access to the underlying C GObject.

const PangoRenderer* Pango::Renderer::gobj ( ) const
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.

Renderer& Pango::Renderer::operator= ( Renderer&&  src)
noexcept
void Pango::Renderer::part_changed ( Part  part)

Informs Pango that the way that the rendering is done for part has changed 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

[C example ellipted]

When the stipple changes or underlines with different stipples might be joined together. Pango automatically calls this for changes to colors. (See set_color())

Since pangomm 1.8:
Parameters
partThe part for which rendering has changed.
virtual void Pango::Renderer::part_changed_vfunc ( Part  part)
protectedvirtual
virtual void Pango::Renderer::prepare_run_vfunc ( const GlyphItem run)
protectedvirtual
void Pango::Renderer::set_alpha ( Part  part,
guint16  alpha 
)

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.

Since pangomm 1.38:
Parameters
partThe part to set the alpha for.
alphaAn alpha value between 1 and 65536, or 0 to unset the alpha.
void Pango::Renderer::set_color ( Part  part,
const Color color 
)

Sets the color for part of the rendering.

Also see set_alpha().

Since pangomm 1.8:
Parameters
partThe part to change the color of.
colorThe new color or nullptr to unset the current color.
void Pango::Renderer::set_matrix ( const Matrix matrix)

Sets the transformation matrix that will be applied when rendering.

Since pangomm 1.8:
Parameters
matrixA Pango::Matrix, or nullptr to unset any existing matrix. (No matrix set is the same as setting the identity matrix.).

Friends And Related Function Documentation

Glib::RefPtr< Pango::Renderer > wrap ( PangoRenderer *  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.