pango-Cairo-Rendering         package:RGtk2         R Documentation

_C_a_i_r_o _R_e_n_d_e_r_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     Rendering with the Cairo backend

_M_e_t_h_o_d_s _a_n_d _F_u_n_c_t_i_o_n_s:

     'pangoCairoFontMapGetDefault()'
      'pangoCairoFontMapNew()'
      'pangoCairoFontMapNewForFontType(fonttype)'
      'pangoCairoFontMapGetFontType(object)'
      'pangoCairoFontMapSetResolution(object, dpi)'
      'pangoCairoFontMapGetResolution(object)'
      'pangoCairoFontMapCreateContext(object)'
      'pangoCairoFontGetScaledFont(object)'
      'pangoCairoContextSetResolution(context, dpi)'
      'pangoCairoContextGetResolution(context)'
      'pangoCairoContextSetFontOptions(context, options)'
      'pangoCairoContextGetFontOptions(context)'
      'pangoCairoContextSetShapeRenderer(object, func, data)'
      'pangoCairoContextGetShapeRenderer(object)'
      'pangoCairoUpdateContext(cr, context)'
      'pangoCairoCreateLayout(cr)'
      'pangoCairoUpdateLayout(cr, layout)'
      'pangoCairoShowGlyphString(cr, font, glyphs)'
      'pangoCairoShowLayoutLine(cr, line)'
      'pangoCairoShowLayout(cr, layout)'
      'pangoCairoShowErrorUnderline(cr, x, y, width, height)'
      'pangoCairoGlyphStringPath(cr, font, glyphs)'
      'pangoCairoLayoutLinePath(cr, line)'
      'pangoCairoLayoutPath(cr, layout)'
      'pangoCairoErrorUnderlinePath(cr, x, y, width, height)'

_H_i_e_r_a_r_c_h_y:

     GInterface
        +----PangoCairoFontMap 

_D_e_t_a_i_l_e_d _D_e_s_c_r_i_p_t_i_o_n:

     The Cairo library (<URL: http://cairographics.org>) is a vector
     graphics library with a powerful rendering model. It has such
     features as anti-aliased primitives, alpha-compositing, and
     gradients. Multiple backends for Cairo are available, to allow
     rendering to images, to PDF files, and to the screen on X and on
     other windowing systems. The functions in this section allow using
     Pango to render to Cairo surfaces.

     Using Pango with Cairo is straightforward. A 'PangoContext'
     created with 'pangoCairoFontMapCreateContext' can be used on any
     Cairo context (cairo_t), but needs to be updated to match the
     current transformation matrix and target surface of the Cairo
     context using 'pangoCairoUpdateContext'. The convenience functions
     'pangoCairoCreateLayout' and 'pangoCairoUpdateLayout' handle the
     common case where the program doesn't need to manipulate the
     properties of the 'PangoContext'.

     When you get the metrics of a layout or of a piece of a layout
     using functions such as 'pangoLayoutGetExtents', the reported
     metrics are in user-space coordinates. If a piece of text is 10
     units long, and you call cairo_scale (cr, 2.0), it still is
     more-or-less 10 units long. However, the results will be affected
     by hinting (that is, the process of adjusting the text to look
     good on the pixel grid), so you shouldn't assume they are
     completely independent of the current transformation matrix. Note
     that the basic metrics functions in Pango report results in
     integer Pango units. To get to the floating point units used in
     Cairo divide by 'PANGO_SCALE'.

     _Using Pango with Cairo_


     RADIUS <- 150
     N.WORDS <- 10
     FONT <- "Sans Bold 27"

     draw.text <- function(widget, event, data)
     {
       width <- widget[["allocation"]][["width"]]
       height <- widget[["allocation"]][["height"]]

       device.radius <- min(width, height) / 2.

       cr <- gdkCairoCreate(widget[["window"]])

       ## Center coordinates on the middle of the region we are drawing
       cr$translate(device.radius + (width - 2 * device.radius) / 2,
                    device.radius + (height - 2 * device.radius) / 2)
       cr$scale(device.radius / RADIUS, device.radius / RADIUS)

       ## Create a PangoLayout, set the font and text
       layout <- pangoCairoCreateLayout(cr)

       layout$setText("Text")
       desc <- pangoFontDescriptionFromString(FONT)
       layout$setFontDescription(desc)

       ## Draw the layout N.WORDS times in a circle
       for (i in 1:N.WORDS) {
         angle <- (360 * i) / N.WORDS

         cr$save()

         ## Gradient from red at angle 60 to blue at angle 300
         red <- (1 + cos((angle - 60) * pi / 180)) / 2
         cr$setSourceRgb(red, 0, 1.0 - red)

         cr$rotate(angle * pi / 180)

         ## Inform Pango to re-layout the text with the new
     transformation
         pangoCairoUpdateLayout(cr, layout)

         size <- layout$getSize()
         cr$moveTo(- (size$width / .PangoScale) / 2, - RADIUS)
         pangoCairoShowLayout(cr, layout)

         cr$restore()
       }
       return(FALSE)
     }

     white <- c( 0, "0xffff", "0xffff", "0xffff" )

     window <- gtkWindow("toplevel", show = F)
     window$setTitle("Rotated Text")
     drawing.area <- gtkDrawingArea()
     window$add(drawing.area)

     # This overrides the background color from the theme
     drawing.area$modifyBg("normal", white)

     gSignalConnect(drawing.area, "expose-event", draw.text)

     window$showAll()


_S_t_r_u_c_t_u_r_e_s:


     '_P_a_n_g_o_C_a_i_r_o_F_o_n_t' 'PangoCairoFont' is an interface exported by
          fonts for use with Cairo. The actual type of the font will
          depend on the particular font technology Cairo was compiled
          to use.  

          Since  1.18


     '_P_a_n_g_o_C_a_i_r_o_F_o_n_t_M_a_p' 'PangoCairoFontMap' is an interface exported
          by font maps for use with Cairo. The actual type of the font
          map will depend on the particular font technology Cairo was
          compiled to use.  

          Since  1.10


_U_s_e_r _F_u_n_c_t_i_o_n_s:


     '_P_a_n_g_o_C_a_i_r_o_S_h_a_p_e_R_e_n_d_e_r_e_r_F_u_n_c(_c_r, _a_t_t_r, _d_o._p_a_t_h, _d_a_t_a)' Function
          type for rendering attributes of type 'PANGO_ATTR_SHAPE' with
          Pango's Cairo renderer.

          '_c_r' ['Cairo'] a Cairo context with current point set to
               where the shape should be rendered

          '_a_t_t_r' ['PangoAttrShape'] the 'PANGO_ATTR_SHAPE' to render

          '_d_o._p_a_t_h' [logical] whether only the shape path should be
               appended to current path of 'cr' and no filling/stroking
               done.  This will be set to 'TRUE' when called from
               'pangoCairoLayoutPath' and 'pangoCairoLayoutLinePath'
               rendering functions.

          '_d_a_t_a' [R object] user data passed to
               'pangoCairoContextSetShapeRenderer'


_A_u_t_h_o_r(_s):

     Derived by RGtkGen from GTK+ documentation

_R_e_f_e_r_e_n_c_e_s:

     <URL:
     http://developer.gnome.org/doc/API/2.0/pango/pango-Cairo-Rendering.html>

