当前位置: 首页>>代码示例>>C++>>正文


C++ cairo_set_font_size函数代码示例

本文整理汇总了C++中cairo_set_font_size函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_set_font_size函数的具体用法?C++ cairo_set_font_size怎么用?C++ cairo_set_font_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cairo_set_font_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _cairo_user_scaled_font_create_meta_context

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;
}
开发者ID:angerangel,项目名称:livecode-thirdparty,代码行数:22,代码来源:cairo-user-font.c

示例2: thisBounds

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);
}
开发者ID:MarcoCicognani,项目名称:MeetiX-OS-Project,代码行数:22,代码来源:label.cpp

示例3: affiche_serieL2

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);
	}
}
开发者ID:J4g0n,项目名称:logigraphe,代码行数:22,代码来源:interaction.c

示例4: render_date

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;
}
开发者ID:Mnib,项目名称:bLifebar,代码行数:22,代码来源:render.c

示例5: do_drawing

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;
  }     
}
开发者ID:wiggni,项目名称:cpro,代码行数:39,代码来源:puff.c

示例6: startMenuDraw

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);
}
开发者ID:evheny0,项目名称:epic-spaceride,代码行数:39,代码来源:graphics.c

示例7: do_drawing

/* 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);
}
开发者ID:BartMassey,项目名称:duvis,代码行数:23,代码来源:graphics.c

示例8: main

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;
}
开发者ID:4179e1,项目名称:misc,代码行数:22,代码来源:svg.c

示例9: text_extents

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;
}
开发者ID:bartgrantham,项目名称:fasttext,代码行数:22,代码来源:fasttext.c

示例10: do_twin

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 ();
}
开发者ID:jaglass,项目名称:WinCairoRequirements,代码行数:39,代码来源:twin.c

示例11: draw_cb

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;
}
开发者ID:LetterModeller,项目名称:kernagic,代码行数:38,代码来源:gray.c

示例12: render_alarm

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;
}
开发者ID:Mnib,项目名称:bLifebar,代码行数:38,代码来源:render.c

示例13: draw

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;
}
开发者ID:499940913,项目名称:moon,代码行数:38,代码来源:text-antialias-gray.c

示例14: sp_canvastext_render

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);
}
开发者ID:NotBrianZach,项目名称:modalComposableProgrammableFuzzySearchingVectorGraphicEditing,代码行数:38,代码来源:canvas-text.cpp

示例15: draw_input_box

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);
    }
}
开发者ID:wsmithril,项目名称:wslock,代码行数:38,代码来源:lock_screen.c


注:本文中的cairo_set_font_size函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。