static cairo_t *
_cairo_user_scaled_font_create_meta_context (cairo_user_scaled_font_t *scaled_font)
{
    cairo_content_t content;
    cairo_surface_t *meta_surface;
    cairo_t *cr;

    content = scaled_font->base.options.antialias == CAIRO_ANTIALIAS_SUBPIXEL ?
						     CAIRO_CONTENT_COLOR_ALPHA :
						     CAIRO_CONTENT_ALPHA;

    meta_surface = cairo_meta_surface_create (content, NULL);
    cr = cairo_create (meta_surface);
    cairo_surface_destroy (meta_surface);

    cairo_set_matrix (cr, &scaled_font->base.scale);
    cairo_set_font_size (cr, 1.0);
    cairo_set_font_options (cr, &scaled_font->base.options);
    cairo_set_source_rgb (cr, 1., 1., 1.);

    return cr;
}
void Label_t::update()
{
	Rectangle thisBounds(0, 0, getBounds().width, getBounds().height);

	// Check if the component was ever layouted, otherwise set to a high value
	if (!thisBounds.width && !thisBounds.height)
	{
		thisBounds.width = 9999;
		thisBounds.height = 9999;
	}

	// get text bounds
	cr = graphics.getContext();
	cairo_set_font_face(cr, font->getFace());
	cairo_set_font_size(cr, fontSize);
	cairo_text_extents(cr, this->text.c_str(), &lastExtents);
	Dimension newPreferred(lastExtents.width + 3, lastExtents.height + 3);

	// Set new preferred size
	if (getPreferredSize() != newPreferred) setPreferredSize(newPreferred);
	markFor(COMPONENT_REQUIREMENT_PAINT);
}
Beispiel #3
0
void affiche_serieL2(grille G,cairo_t *cr) {
	int *serieL;
	char *tab=(char*)calloc(10,sizeof(char));
	int i,j;
	for(i=0;i<G->n;i++){
		serieL=serie_pointL(G,i);
		for(j=1;j<((G->m+1)/2)+1;j++)	{
			if (serieL[j]!=0) {
				cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); 
				cairo_select_font_face(cr,
				"cairo:",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL);
				cairo_set_font_size(cr, 20);
				cairo_move_to(cr, (G->m*((int)width))+j*30,30+i*((int)width));
				//printf("%d\n",serieL[j]);
				sprintf(tab,"%2d",serieL[j]);
				cairo_show_text(cr,tab);  
			}
			else break;
		}
		free(serieL);
	}
}
Beispiel #4
0
int render_date(cairo_t *cairo, int x, int y, int d) {
	time_t rawnow = time(NULL);
	struct tm *now = localtime(&rawnow);
	char date_string[256];

	strftime(date_string, 256, conf->datefmt, now);

	set_cairo_source_colour(cairo, conf->datecol);
	cairo_set_font_face(cairo, conf->datefont);
	cairo_set_font_size(cairo, conf->datefontsize);

	cairo_text_extents_t extents;
	cairo_text_extents(cairo, date_string, &extents);

	int render_x = x;
	if(d == RIGHT) render_x = x - extents.width;

	cairo_move_to(cairo, render_x, y);
	cairo_show_text(cairo, date_string);

	return extents.width - 1;
}
Beispiel #5
0
void do_drawing(cairo_t *cr, GtkWidget *widget)
{
  cairo_text_extents_t extents;

  GtkWidget *win = gtk_widget_get_toplevel(widget);
  
  gint width, height;
  gtk_window_get_size(GTK_WINDOW(win), &width, &height);  
  
  gint x = width/2;
  gint y = height/2;
  
  cairo_set_source_rgb(cr, 0.5, 0, 0); 
  cairo_paint(cr);   

  cairo_select_font_face(cr, "Courier",
      CAIRO_FONT_SLANT_NORMAL,
      CAIRO_FONT_WEIGHT_BOLD);
 
  glob.size += 0.8;

  if (glob.size > 20) {
      glob.alpha -= 0.01;
  }

  cairo_set_font_size(cr, glob.size);
  cairo_set_source_rgb(cr, 1, 1, 1); 

  cairo_text_extents(cr, "ZetCode", &extents);
  cairo_move_to(cr, x - extents.width/2, y);
  cairo_text_path(cr, "ZetCode");
  cairo_clip(cr);

  cairo_paint_with_alpha(cr, glob.alpha);
  
  if (glob.alpha <= 0) {
      glob.timer = FALSE;
  }     
}
Beispiel #6
0
void startMenuDraw(cairo_t *cairoDrawPlace, field_t *field)
{
    int i, j;
    char shipName[20][20] = {"ARCANE",
                             "WING",
                             "VERTIGO",
                             "YOMEN",
                             "OMEGA", 
                             "HERO",
                             "SKULL"};
    cairo_set_source_rgba(cairoDrawPlace, 1, 1, 1, 1);
    cairo_set_font_size(cairoDrawPlace, 16);
    cairo_move_to(cairoDrawPlace, 7 * pixelConst, 2 * pixelConst);
    cairo_show_text(cairoDrawPlace, "Choose ship:"); 
    for (i = 0; i <= SKULL; i++) {
        if (field->shipType == i) {
            cairo_rectangle(cairoDrawPlace, 6 * pixelConst, 2 * (i + 2) * pixelConst, pixelConst, -pixelConst);
        }
        cairo_move_to(cairoDrawPlace, 8 * pixelConst, 2 * (i + 2) * pixelConst - 1);
        cairo_show_text(cairoDrawPlace, shipName[i]); 
    }
    cairo_move_to(cairoDrawPlace, pixelConst, 2 * (i + 4) * pixelConst);
    cairo_show_text(cairoDrawPlace, "Arrows - move."); 
    cairo_move_to(cairoDrawPlace,  pixelConst, 2 * (i + 5) * pixelConst);
    cairo_show_text(cairoDrawPlace, "'z' - fire/start."); 
    cairo_stroke(cairoDrawPlace);

    for (i = 0; i < field->size.y; i++) {
        for (j = 0; j < field->size.x; j++) {
            if (field->values[i][j] == SHIP) {
                cairo_set_source_rgba(cairoDrawPlace, 1, 0.85, 0, 1);
                cairo_rectangle(cairoDrawPlace, j * pixelConst, i * pixelConst, pixelConst, pixelConst);
                cairo_fill(cairoDrawPlace);
                cairo_stroke(cairoDrawPlace);
            }
        }
    }
    cairo_stroke(cairoDrawPlace);
}
Beispiel #7
0
/* Perform the actual drawing of the entries */
static void do_drawing(GtkWidget *widget, cairo_t *cr) {

    /* How much space was the window actually allocated? */
    GtkAllocation *allocation = g_new0 (GtkAllocation, 1);
    gtk_widget_get_allocation(GTK_WIDGET(widget), allocation);
    display_width = allocation->width;
    display_height = allocation->height;

    /* Allocation no longer needed */
    g_free(allocation);
   
    /* Set cairo drawing variables */
    cairo_set_source_rgb(cr, 0, 0, 0);
    cairo_select_font_face(cr, "Helvetica",
                           CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size(cr, 20);
    cairo_set_line_width(cr, 1);
    cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
    
    /* Begin drawing the nodes */
    draw_tree(cr, root_entry);
}
Beispiel #8
0
Datei: svg.c Projekt: 4179e1/misc
int main (void)
{
	cairo_surface_t *surface;
	cairo_t *cr;

	surface = cairo_svg_surface_create ("image.svg", 504, 648);
	cr = cairo_create (surface);

	cairo_set_source_rgb (cr, 0, 0, 0);
	cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size (cr, 40.0);

	cairo_move_to (cr, 10.0, 50.0);
	cairo_show_text (cr, "Hello world!");

	cairo_show_page (cr);

	cairo_surface_destroy (surface);
	cairo_destroy (cr);

	return 0;
}
Beispiel #9
0
void text_extents(char * text, double * w, double * h)
{
    fontface * face = NULL;
    cairo_text_extents_t text_extents;
    double tmp_w, tmp_h;

    face = hash_get(faces, "__DEFAULT__");

    cairo_set_font_face(main_context, face->cface);
    cairo_set_font_size(main_context, _DEFAULT_FONT_SIZE);

    // will have to keep subtracting from the previous amount to determine
    // the width of the current "line"
    while ( text[0] != '\0' )
    {
        cairo_text_extents(main_context, text, &text_extents);
        text += strcspn(text, "\n") + 1;
    }

    *w = text_extents.width;
    *h = text_extents.height;
}
Beispiel #10
0
static cairo_perf_ticks_t
do_twin (cairo_t *cr,
	 int width,
	 int height,
	 int loops)
{
    int i, j, h;
    unsigned char s[2] = {0, 0};

    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
    cairo_paint (cr);
    cairo_set_source_rgb (cr, 0, 0, 0);

    cairo_select_font_face (cr,
			    "@cairo:",
			    CAIRO_FONT_SLANT_NORMAL,
			    CAIRO_FONT_WEIGHT_NORMAL);

    cairo_perf_timer_start ();

    while (loops--) {
	h = 2;
	for (i = 8; i < 48; i >= 24 ? i+=3 : i++) {
	    cairo_set_font_size (cr, i);
	    for (j = 33; j < 128; j++) {
		if (j == 33 || (j == 80 && i > 24)) {
		    h += i + 2;
		    cairo_move_to (cr, 10, h);
		}
		s[0] = j;
		cairo_text_path (cr, (const char *) s);
	    }
	}
	cairo_fill (cr);
    }

    cairo_perf_timer_stop ();
    return cairo_perf_timer_elapsed ();
}
Beispiel #11
0
static gboolean draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data)
{
  cairo_set_source_rgb (cr, 1,1,1);
  cairo_paint (cr);

  cairo_surface_t *g_surface;
  
  g_surface = cairo_image_surface_create_for_data (scratch, CAIRO_FORMAT_A8,
      s_width, s_height, s_width);

  cairo_set_source_rgb (cr, 1,0,0);
  cairo_translate (cr, 0, 0);
  cairo_mask_surface (cr, g_surface, 0, 0);
  cairo_fill (cr);

  cairo_surface_destroy (g_surface);
  cairo_set_source_rgb (cr, 0,0,0);
  
  cairo_select_font_face(cr, "Sans",
      CAIRO_FONT_SLANT_NORMAL,
      CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size(cr, 20);

  char buf[4096];
  float y = 0.0;
  float x = 300;

  sprintf (buf, "alpha: %2.2f%%", 100 * alpha);
  cairo_move_to (cr, x, y+=30);
  cairo_show_text (cr, buf);


  sprintf (buf, "beta: %2.2f%%", 100 * beta);
  cairo_move_to (cr, x, y+=30);
  cairo_show_text (cr, buf);

  return FALSE;
}
Beispiel #12
0
void menuwin_paint_clock(cairo_t *cr) {

	struct timeval tv;
	struct tm *l_time;
	cairo_text_extents_t te;
	char string[100];
	float date_width;

	gettimeofday(&tv,NULL);
	l_time=localtime(&tv.tv_sec);

	float scale_h=((float)height)/((float)KEYS_H_DIVISOR);
	float scale_w=((float)width)/((float)KEYS_PER_ROW);

	menuwin_paint_button(cr,1,0,2,1,0.8,1.0,0.2);
	//cairo_restore(cr);

	//cairo_save(cr);
	//cairo_scale(cr,scale_h,scale_h);
	cairo_set_font_size(cr,0.85);

	cairo_set_source_rgb(cr, 0,0,0);

	strftime(string,99,"%x",l_time);
	cairo_text_extents(cr,string, &te);
	cairo_move_to(cr,-te.x_bearing-(te.width/2.0),0.05-te.y_bearing);
	cairo_show_text(cr,string);
	date_width=te.width;

	strftime(string,99,"%k:%M",l_time);
	cairo_text_extents(cr,string, &te);
	cairo_move_to(cr,-te.x_bearing-(te.width/2.0),-0.05-te.height-te.y_bearing);
	cairo_show_text(cr,string);


	cairo_restore(cr);

}
Beispiel #13
0
int render_alarm(cairo_t *cairo, uint32_t alarm_s, int x, int y, int d) {
	struct tm *atm = malloc(sizeof *atm);
	memset(atm, 0, sizeof *atm);
	char *format = malloc(32);
	sprintf(format, "%s", "%M:%S");
	char time_string[128];

	while(alarm_s >= 3600) {
		atm->tm_hour++;
		alarm_s -= 3600;
		sprintf(format, "%s", "%H:%M:%S");
	}
	while(alarm_s >= 60) {
		atm->tm_min++;
		alarm_s -= 60;
	}
	atm->tm_sec = alarm_s;


	strftime(time_string, 128, format, atm);
	free(atm);
	free(format);

	set_cairo_source_colour(cairo, conf->alarmcol);
	cairo_set_font_face(cairo, conf->timefont);
	cairo_set_font_size(cairo, conf->timefontsize);

	cairo_text_extents_t extents;
	cairo_text_extents(cairo, time_string, &extents);

	int render_x = x;
	if(d == RIGHT) render_x = x - extents.width;

	cairo_move_to(cairo, render_x, y);
	cairo_show_text(cairo, time_string);

	return extents.width - 1;
}
Beispiel #14
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_text_extents_t extents;
    cairo_font_options_t *font_options;
    const char black[] = "black", blue[] = "blue";

    /* We draw in the default black, so paint white first. */
    cairo_save (cr);
    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
    cairo_paint (cr);
    cairo_restore (cr);

    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
			    CAIRO_FONT_SLANT_NORMAL,
			    CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, TEXT_SIZE);

    font_options = cairo_font_options_create ();
    cairo_get_font_options (cr, font_options);
    cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY);
    cairo_set_font_options (cr, font_options);

    cairo_font_options_destroy (font_options);

    cairo_set_source_rgb (cr, 0, 0, 0); /* black */
    cairo_text_extents (cr, black, &extents);
    cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
    cairo_show_text (cr, black);
    cairo_translate (cr, 0, -extents.y_bearing + 1);

    cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
    cairo_text_extents (cr, blue, &extents);
    cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
    cairo_show_text (cr, blue);

    return CAIRO_TEST_SUCCESS;
}
static void
sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf)
{
    SPCanvasText *cl = SP_CANVASTEXT (item);

    if (!buf->ct)
        return;

    cairo_set_font_size(buf->ct, cl->fontsize);

    if (cl->background) {
        cairo_text_extents_t extents;
        cairo_text_extents(buf->ct, cl->text, &extents);

        cairo_rectangle(buf->ct, item->x1 - buf->rect.left(),
                        item->y1 - buf->rect.top(),
                        item->x2 - item->x1,
                        item->y2 - item->y1);

        ink_cairo_set_source_rgba32(buf->ct, cl->rgba_background);
        cairo_fill(buf->ct);
    }

    Geom::Point s = cl->s * cl->affine;
    double offsetx = s[Geom::X] - cl->anchor_offset_x - buf->rect.left();
    double offsety = s[Geom::Y] - cl->anchor_offset_y - buf->rect.top();

    cairo_move_to(buf->ct, round(offsetx), round(offsety));
    cairo_text_path(buf->ct, cl->text);

    if (cl->outline) {
        ink_cairo_set_source_rgba32(buf->ct, cl->rgba_stroke);
        cairo_set_line_width (buf->ct, 2.0);
        cairo_stroke_preserve(buf->ct);
    }
    ink_cairo_set_source_rgba32(buf->ct, cl->rgba);
    cairo_fill(buf->ct);
}
Beispiel #16
0
void draw_input_box(cairo_t * cc,
        const uint16_t width, const uint16_t height,
        const uint32_t fg,    const uint32_t bg,
        const uint32_t pad,   const int len) {
    // U+25CF BLACK CIRCLE, UTF-8 encoding
    static const char dot[] = {0xE2, 0x97, 0x8F, 0x00};
    cairo_set_font_size(cc, TEXT_SIZE * 0.75);
    cairo_select_font_face(cc, "Sans",
            CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);

    cairo_text_extents_t te;
    cairo_text_extents(cc, dot, &te);

    int show_len = MIN(len, PASS_SHOW_LEN);
    // draw the outer box
    uint16_t x = 0, y = 0, w = 0, h = 0;
    w = te.width * show_len + pad * (show_len - 1) + te.height;
    h = te.height * 2;
    x = (width -  w) / 2;
    y = (height - h) / 2;

    cairo_set_source_uint32(cc, fg);
    cairo_rectangle(cc, x, y, w, h);
    cairo_set_line_width(cc, TEXT_SIZE / 10);
    cairo_stroke(cc);

    // draw text
    int i = 0;
    w = te.width * show_len + pad * (show_len - 1);
    h = te.height;
    x = (width -  w) / 2;
    y = (height - h) / 2;
    for (i = 0; i < show_len; i++) {
        cairo_move_to(cc,
            x + i * (te.width + pad) - te.x_bearing, y - te.y_bearing);
        cairo_show_text(cc, dot);
    }
}
Beispiel #17
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    /* We draw in the default black, so paint white first. */
    cairo_save (cr);
    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
    cairo_paint (cr);
    cairo_restore (cr);

    cairo_select_font_face (cr, "Bitstream Vera Sans",
			    CAIRO_FONT_SLANT_NORMAL,
			    CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, TEXT_SIZE);

    cairo_set_source_rgb (cr, 0, 0, 0); /* black */

    cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_get_scaled_font (cr), 1);

    cairo_move_to (cr, 1, TEXT_SIZE);
    cairo_show_text (cr, "the five boxing wizards jump quickly");

    return CAIRO_TEST_SUCCESS;
}
Beispiel #18
0
int main(void)
{
  cairo_surface_t *surface;
  cairo_t *cr;

  surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 390, 60);
  cr = cairo_create(surface);

  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
      CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size(cr, 40.0);

  cairo_move_to(cr, 10.0, 50.0);
  cairo_show_text(cr, "Disziplin ist Macht.");

  cairo_surface_write_to_png(surface, "image.png");

  cairo_destroy(cr);
  cairo_surface_destroy(surface);

  return 0;
}
Beispiel #19
0
void shutdown_expose() {

	if (shutdown_win.cache->mapped==1) {
	
		cairo_text_extents_t te;
	
		cairo_t *cr=cairo_create(shutdown_win.surface);
		cairo_select_font_face(cr,"sans-serif",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL);
		cairo_set_font_size(cr,18);

		cairo_set_source_rgb(cr, 0.75,0.75,0.75);
		cairo_paint(cr);
		shutdown_paint_cancel(cr);
		shutdown_paint_ok(cr);
		cairo_set_source_rgb(cr,0.0,0.0,0.0);
		cairo_text_extents(cr,"Shutdown the device?", &te);
		cairo_move_to(cr,(shutdown_win.width/2)+(-te.x_bearing-(te.width/2.0)),(shutdown_win.height/3)+(-te.y_bearing-(te.height/2.0)));
		cairo_show_text(cr,"Shutdown the device?");

		xcb_flush(conn);
		cairo_destroy(cr);
	}
}
void PdfView::drawPage(PdfCache* cache, XojPopplerPage* popplerPage, cairo_t* cr,
					   double zoom, double width, double height, bool forPrinting)
{
	if (popplerPage)
	{
		if (cache && !forPrinting)
		{
			cache->render(cr, popplerPage, zoom);
		}
		else
		{
			popplerPage->render(cr, forPrinting);
		}

		if (!forPrinting)
		{
			cairo_set_operator(cr, CAIRO_OPERATOR_DEST_OVER);
			cairo_set_source_rgb(cr, 1., 1., 1.);
		}
		cairo_paint(cr);
	}
	else
	{
		cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
							CAIRO_FONT_WEIGHT_BOLD);
		cairo_set_font_size(cr, 26);

		cairo_set_source_rgb(cr, 0.8, 0.8, 0.8);

		cairo_text_extents_t extents = { 0 };
		string strMissing = _("PDF background missing");

		cairo_text_extents(cr, strMissing.c_str(), &extents);
		cairo_move_to(cr, width / 2 - extents.width / 2, height / 2 - extents.height / 2);
		cairo_show_text(cr, strMissing.c_str());
	}
}
Beispiel #21
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_font_options_t *options;

    cairo_set_source_rgb (cr, 1, 1, 1);
    cairo_paint (cr);
    cairo_set_source_rgb (cr, 0, 0, 0);

    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);

    cairo_select_font_face (cr,
			    "@cairo:",
			    CAIRO_FONT_SLANT_NORMAL,
			    CAIRO_FONT_WEIGHT_NORMAL);

    options = cairo_font_options_create ();
    cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_NONE);
    cairo_set_font_options (cr, options);
    cairo_font_options_destroy (options);

    cairo_set_font_size (cr, 16);

    cairo_move_to (cr, 4, 14);
    cairo_show_text (cr, "Is cairo's twin giza?");

    cairo_move_to (cr, 4, 34);
    cairo_text_path (cr, "Is cairo's twin giza?");
    cairo_fill (cr);

    cairo_move_to (cr, 4, 54);
    cairo_text_path (cr, "Is cairo's twin giza?");
    cairo_set_line_width (cr, 2/16.);
    cairo_stroke (cr);

    return CAIRO_TEST_SUCCESS;
}
Beispiel #22
0
/* Drawing of the whole bunch */
void
draw_chip(drawing_context_t *ctx, const chip_descr_t *chip) {
  cairo_t *cr = ctx->cr;

  debit_log(L_DRAW, "Start of draw chip");

  /* This should be after zoom, in user coordinates */

  /* paint the clip region */
  cairo_set_source_rgb (cr, 0., 0., 0.);
  cairo_paint (cr);

  /* draw everything in white. This could be per-site or per-site-type */
  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
  cairo_set_line_width (cr, 1);

  cairo_select_font_face(cr, NAME_FONT_TYPE,
			 CAIRO_FONT_SLANT_NORMAL,
			 CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size(cr, NAME_FONT_SIZE);

  /* initialize patterns -- once and for all ? */
/*   if (!ctx->site_sing_patterns[CLB]) */
/*     ctx->site_sing_patterns[CLB] = draw_clb_pattern(ctx); */

/*   if (!ctx->site_full_patterns[CLB]) */
/*     ctx->site_full_patterns[CLB] = draw_full_clb_pattern(ctx, chip); */
/*   cairo_save (cr); */
/*   cairo_set_source (cr, ctx->site_full_patterns[CLB]); */
/*   cairo_paint (cr); */
/*   cairo_restore (cr); */

  /* move from the context */
  draw_chip_for_window(ctx, chip);

  debit_log(L_DRAW, "End of draw chip");
}
Beispiel #23
0
void gui_post_expose(struct dt_iop_module_t *self, cairo_t *cr, int32_t width, int32_t height,
                     int32_t pointerx, int32_t pointery)
{
  dt_iop_colorout_gui_data_t *g = (dt_iop_colorout_gui_data_t *)self->gui_data;
  if(g->softproof_enabled)
  {
    gchar *label = g->softproof_enabled == DT_SOFTPROOF_GAMUTCHECK ? _("gamut check") : _("soft proof");
    cairo_set_source_rgba(cr, 0.5, 0.5, 0.5, 0.5);
    cairo_text_extents_t te;
    cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size(cr, 20);
    cairo_text_extents(cr, label, &te);
    cairo_move_to(cr, te.height * 2, height - (te.height * 2));
    cairo_text_path(cr, label);
    cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
    cairo_fill_preserve(cr);
    cairo_set_line_width(cr, 0.7);
    cairo_set_source_rgb(cr, 0.3, 0.3, 0.3);
    cairo_stroke(cr);
  }

  const int force_lcms2 = dt_conf_get_bool("plugins/lighttable/export/force_lcms2");
  if(force_lcms2)
  {
    gtk_widget_set_no_show_all(g->cbox1, FALSE);
    gtk_widget_set_visible(g->cbox1, TRUE);
    gtk_widget_set_no_show_all(g->cbox4, FALSE);
    gtk_widget_set_visible(g->cbox4, TRUE);
  }
  else
  {
    gtk_widget_set_no_show_all(g->cbox1, TRUE);
    gtk_widget_set_visible(g->cbox1, FALSE);
    gtk_widget_set_no_show_all(g->cbox4, TRUE);
    gtk_widget_set_visible(g->cbox4, FALSE);
  }
}
Beispiel #24
0
Datei: sub.c Projekt: 9060/spdiff
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_text_extents_t extents;
    cairo_font_options_t *font_options;
    static char black[] = "black", blue[] = "blue";

    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
    cairo_paint (cr);

    cairo_select_font_face (cr, "Bitstream Vera Sans",
			    CAIRO_FONT_SLANT_NORMAL,
			    CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, TEXT_SIZE);

    font_options = cairo_font_options_create ();
    cairo_get_font_options (cr, font_options);
    cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
    cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB);
    cairo_set_font_options (cr, font_options);

    cairo_font_options_destroy (font_options);

    cairo_set_source_rgb (cr, 0, 0, 0); /* black */
    cairo_text_extents (cr, black, &extents);
    cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
    cairo_show_text (cr, black);
    cairo_translate (cr, 0, -extents.y_bearing + 1);

    cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
    cairo_text_extents (cr, blue, &extents);
    cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
    cairo_show_text (cr, blue);

    return CAIRO_TEST_SUCCESS;
}
Beispiel #25
0
//
// redraw
//
void root_window_redraw(XExposeEvent *e, Display *d, int screen, StateMachine *state)
{
    // NOTE: if you wish t use `e` you MUST check if it is not NULL first

    if (!is_init)
    {
        // init freetype font the first time
        init_font(&font, ROOT_WINDOW_FONT_PATH);
        is_init = True;
    }

    // required properties and structs for redraw
    Window root = RootWindow(d, screen);
    int width = DisplayWidth(d, screen);
    int height = DisplayHeight(d, screen);
    Visual *visual = DefaultVisual(d, screen);

    // create surface
    cairo_surface_t *surface=cairo_xlib_surface_create(d, root, visual, width, height);
    cairo_t *cr = cairo_create(surface);

    // clear surface with a solid colour
    cairo_set_source_rgb(cr, ROOT_WINDOW_BG_RGB);
    cairo_rectangle(cr, 0, 0, width, height);
    cairo_fill(cr);

    // draw product name and version on desktop
    cairo_set_source_rgb(cr, ROOT_WINDOW_FG_RGB);
    cairo_set_font_face(cr, font.cairo_font);
    cairo_set_font_size(cr, ROOT_WINDOW_FONT_SIZE);
    cairo_move_to(cr, LAYOUT_MARGIN, height-(2*LAYOUT_MARGIN));
    cairo_show_text(cr, PRODUCT_NAME_AND_VERSION);

    cairo_destroy(cr);
    cairo_surface_destroy(surface);
}
Beispiel #26
0
static void
panel_tag_redraw_handler(struct widget *widget, void *data)
{
	static char* tag_names[] = {"a", "s", "d", "f", "g", "h", "j", "k", "l", ";"};
	struct panel_tag *tag = data;
	cairo_text_extents_t extents;
	cairo_surface_t *surface;
	struct rectangle allocation;
	cairo_t *cr;
	
	surface = window_get_surface(tag->panel->window);
	cr = cairo_create(surface);
	widget_get_allocation(widget, &allocation);

	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
	cairo_select_font_face(cr, "monospace",
			       CAIRO_FONT_SLANT_NORMAL,
			       CAIRO_FONT_WEIGHT_BOLD);
	cairo_set_font_size(cr, tag->font_size);
	//cairo_text_extents(cr, "1", &extents);
	int x = 0;
	int y = 0;
	cairo_move_to(cr, allocation.x, 26);
	if (tag->focused)
		cairo_set_source_rgba(cr, 0.8, 1, 1, 1);
	else if (tag->pressed)
		cairo_set_source_rgba(cr, 1, 0, 0, 1);
	else
		cairo_set_source_rgba(cr, 0, 0.7, 1, 1);
	
	cairo_show_text(cr, tag_names[tag->no]); 
	//cairo_set_source_surface(cr, launcher->icon, allocation.x, allocation.y);
	//cairo_paint(cr);
	
	cairo_destroy(cr);
}
void drawContextFltkCairo::setFont(int fontid, int fontsize)
{
  if (_currentFontId != fontid) {
    switch (fontid) {
      case FL_HELVETICA :
      case FL_HELVETICA_BOLD :
      case FL_HELVETICA_BOLD_ITALIC :
      case FL_HELVETICA_ITALIC :
        cairo_select_font_face(_cr, "sans",
          fontid & FL_ITALIC ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL,
          fontid & FL_BOLD ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL);
        break;
      case FL_COURIER :
      case FL_COURIER_BOLD :
      case FL_COURIER_BOLD_ITALIC :
      case FL_COURIER_ITALIC :
        cairo_select_font_face(_cr, "courier",
          fontid & FL_ITALIC ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL,
          fontid & FL_BOLD ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL);
        break;
      case FL_TIMES :
      case FL_TIMES_BOLD :
      case FL_TIMES_BOLD_ITALIC :
      case FL_TIMES_ITALIC :
        cairo_select_font_face(_cr, "serif",
          fontid & FL_ITALIC ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL,
          fontid & FL_BOLD ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL);
        break;
      default :
        cairo_select_font_face(_cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    }
    _currentFontId = fontid;
  }
  cairo_set_font_size(_cr, fontsize);
  _currentFontSize = fontsize;
}
Beispiel #28
0
void GUIFont_GetGreaterSize(const char *AFontName, float AHeight, unsigned int *ACharWidth, unsigned int *ACharHeight)
{
  cairo_text_extents_t *BExtents = (cairo_text_extents_t *)malloc(sizeof(cairo_text_extents_t));
  unsigned char *BText = (unsigned char *)malloc(sizeof(unsigned char) * 2);
  BText[0] = 0;
  BText[1] = '\0';
  
  cairo_surface_t *BSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
                                                         1,
                                                         1);
  cairo_t *BContext = cairo_create(BSurface);
  
  cairo_font_options_t *cfo = cairo_font_options_create();
  cairo_font_options_set_antialias(cfo, CAIRO_ANTIALIAS_SUBPIXEL);
  cairo_set_font_options(BContext, cfo);
  cairo_select_font_face(BContext, AFontName, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size(BContext, AHeight);
  
  for (BText[0] = 0; BText[0] < 255; BText[0]++)
  {
    cairo_text_extents(BContext, BText, BExtents);
    if (BExtents)
    {
      if (*ACharHeight < BExtents->height)
      {
        *ACharHeight = BExtents->height;
      };
      if (*ACharWidth < BExtents->width)
      {
        *ACharWidth = BExtents->width;
      };
    };
  };
  cairo_destroy(BContext);
  cairo_surface_destroy(BSurface);
};
Beispiel #29
0
void affiche_serieC2(grille G,cairo_t *cr) {
	int **serieC;
	char *tab=(char*)calloc(10,sizeof(char));
	serieC=tableauSerieC(G);
	int i,j;
	for(j=1;j<=(((G->n+1)/2)+1);j++) {
		for(i=0;i<G->m;i++) {
			if (serieC[i][j]!=0) {
				cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); 
				cairo_select_font_face(cr,
				"cairo:",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL);
				cairo_set_font_size(cr, 20);
				cairo_move_to(cr,10+i*((int)width),(G->n*((int)width))+20+j*30);
				//printf("%d\n",serieC[i][j]);
				sprintf(tab,"%2d",serieC[i][j]);
				cairo_show_text(cr,tab); 
			}
		}
	}
	for(j=0;j<G->m;j++) {
		free(serieC[j]);
	}		
	free(serieC);
}
Beispiel #30
0
void print_circle(GtkWidget *widget, const char* s, color c, int x, int y, int d, int h) {
  cairo_t *cr = gdk_cairo_create(widget->window);

  cairo_set_line_width(cr, 2);
  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_arc(cr, x, y, d, 0, 2 * M_PI);
  cairo_stroke_preserve(cr);

  if (c == RED)
    cairo_set_source_rgb(cr, 1, 0, 0);
  else
    cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_fill(cr);

  int d2 = 5, d1 = strlen(s) < 2 ? 4 : 9;

  cairo_set_source_rgb(cr, 0.8, 0.8, 0.8);
  cairo_select_font_face(cr, "Courier", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
  cairo_set_font_size(cr, h);
  cairo_move_to(cr, x - d1, y + d2);
  cairo_show_text(cr, s);

  cairo_destroy(cr);
}