⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pangocairo-render.c

📁 GTK+-2.0源码之pango-1.15.6.tar.gz
💻 C
📖 第 1 页 / 共 2 页
字号:
					   int            width,					   int            height){  PangoCairoRenderer *crenderer = (PangoCairoRenderer *) (renderer);  cairo_t *cr = crenderer->cr;  if (!crenderer->do_path)    {      cairo_save (cr);      set_color (crenderer, PANGO_RENDER_PART_UNDERLINE);      cairo_new_path (cr);    }  draw_error_underline (cr,			crenderer->x_offset + (double)x / PANGO_SCALE,			crenderer->y_offset + (double)y / PANGO_SCALE,			(double)width / PANGO_SCALE, (double)height / PANGO_SCALE);  if (!crenderer->do_path)    {      cairo_fill (cr);      cairo_restore (cr);    }}static voidpango_cairo_renderer_init (PangoCairoRenderer *renderer){}static voidpango_cairo_renderer_class_init (PangoCairoRendererClass *klass){  PangoRendererClass *renderer_class = PANGO_RENDERER_CLASS (klass);  renderer_class->draw_glyphs = pango_cairo_renderer_draw_glyphs;  renderer_class->draw_rectangle = pango_cairo_renderer_draw_rectangle;  renderer_class->draw_error_underline = pango_cairo_renderer_draw_error_underline;}static PangoCairoRenderer *cached_renderer = NULL;G_LOCK_DEFINE_STATIC (cached_renderer);static PangoCairoRenderer *acquire_renderer (gboolean *free_renderer){  PangoCairoRenderer *renderer;  /* renderer = _pango_cairo_font_map_get_renderer (PANGO_CAIRO_FONT_MAP (fontmap)); */  if (G_LIKELY (G_TRYLOCK (cached_renderer)))    {      if (G_UNLIKELY (!cached_renderer))	cached_renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL);      renderer = cached_renderer;      *free_renderer = FALSE;    }  else    {      renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL);      *free_renderer = TRUE;    }  return renderer;}static voidrelease_renderer (PangoCairoRenderer *renderer, gboolean free_renderer){  if (G_LIKELY (!free_renderer))    {      renderer->cr = NULL;      renderer->do_path = FALSE;      renderer->x_offset = 0.;      renderer->y_offset = 0.;      G_UNLOCK (cached_renderer);    }  else    g_object_unref (renderer);}/* convenience wrappers using the default renderer */static void_pango_cairo_do_glyph_string (cairo_t          *cr,			      PangoFont        *font,			      PangoGlyphString *glyphs,			      gboolean          do_path){  gboolean free_renderer;  PangoCairoRenderer *crenderer = acquire_renderer (&free_renderer);  PangoRenderer *renderer = (PangoRenderer *) crenderer;  crenderer->cr = cr;  crenderer->do_path = do_path;  cairo_get_current_point (cr, &crenderer->x_offset, &crenderer->y_offset);  if (!do_path)    {      /* unset all part colors, since when drawing just a glyph string,       * prepare_run() isn't called.       */      pango_renderer_activate (renderer);      pango_renderer_set_color (renderer, PANGO_RENDER_PART_FOREGROUND, NULL);      pango_renderer_set_color (renderer, PANGO_RENDER_PART_BACKGROUND, NULL);      pango_renderer_set_color (renderer, PANGO_RENDER_PART_UNDERLINE, NULL);      pango_renderer_set_color (renderer, PANGO_RENDER_PART_STRIKETHROUGH, NULL);    }  pango_renderer_draw_glyphs (renderer, font, glyphs, 0, 0);  if (!do_path)    {      pango_renderer_deactivate (renderer);    }  release_renderer (crenderer, free_renderer);}static void_pango_cairo_do_layout_line (cairo_t          *cr,			     PangoLayoutLine  *line,			     gboolean          do_path){  gboolean free_renderer;  PangoCairoRenderer *crenderer = acquire_renderer (&free_renderer);  PangoRenderer *renderer = (PangoRenderer *) crenderer;  crenderer->cr = cr;  crenderer->do_path = do_path;  cairo_get_current_point (cr, &crenderer->x_offset, &crenderer->y_offset);  pango_renderer_draw_layout_line (renderer, line, 0, 0);  release_renderer (crenderer, free_renderer);}static void_pango_cairo_do_layout (cairo_t     *cr,			PangoLayout *layout,			gboolean     do_path){  gboolean free_renderer;  PangoCairoRenderer *crenderer = acquire_renderer (&free_renderer);  PangoRenderer *renderer = (PangoRenderer *) crenderer;  crenderer->cr = cr;  crenderer->do_path = do_path;  cairo_get_current_point (cr, &crenderer->x_offset, &crenderer->y_offset);  pango_renderer_draw_layout (renderer, layout, 0, 0);  release_renderer (crenderer, free_renderer);}static void_pango_cairo_do_error_underline (cairo_t *cr,				 double   x,				 double   y,				 double   width,				 double   height,				 gboolean do_path){  /* We don't use a renderer here, for a simple reason:   * the only renderer we can get is the default renderer, that   * is all implemented here, so we shortcircuit and make our   * life way easier.   */  if (!do_path)    cairo_new_path (cr);  draw_error_underline (cr, x, y, width, height);  if (!do_path)    cairo_fill (cr);}/* public wrapper of above to show or append path *//** * pango_cairo_show_glyph_string: * @cr: a Cairo context * @font: a #PangoFont * @glyphs: a #PangoGlyphString * * Draws the glyphs in @glyphs in the specified cairo context. * The origin of the glyphs (the left edge of the baseline) will * be drawn at the current point of the cairo context. * * Since: 1.10 **/voidpango_cairo_show_glyph_string (cairo_t          *cr,			       PangoFont        *font,			       PangoGlyphString *glyphs){  g_return_if_fail (cr != NULL);  g_return_if_fail (glyphs != NULL);  _pango_cairo_do_glyph_string (cr, font, glyphs, FALSE);}/** * pango_cairo_show_layout_line: * @cr: a Cairo context * @line: a #PangoLayoutLine * * Draws a #PangoLayoutLine in the specified cairo context. * The origin of the glyphs (the left edge of the line) will * be drawn at the current point of the cairo context. * * Since: 1.10 **/voidpango_cairo_show_layout_line (cairo_t          *cr,			      PangoLayoutLine  *line){  g_return_if_fail (cr != NULL);  g_return_if_fail (line != NULL);  _pango_cairo_do_layout_line (cr, line, FALSE);}/** * pango_cairo_show_layout: * @cr: a Cairo context * @layout: a Pango layout * * Draws a #PangoLayoutLine in the specified cairo context. * The top-left corner of the #PangoLayout will be drawn * at the current point of the cairo context. * * Since: 1.10 **/voidpango_cairo_show_layout (cairo_t     *cr,			 PangoLayout *layout){  g_return_if_fail (cr != NULL);  g_return_if_fail (PANGO_IS_LAYOUT (layout));  _pango_cairo_do_layout (cr, layout, FALSE);}/** * pango_cairo_show_error_underline: * @cr: a Cairo context * @x: The X coordinate of one corner of the rectangle * @y: The Y coordinate of one corner of the rectangle * @width: Non-negative width of the rectangle * @height: Non-negative height of the rectangle * * Draw a squiggly line in the specified cairo context 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) * * Since: 1.14 **/voidpango_cairo_show_error_underline (cairo_t *cr,				  double  x,				  double  y,				  double  width,				  double  height){  g_return_if_fail (cr != NULL);  g_return_if_fail ((width >= 0) && (height >= 0));  _pango_cairo_do_error_underline (cr, x, y, width, height, FALSE);}/** * pango_cairo_glyph_string_path * @cr: a Cairo context * @font: a #PangoFont * @glyphs: a #PangoGlyphString * * Adds the glyphs in @glyphs to the current path in the specified * cairo context. The origin of the glyphs (the left edge of the baseline) * will be at the current point of the cairo context. * * Since: 1.10 **/voidpango_cairo_glyph_string_path (cairo_t          *cr,			       PangoFont        *font,			       PangoGlyphString *glyphs){  g_return_if_fail (cr != NULL);  g_return_if_fail (glyphs != NULL);  _pango_cairo_do_glyph_string (cr, font, glyphs, TRUE);}/** * pango_cairo_layout_line_path: * @cr: a Cairo context * @line: a #PangoLayoutLine * * Adds the text in #PangoLayoutLine to the current path in the * specified cairo context.  The origin of the glyphs (the left edge * of the line) will be at the current point of the cairo context. * * Since: 1.10 **/voidpango_cairo_layout_line_path (cairo_t          *cr,			      PangoLayoutLine  *line){  g_return_if_fail (cr != NULL);  g_return_if_fail (line != NULL);  _pango_cairo_do_layout_line (cr, line, TRUE);}/** * pango_cairo_layout_path: * @cr: a Cairo context * @layout: a Pango layout * * Adds the text in a #PangoLayout to the current path in the * specified cairo context.  The top-left corner of the #PangoLayout * will be at the current point of the cairo context. * * Since: 1.10 **/voidpango_cairo_layout_path (cairo_t     *cr,			 PangoLayout *layout){  g_return_if_fail (cr != NULL);  g_return_if_fail (PANGO_IS_LAYOUT (layout));  _pango_cairo_do_layout (cr, layout, TRUE);}/** * pango_cairo_error_underline_path: * @cr: a Cairo context * @x: The X coordinate of one corner of the rectangle * @y: The Y coordinate of one corner of the rectangle * @width: Non-negative width of the rectangle * @height: Non-negative height of the rectangle * * Add a squiggly line to the current path in the specified cairo context 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) * * Since: 1.14 **/voidpango_cairo_error_underline_path (cairo_t *cr,				  double   x,				  double   y,				  double   width,				  double   height){  g_return_if_fail (cr != NULL);  g_return_if_fail ((width >= 0) && (height >= 0));  _pango_cairo_do_error_underline (cr, x, y, width, height, TRUE);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -