📄 pangoxft-render.c
字号:
} x_off += gi->geometry.width; }}static voidflush_trapezoids (PangoXftRenderer *xftrenderer){ if (!xftrenderer->priv->trapezoids || xftrenderer->priv->trapezoids->len == 0) return; PANGO_XFT_RENDERER_GET_CLASS (xftrenderer)->composite_trapezoids (xftrenderer, xftrenderer->priv->trapezoid_part, (XTrapezoid *)xftrenderer->priv->trapezoids->data, xftrenderer->priv->trapezoids->len); g_array_set_size (xftrenderer->priv->trapezoids, 0);}static voidpango_xft_renderer_draw_trapezoid (PangoRenderer *renderer, PangoRenderPart part, double y1, double x11, double x21, double y2, double x12, double x22){ PangoXftRenderer *xftrenderer = PANGO_XFT_RENDERER (renderer); XTrapezoid trap; flush_glyphs (xftrenderer); if (!xftrenderer->priv->trapezoids) xftrenderer->priv->trapezoids = g_array_new (FALSE, FALSE, sizeof (XTrapezoid)); if (xftrenderer->draw) { if (xftrenderer->priv->trapezoids->len > 0 && xftrenderer->priv->trapezoid_part != part) flush_trapezoids (xftrenderer); xftrenderer->priv->trapezoid_part = part; } trap.top = XDoubleToFixed (y1); trap.bottom = XDoubleToFixed (y2); trap.left.p1.x = XDoubleToFixed (x11); trap.left.p1.y = XDoubleToFixed (y1); trap.left.p2.x = XDoubleToFixed (x12); trap.left.p2.y = XDoubleToFixed (y2); trap.right.p1.x = XDoubleToFixed (x21); trap.right.p1.y = XDoubleToFixed (y1); trap.right.p2.x = XDoubleToFixed (x22); trap.right.p2.y = XDoubleToFixed (y2); g_array_append_val (xftrenderer->priv->trapezoids, trap);}static voidpango_xft_renderer_part_changed (PangoRenderer *renderer, PangoRenderPart part){ PangoXftRenderer *xftrenderer = PANGO_XFT_RENDERER (renderer); if (part == PANGO_RENDER_PART_FOREGROUND) flush_glyphs (xftrenderer); if (part == xftrenderer->priv->trapezoid_part) flush_trapezoids (xftrenderer);}static voidpango_xft_renderer_end (PangoRenderer *renderer){ PangoXftRenderer *xftrenderer = PANGO_XFT_RENDERER (renderer); flush_glyphs (xftrenderer); flush_trapezoids (xftrenderer);}static voidpango_xft_renderer_real_composite_trapezoids (PangoXftRenderer *xftrenderer, PangoRenderPart part, XTrapezoid *trapezoids, int n_trapezoids){ Picture src_picture; Picture dest_picture; if (!XftDefaultHasRender (xftrenderer->display)) return; if (xftrenderer->priv->src_picture != None) { src_picture = xftrenderer->priv->src_picture; dest_picture = xftrenderer->priv->dest_picture; } else { XftColor xft_color; PangoColor *color = pango_renderer_get_color (PANGO_RENDERER (xftrenderer), part); if (!color) color = &xftrenderer->priv->default_color; xft_color.color.red = color->red; xft_color.color.green = color->green; xft_color.color.blue = color->blue; xft_color.color.alpha = xftrenderer->priv->alpha; src_picture = XftDrawSrcPicture (xftrenderer->draw, &xft_color); dest_picture = XftDrawPicture (xftrenderer->draw); } XRenderCompositeTrapezoids (xftrenderer->display, PictOpOver, src_picture, dest_picture, xftrenderer->priv->mask_format, 0, 0, trapezoids, n_trapezoids);}static voidpango_xft_renderer_real_composite_glyphs (PangoXftRenderer *xftrenderer, XftFont *xft_font, XftGlyphSpec *glyphs, int n_glyphs){ if (xftrenderer->priv->src_picture != None) { XftGlyphSpecRender (xftrenderer->display, PictOpOver, xftrenderer->priv->src_picture, xft_font, xftrenderer->priv->dest_picture, 0, 0, glyphs, n_glyphs); } else { XftColor xft_color; PangoColor *color = pango_renderer_get_color (PANGO_RENDERER (xftrenderer), PANGO_RENDER_PART_FOREGROUND); if (!color) color = &xftrenderer->priv->default_color; xft_color.color.red = color->red; xft_color.color.green = color->green; xft_color.color.blue = color->blue; xft_color.color.alpha = xftrenderer->priv->alpha; XftDrawGlyphSpec (xftrenderer->draw, &xft_color, xft_font, glyphs, n_glyphs); }}static PangoRenderer *get_renderer (PangoFontMap *fontmap, XftDraw *draw, XftColor *color){ PangoRenderer *renderer; PangoXftRenderer *xftrenderer; PangoColor pango_color; renderer = _pango_xft_font_map_get_renderer (PANGO_XFT_FONT_MAP (fontmap)); xftrenderer = PANGO_XFT_RENDERER (renderer); pango_xft_renderer_set_draw (xftrenderer, draw); pango_color.red = color->color.red; pango_color.green = color->color.green; pango_color.blue = color->color.blue; pango_xft_renderer_set_default_color (xftrenderer, &pango_color); xftrenderer->priv->alpha = color->color.alpha; return renderer;}static voidrelease_renderer (PangoRenderer *renderer){ PangoXftRenderer *xftrenderer = PANGO_XFT_RENDERER (renderer); xftrenderer->priv->alpha = 0xffff;}/** * pango_xft_render_layout: * @draw: an #XftDraw * @color: the foreground color in which to draw the layout * (may be overridden by color attributes) * @layout: a #PangoLayout * @x: the X position of the left of the layout (in Pango units) * @y: the Y position of the top of the layout (in Pango units) * * Render a #PangoLayout onto a #XftDraw * * Since: 1.8 */voidpango_xft_render_layout (XftDraw *draw, XftColor *color, PangoLayout *layout, int x, int y){ PangoContext *context; PangoFontMap *fontmap; PangoRenderer *renderer; g_return_if_fail (draw != NULL); g_return_if_fail (color != NULL); g_return_if_fail (PANGO_IS_LAYOUT (layout)); context = pango_layout_get_context (layout); fontmap = pango_context_get_font_map (context); renderer = get_renderer (fontmap, draw, color); pango_renderer_draw_layout (renderer, layout, x, y); release_renderer (renderer);}/** * pango_xft_render_layout_line: * @draw: an #XftDraw * @color: the foreground color in which to draw the layout line * (may be overridden by color attributes) * @line: a #PangoLayoutLine * @x: the x position of start of string (in Pango units) * @y: the y position of baseline (in Pango units) * * Render a #PangoLayoutLine onto a #XftDraw * * Since: 1.8 */voidpango_xft_render_layout_line (XftDraw *draw, XftColor *color, PangoLayoutLine *line, int x, int y){ PangoContext *context; PangoFontMap *fontmap; PangoRenderer *renderer; g_return_if_fail (draw != NULL); g_return_if_fail (color != NULL); g_return_if_fail (line != NULL); context = pango_layout_get_context (line->layout); fontmap = pango_context_get_font_map (context); renderer = get_renderer (fontmap, draw, color); pango_renderer_draw_layout_line (renderer, line, x, y); release_renderer (renderer);}/** * pango_xft_render_transformed: * @draw: an #XftDraw * @color: the color in which to draw the glyphs * @font: the font in which to draw the string * @matrix: a #PangoMatrix, or %NULL to use an identity transformation * @glyphs: the glyph string to draw * @x: the x position of the start of the string (in Pango * units in user space coordinates) * @y: the y position of the baseline (in Pango units * in user space coordinates) * * Renders a #PangoGlyphString onto a #XftDraw, possibly * transforming the layed-out coordinates through a transformation * matrix. Note that the transformation matrix for @font is not * changed, so to produce correct rendering results, the @font * must have been loaded using a #PangoContext with an identical * transformation matrix to that passed in to this function. * * Since: 1.8 **/voidpango_xft_render_transformed (XftDraw *draw, XftColor *color, PangoMatrix *matrix, PangoFont *font, PangoGlyphString *glyphs, int x, int y){ PangoFontMap *fontmap; PangoRenderer *renderer; g_return_if_fail (draw != NULL); g_return_if_fail (color != NULL); g_return_if_fail (PANGO_XFT_IS_FONT (font)); g_return_if_fail (glyphs != NULL); fontmap = PANGO_FC_FONT (font)->fontmap; renderer = get_renderer (fontmap, draw, color); pango_renderer_set_matrix (renderer, matrix); pango_renderer_draw_glyphs (renderer, font, glyphs, x, y); release_renderer (renderer);}/** * pango_xft_render: * @draw: the <type>XftDraw</type> object. * @color: the color in which to draw the string * @font: the font in which to draw the string * @glyphs: the glyph string to draw * @x: the x position of start of string (in pixels) * @y: the y position of baseline (in pixels) * * Renders a #PangoGlyphString onto an <type>XftDraw</type> object wrapping an X drawable. */voidpango_xft_render (XftDraw *draw, XftColor *color, PangoFont *font, PangoGlyphString *glyphs, gint x, gint y){ g_return_if_fail (draw != NULL); g_return_if_fail (color != NULL); g_return_if_fail (PANGO_XFT_IS_FONT (font)); g_return_if_fail (glyphs != NULL); pango_xft_render_transformed (draw, color, NULL, font, glyphs, x * PANGO_SCALE, y * PANGO_SCALE);}/** * pango_xft_picture_render: * @display: an X display * @src_picture: the source picture to draw the string with * @dest_picture: the destination picture to draw the string onto * @font: the font in which to draw the string * @glyphs: the glyph string to draw * @x: the x position of start of string (in pixels) * @y: the y position of baseline (in pixels) * * Renders a #PangoGlyphString onto an Xrender <type>Picture</type> object. */voidpango_xft_picture_render (Display *display, Picture src_picture, Picture dest_picture, PangoFont *font, PangoGlyphString *glyphs, gint x, gint y){ PangoFontMap *fontmap; PangoRenderer *renderer; g_return_if_fail (display != NULL); g_return_if_fail (src_picture != None); g_return_if_fail (dest_picture != None); g_return_if_fail (PANGO_XFT_IS_FONT (font)); g_return_if_fail (glyphs != NULL); fontmap = PANGO_FC_FONT (font)->fontmap; renderer = _pango_xft_font_map_get_renderer (PANGO_XFT_FONT_MAP (fontmap)); pango_xft_renderer_set_pictures (PANGO_XFT_RENDERER (renderer), src_picture, dest_picture); pango_renderer_set_matrix (renderer, NULL); pango_renderer_draw_glyphs (renderer, font, glyphs, x * PANGO_SCALE, y * PANGO_SCALE); pango_xft_renderer_set_pictures (PANGO_XFT_RENDERER (renderer), None, None);}/** * pango_xft_renderer_new: * @display: an X display * @screen: the index of the screen for @display to which rendering will be done * * Create a new #PangoXftRenderer to allow rendering Pango objects * with the Xft library. You must call pango_xft_renderer_set_draw() before * using the renderer. * * Return value: the newly created #PangoXftRenderer, which should * be freed with g_object_unref(). * * Since: 1.8 **/PangoRenderer *pango_xft_renderer_new (Display *display, int screen){ PangoXftRenderer *xftrenderer; xftrenderer = g_object_new (PANGO_TYPE_XFT_RENDERER, "display", display, "screen", screen, NULL); return PANGO_RENDERER (xftrenderer);}/** * pango_xft_renderer_set_draw: * @xftrenderer: a #PangoXftRenderer * @draw: a #XftDraw * * Sets the #XftDraw object that the renderer is drawing to. * The renderer must not be currently active. * * Since: 1.8 **/voidpango_xft_renderer_set_draw (PangoXftRenderer *xftrenderer, XftDraw *draw){ g_return_if_fail (PANGO_IS_XFT_RENDERER (xftrenderer)); xftrenderer->draw = draw;}/** * pango_xft_renderer_set_default_color: * @xftrenderer: a #XftRenderer * @default_color: the default foreground color * * Sets the default foreground color for a #XftRenderer. * * Since: 1.8 **/voidpango_xft_renderer_set_default_color (PangoXftRenderer *xftrenderer, PangoColor *default_color){ g_return_if_fail (PANGO_IS_XFT_RENDERER (xftrenderer)); xftrenderer->priv->default_color = *default_color;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -