GtGraphics* gt_graphics_cairo_new_from_context(cairo_t *context, unsigned int width, unsigned int height) { GtGraphics *g; GtGraphicsCairo *gc; char buf[64]; g = gt_graphics_create(gt_graphics_cairo_class()); gc = gt_graphics_cairo_cast(g); gc->width = width; gc->height = height; gc->margin_x = gc->margin_y = 20; gc->from_context = true; gc->cr = context; gc->layout = pango_cairo_create_layout(gc->cr); pango_layout_set_width(gc->layout, -1); gt_assert(gc->layout); snprintf(buf, 64, "Sans %d", TEXT_SIZE_DEFAULT); gc->desc = pango_font_description_from_string(buf); pango_layout_set_font_description(gc->layout, gc->desc); pango_font_description_free(gc->desc); cairo_set_line_join(context, CAIRO_LINE_JOIN_ROUND); cairo_set_line_cap(context, CAIRO_LINE_CAP_ROUND); return g; }
GtGraphics* gt_graphics_cairo_new(GtGraphicsOutType type, unsigned int width, unsigned int height) { GtGraphics *g; g = gt_graphics_create(gt_graphics_cairo_class()); gt_graphics_cairo_initialize(gt_graphics_cairo_cast(g), type, width, height); return g; }
GtGraphics* gt_graphics_cairo_new(GtGraphicsOutType type, unsigned int width, unsigned int height) { GtGraphics *g; GtGraphicsCairo *gc; char buf[64]; g = gt_graphics_create(gt_graphics_cairo_class()); gc = gt_graphics_cairo_cast(g); gt_graphics_cairo_initialize(g, type, width, height); gc->layout = pango_cairo_create_layout(gc->cr); pango_layout_set_width(gc->layout, -1); gt_assert(gc->layout); snprintf(buf, 64, "Sans %d", TEXT_SIZE_DEFAULT); gc->desc = pango_font_description_from_string(buf); pango_layout_set_font_description(gc->layout, gc->desc); pango_font_description_free(gc->desc); return g; }
GtGraphics* gt_graphics_cairo_new_from_context(cairo_t *context, unsigned int width, unsigned int height) { GtGraphics *g; GtGraphicsCairo *gc; g = gt_graphics_create(gt_graphics_cairo_class()); gc = gt_graphics_cairo_cast(g); gc->width = width; gc->height = height; gc->margin_x = gc->margin_y = 20; gc->from_context = true; gc->cr = context; cairo_set_line_join(context, CAIRO_LINE_JOIN_ROUND); cairo_set_line_cap(context, CAIRO_LINE_CAP_ROUND); cairo_select_font_face(context, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); return g; }