Ejemplo n.º 1
0
static VALUE
rg_draw_layout(VALUE self, VALUE layout, VALUE x, VALUE y)
{
    pango_renderer_draw_layout(_SELF(self), 
                               PANGO_LAYOUT(RVAL2GOBJ(layout)),
                               NUM2INT(x), NUM2INT(y));
    return self;
}
Ejemplo n.º 2
0
void viewdo_pango_render(PangoLayout* layout, float x, float y, float scale, std::vector<ViewdoTextRun>& outRuns) {
    Renderer* viewdoRenderer = (Renderer*) g_object_new(TYPE_RENDERER, 0);
    viewdoRenderer->m_runs = &outRuns;
    viewdoRenderer->m_scale = scale;

    pango_renderer_draw_layout(
        PANGO_RENDERER(viewdoRenderer),
        layout,
        (int)(x * PANGO_SCALE / scale), (int)(y * PANGO_SCALE / scale));

    g_object_unref(viewdoRenderer);
}
void
pango_clutter_render_layout_subpixel (PangoLayout  *layout,
				      int           x,
				      int           y,
				      ClutterColor *color,
				      int           flags)
{
  PangoContext         *context;
  PangoFontMap         *font_map;
  PangoRenderer        *renderer;
  PangoClutterRenderer *priv;

  context = pango_layout_get_context (layout);
  font_map = pango_context_get_font_map (context);
  g_return_if_fail (PANGO_CLUTTER_IS_FONT_MAP (font_map));
  renderer = _pango_clutter_font_map_get_renderer
    (PANGO_CLUTTER_FONT_MAP (font_map));
  priv = PANGO_CLUTTER_RENDERER (renderer);

  priv->color = *color;

  pango_renderer_draw_layout (renderer, layout, x, y);
}
Ejemplo n.º 4
0
Archivo: gui_util.c Proyecto: bert/fped
void render_text(GdkDrawable *da, GdkGC *gc, int x, int y, double angle,
    const char *s, const char *font, double xalign, double yalign,
    int xmax, int ymax)
{
	GdkScreen *screen;
	PangoRenderer *renderer;
	PangoContext *context;
	PangoLayout *layout;
	PangoFontDescription *desc;
	int width, height;
	PangoMatrix m = PANGO_MATRIX_INIT;
	double f_min, f;

	/* set up the renderer */

	screen = gdk_drawable_get_screen(da);
	renderer = gdk_pango_renderer_get_default(screen);
	gdk_pango_renderer_set_drawable(GDK_PANGO_RENDERER(renderer), da);
	gdk_pango_renderer_set_gc(GDK_PANGO_RENDERER(renderer), gc);

	/* start preparing the layout */

	context = gdk_pango_context_get_for_screen(screen);
	layout = pango_layout_new(context);
	pango_layout_set_text(layout, s, -1);

	/* apply the font */

	desc = pango_font_description_from_string(font);
	pango_layout_set_font_description(layout, desc);
	pango_font_description_free(desc);

	/* align and position the text */

	pango_layout_get_size(layout, &width, &height);
	f_min = 1.0;
	if (xmax) {
		f = xmax/((double) width/PANGO_SCALE);
		if (f < f_min)
			f_min = f;
	}
	if (ymax) {
		f = ymax/((double) height/PANGO_SCALE);
		if (f < f_min)
			f_min = f;
	}
	if (f_min < MIN_FONT_SCALE)
		f_min = MIN_FONT_SCALE;
	pango_matrix_translate(&m, x, y);
	pango_matrix_rotate(&m, angle);
	pango_matrix_translate(&m,
	    -xalign*f_min*width/PANGO_SCALE,
	    (yalign-1)*f_min*height/PANGO_SCALE);
	pango_matrix_scale(&m, f_min, f_min);

	pango_context_set_matrix(context, &m);
	pango_layout_context_changed(layout);
	pango_renderer_draw_layout(renderer, layout, 0, 0);

	/* clean up renderer */

	gdk_pango_renderer_set_drawable(GDK_PANGO_RENDERER(renderer), NULL);
	gdk_pango_renderer_set_gc(GDK_PANGO_RENDERER(renderer), NULL);

	/* free objects */

	g_object_unref(layout);
	g_object_unref(context);
}