• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cairo_text_extents函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

/*
    To test, copy the the following files to the disk image:
        vcopy /dev/sdb ../../es-trunk/cmd/fonts.conf
        vcopy /dev/sdb ../../es-trunk/cmd/fonts.dtd
        vcopy /dev/sdb ../../es-trunk/cmd/40-generic.conf conf.d/
        vcopy /dev/sdb /usr/share/fonts/liberation/LiberationMono-Regular.ttf fonts/
        vcopy /dev/sdb /usr/share/fonts/liberation/LiberationSans-Regular.ttf fonts/
        vcopy /dev/sdb /usr/share/fonts/liberation/LiberationSerif-Regular.ttf fonts/

 */
int main(int argc, char* argv[])
{
    init();

    cairo_surface_t *surface;
    cairo_t *cr;

    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 320, 320);
    cr = cairo_create (surface);

    cairo_translate (cr, 10, 10);
    cairo_scale (cr, 100, 100);

    cairo_rectangle (cr, 0.0, 0.0, 3.0, 3.0);
    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
    cairo_fill (cr);

    cairo_text_extents_t te;

    cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
    cairo_select_font_face (cr, "Liberation Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size (cr, 1.0);
    cairo_text_extents (cr, "Hello", &te);
    cairo_move_to (cr, 1.5 - te.width / 2 - te.x_bearing, 0.5 - te.height / 2 - te.y_bearing);
    cairo_show_text (cr, "Hello");

    cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
    cairo_select_font_face (cr, "Liberation Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size (cr, 1.0);
    cairo_text_extents (cr, "Hello", &te);
    cairo_move_to (cr, 1.5 - te.width / 2 - te.x_bearing, 1.5 - te.height / 2 - te.y_bearing);
    cairo_show_text (cr, "Hello");

    cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
    cairo_select_font_face (cr, "Liberation Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size (cr, 1.0);
    cairo_text_extents (cr, "Hello", &te);
    cairo_move_to (cr, 1.5 - te.width / 2 - te.x_bearing, 2.5 - te.height / 2 - te.y_bearing);
    cairo_show_text (cr, "Hello");

    esReport("--- cairo_image_surface_get_data ---\n");
    u8* data = cairo_image_surface_get_data (surface);
    for (int y = 0; y < 320; ++y)
    {
        memmove(framebufferPtr + 4 * WIDTH * y,
                data + 4 * 320 * y,
                4 * 320);
    }
}
开发者ID:giobeatle1794,项目名称:es-operating-system,代码行数:59,代码来源:fontconfig.cpp


示例2: draw_string

/* ...draw multiline string - hmm; need to put that stuff into display */
static inline void draw_string(cairo_t *cr, const char *fmt, ...)
{
	char                    buffer[4096], *p, *end;
	cairo_text_extents_t    text_extents;
	cairo_font_extents_t    font_extents;
	va_list                 argp;

	cairo_save(cr);
	cairo_select_font_face(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size(cr, 40);
	cairo_font_extents(cr, &font_extents);

	va_start(argp, fmt);
	vsnprintf(buffer, sizeof(buffer), fmt, argp);
	va_end(argp);

    for (p = buffer; *p; p = end + 1)
    {
        /* ...output single line */
		((end = strchr(p, '\n')) != NULL ? *end = 0 : 0);
		cairo_show_text(cr, p);
		cairo_text_extents (cr, p, &text_extents);
		cairo_rel_move_to (cr, -text_extents.x_advance, font_extents.height);
        TRACE(0, _b("print text-line: <%f,%f>"), text_extents.x_advance, font_extents.height);

        /* ...stop when last line processes */
        if (!end)   break;
    }

    /* ...restore drawing context */
	cairo_restore(cr);
}
开发者ID:CogentEmbedded,项目名称:utest-adas,代码行数:33,代码来源:utest-sv.c


示例3: add_label

static void
add_label (struct chart *c,
	   int		 test,
	   const char	*label)
{
    cairo_text_extents_t extents;
    double dx, x;

    cairo_save (c->cr);
    dx = c->width / (double) c->num_tests;
    if (dx / 2 - PAD < 4)
	return;
    cairo_set_font_size (c->cr, dx / 2 - PAD);
    cairo_text_extents (c->cr, label, &extents);

    cairo_set_source_rgb (c->cr, .5, .5, .5);

    x = (test + .5) * dx;
    cairo_save (c->cr);
    cairo_translate (c->cr, x, c->height - PAD / 2);
    cairo_rotate (c->cr, -M_PI/2);
    cairo_move_to (c->cr, 0, -extents.y_bearing/2);
    cairo_show_text (c->cr, label);
    cairo_restore (c->cr);

    cairo_save (c->cr);
    cairo_translate (c->cr, x, PAD / 2);
    cairo_rotate (c->cr, -M_PI/2);
    cairo_move_to (c->cr, -extents.width, -extents.y_bearing/2);
    cairo_show_text (c->cr, label);
    cairo_restore (c->cr);

    cairo_restore (c->cr);
}
开发者ID:GuoCheng111,项目名称:WinCairoRequirements,代码行数:34,代码来源:cairo-perf-chart.c


示例4: render_workspace

int render_workspace(cairo_t *cairo, int x, int y,
					 struct i3_workspace *ws, int d) {

	//set colour based on visibility
	struct colour *c = conf->inviswscol;
	if(strcmp(ws->visible, "true") == 0) c = conf->viswscol;
	set_cairo_source_colour(cairo, c);

	//set font
	cairo_set_font_face(cairo, conf->wsfont);
	cairo_set_font_size(cairo, conf->wsfontsize);

	cairo_text_extents_t extents;
	cairo_text_extents(cairo, ws->name, &extents);

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

	//draw the text
	cairo_move_to(cairo, render_x, y);
	cairo_show_text(cairo, ws->name);

	//update the padding
	return extents.width + 2;
}
开发者ID:Mnib,项目名称:bLifebar,代码行数:25,代码来源:render.c


示例5: cairo_get_matrix

void address_histogram::render_bars(cairo_t *cr, const plot::bounds_t &bounds)
{
    if(top_addrs.size() < 1 || top_addrs.at(0).count == 0) {
        return;
    }

    cairo_matrix_t original_matrix;

    cairo_get_matrix(cr, &original_matrix);
    cairo_translate(cr, bounds.x, bounds.y);

    double offset_unit = bounds.width / top_addrs.size();
    double bar_width = offset_unit / bar_space_factor;
    double space_width = offset_unit - bar_width;
    uint64_t greatest = top_addrs.at(0).count;
    int index = 0;

    for(vector<iptree::addr_elem>::const_iterator it = top_addrs.begin();
            it != top_addrs.end(); it++) {
	double bar_height = (((double) it->count) / ((double) greatest)) * bounds.height;

	if(bar_height > 0) {
            // bar
            double bar_x = index * offset_unit + space_width;
            double bar_y = bounds.height - bar_height;

            cairo_set_source_rgb(cr, bar_color.r, bar_color.g, bar_color.b);
            cairo_rectangle(cr, bar_x, bar_y, bar_width, bar_height);
            cairo_fill(cr);

            // bar label
            std::string label = it->str();

            // IP6 labels are half size since they're (potentially) much longer
            if(it->is4()) {
                cairo_set_font_size(cr, bar_label_font_size);
            }
            else {
                cairo_set_font_size(cr, bar_label_font_size / 2.0);
            }

            cairo_text_extents_t label_extents;
            cairo_text_extents(cr, label.c_str(), &label_extents);

            cairo_move_to(cr, bar_x + bar_width / 2.0, bar_y);

            cairo_matrix_t unrotated_matrix;
            cairo_get_matrix(cr, &unrotated_matrix);
            cairo_rotate(cr, -M_PI / 4.0);

            cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
            cairo_show_text(cr, label.c_str());

            cairo_set_matrix(cr, &unrotated_matrix);
	}
	index++;
    }

    cairo_set_matrix(cr, &original_matrix);
}
开发者ID:admckinnon,项目名称:tcpflow,代码行数:60,代码来源:address_histogram.cpp


示例6: cairo_image_surface_create

// --------------------------------------------------------------
void CairoFont::GetExtent( const char * s, float * outWidth, float * outHeight, cairo_t * context ) const
{
        bool newcontext = false;
	if (!context) {
        	cairo_surface_t* surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1000, 1000);
                context = cairo_create (surface);
		cairo_surface_destroy (surface);	
		newcontext = true;
		std::cerr << "Your device has no native context.  Probably due to mixing and matching cairo with another device. Creating an ad hoc context and crossing fingers." << std::endl;
	}
	SelectFont (context);

//	cairo_matrix_t matrix;
//	cairo_get_matrix (context, &matrix);

	cairo_text_extents_t extents;
	cairo_text_extents (context, s, &extents);
	*outWidth	= extents.width;
	*outHeight	= extents.height;
//	*outWidth	= extents.width - extents.x_advance;
//	*outHeight	= extents.height - extents.y_advance;
//	*outWidth	= (extents.width - extents.x_advance) * matrix.xx;
//	*outHeight	= (extents.height - extents.y_advance) * matrix.yy;
//std::cout << "CairoFont::GetExtent -" << s << "- w/h " << *outWidth << "/" << *outHeight 
//	<< " - adv x/y " << extents.x_advance << "/" << extents.y_advance << std::endl;
        if (newcontext)
                cairo_destroy(context);
}
开发者ID:anttirt,项目名称:guidolib,代码行数:29,代码来源:CairoFont.cpp


示例7: WriteText

    void WriteText(double x, double y, 
            const std::string &font, double size, double rowPitch, const std::string &text)
            //const char *font, double size, const char *text)
    {
        cairo_text_extents_t extents;

        cairo_save(ctx_);

        cairo_select_font_face(ctx_, font.c_str(), 
                CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);

        cairo_set_font_size(ctx_, size);
        cairo_text_extents(ctx_, text.c_str(), &extents);

        std::istringstream is(text);
        std::string line;

        while(!is.eof())
        {
            y = y - extents.y_bearing + rowPitch;
            cairo_move_to(ctx_, x - extents.x_bearing, y);
            std::getline(is, line);
            cairo_show_text(ctx_, line.c_str());
        }

        cairo_restore(ctx_);
    }
开发者ID:yeyan,项目名称:ffmpeg-screens,代码行数:27,代码来源:ImageBuilder.hpp


示例8: cairo_set_operator

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 };
		const char * strMissing = _("PDF background missing");

		cairo_text_extents(cr, strMissing, &extents);
		cairo_move_to(cr, width / 2 - extents.width / 2, height / 2 - extents.height / 2);
		cairo_show_text(cr, strMissing);
	}
}
开发者ID:yolanother,项目名称:Xournal,代码行数:27,代码来源:PdfView.cpp


示例9: buttonDraw

static void
buttonDraw(cairo_t* cr, const Button* but)
{
	// Draw base
	if (but->pressed) {
		cairo_set_source_rgba(cr, 0.4, 0.9, 0.1, 1);
	} else {
		cairo_set_source_rgba(cr, 0.3, 0.5, 0.1, 1);
	}
	roundedBox(cr, but->x, but->y, but->w, but->h);
	cairo_fill_preserve(cr);

	// Draw border
	cairo_set_source_rgba(cr, 0.4, 0.9, 0.1, 1);
	cairo_set_line_width(cr, 4.0);
	cairo_stroke(cr);

	// Draw label
	cairo_text_extents_t extents;
	cairo_set_font_size(cr, 32.0);
	cairo_text_extents(cr, but->label, &extents);
	cairo_move_to(cr,
	              (but->x + but->w / 2) - extents.width / 2,
	              (but->y + but->h / 2) + extents.height / 2);
	cairo_set_source_rgba(cr, 0, 0, 0, 1);
	cairo_show_text(cr, but->label);
}
开发者ID:eriser,项目名称:pugl,代码行数:27,代码来源:pugl_cairo_test.c


示例10: draw

static void
draw (cairo_t *cr, struct options *options)
{
    cairo_text_extents_t extents;
    cairo_font_extents_t font_extents;

    cairo_select_font_face (cr,
			    options->family, options->slant, options->weight);
    cairo_set_font_size (cr, options->size);

    cairo_text_extents (cr, options->text, &extents);
    cairo_translate (cr,
		     options->PAD - extents.x_bearing,
		     options->PAD - extents.y_bearing);

    cairo_font_extents (cr, &font_extents);
    cairo_rectangle (cr, 0, -font_extents.ascent,
		      extents.x_advance, font_extents.height);
    cairo_move_to (cr, -options->PAD, 0);
    cairo_line_to (cr, extents.width + options->PAD, 0);
    cairo_set_source_rgba (cr, 1, 0, 0, .7);
    cairo_stroke (cr);

    cairo_rectangle (cr,
		     extents.x_bearing, extents.y_bearing,
		     extents.width, extents.height);
    cairo_set_source_rgba (cr, 0, 1, 0, .7);
    cairo_stroke (cr);

    cairo_move_to (cr, 0, 0);
    cairo_set_source_rgb (cr, 0, 0, 1);
    cairo_show_text (cr, options->text);
    cairo_fill (cr);
}
开发者ID:Youlean,项目名称:WDL-Youlean,代码行数:34,代码来源:font-view.c


示例11: print_pe

// Function to write the percent error on the upper left
void print_pe(frame &anim, double pe, color clr){

    // Drawing black box underneath "Percent Error"
    cairo_set_source_rgb(anim.frame_ctx[anim.curr_frame], 0, 0, 0);
    cairo_rectangle(anim.frame_ctx[anim.curr_frame], 0, 
                    anim.res_y - 20, anim.res_x, 20);
    cairo_fill(anim.frame_ctx[anim.curr_frame]);
    std::string pe_txt, number;
 
    std::stringstream ss;
    ss << std::setw(3) << pe;
    number = ss.str();

    pe_txt = "Percent Error: " + number;
    //std::cout << pe_txt << '\n';

    cairo_set_source_rgb(anim.frame_ctx[anim.curr_frame], clr.r,clr.g,clr.b);

    cairo_text_extents_t textbox;
    cairo_text_extents(anim.frame_ctx[anim.curr_frame], 
                       pe_txt.c_str(), &textbox);
    cairo_move_to(anim.frame_ctx[anim.curr_frame], 20, anim.res_y);
    cairo_show_text(anim.frame_ctx[anim.curr_frame], pe_txt.c_str());

    cairo_stroke(anim.frame_ctx[anim.curr_frame]);

}
开发者ID:leios,项目名称:simuleios,代码行数:28,代码来源:monte_carlo_vis.cpp


示例12: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    const char *text =
"This needs to be a very long string, wider than the surface, and yet wider."
"Ideally it should overflow the stack buffers, but do you really want to read "
"a message that long. No. So we compromise with around 300 glyphs that is "
"long enough to trigger the conditions as stated in "
"http://lists.cairographics.org/archives/cairo/2008-December/015976.html. "
"Happy now?";
    cairo_text_extents_t extents;

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

    cairo_set_font_size (cr, 16);
    cairo_text_extents (cr, text, &extents);
    cairo_move_to (cr, -extents.width/2, 18);
    cairo_show_text (cr, text);

    /* XXX we should exercise cairo_show_text_glyphs() as well,
     * and CAIRO_TEXT_CLUSTER_BACKWARDS
     */

    return CAIRO_TEST_SUCCESS;
}
开发者ID:AZed,项目名称:cairo,代码行数:27,代码来源:culled-glyphs.c


示例13: ui_text_extents

static int ui_text_extents(lua_State *L)
{
	struct context *c = lua_touserdata(L, 1);
	const char *str = lua_tostring(L, 2);	

	cairo_text_extents_t te;
	cairo_text_extents (c->cr, str, &te);

	lua_newtable(L);

	lua_pushnumber(L, te.x_bearing);
	lua_setfield(L, -2, "x_bearing");

	lua_pushnumber(L, te.y_bearing);
	lua_setfield(L, -2, "y_bearing");

	lua_pushnumber(L, te.width);
	lua_setfield(L, -2, "width");

	lua_pushnumber(L, te.height);
	lua_setfield(L, -2, "height");

	lua_pushnumber(L, te.x_advance);
	lua_setfield(L, -2, "x_advance");

	lua_pushnumber(L, te.y_advance);
	lua_setfield(L, -2, "y_advance");	

	return 1;
}
开发者ID:rtitmuss,项目名称:opencalc,代码行数:30,代码来源:ui.c


示例14: cairo_save

void GraphicsLayerTextureMapper::drawRepaintCounter(GraphicsContext* context)
{
    cairo_t* cr = context->platformContext()->cr();
    cairo_save(cr);

    CString repaintCount = String::format("%i", this->repaintCount()).utf8();
    cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size(cr, 18);

    cairo_text_extents_t repaintTextExtents;
    cairo_text_extents(cr, repaintCount.data(), &repaintTextExtents);

    static const int repaintCountBorderWidth = 10;
    setSourceRGBAFromColor(cr, isShowingDebugBorder() ? m_debugBorderColor : Color(0, 255, 0, 127));
    cairo_rectangle(cr, 0, 0,
        repaintTextExtents.width + (repaintCountBorderWidth * 2),
        repaintTextExtents.height + (repaintCountBorderWidth * 2));
    cairo_fill(cr);

    cairo_set_source_rgb(cr, 1, 1, 1);
    cairo_move_to(cr, repaintCountBorderWidth, repaintTextExtents.height + repaintCountBorderWidth);
    cairo_show_text(cr, repaintCount.data());

    cairo_restore(cr);
}
开发者ID:jiezh,项目名称:h5vcc,代码行数:25,代码来源:GraphicsLayerTextureMapper.cpp


示例15: ng_view_render_hints

void ng_view_render_hints(cairo_surface_t *surf, guint gridsize, guint32 *hints, guint16 *offsets,
                          guint16 count, enum ORIENTATION orientation)
{
    cairo_t *cr = cairo_create(surf);
    guint i, offset = 0, col=0, row=1;
    gchar buf[8];
    cairo_text_extents_t extents;

    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
    cairo_set_font_size(cr, 10);
    for (i = 0; i < count; ++i) {
        while (offset < offsets[i+1]) {
            snprintf(buf, 8, "%d", NG_HINT_NUM(hints[offset]));
            cairo_text_extents(cr, buf, &extents);
            cairo_move_to(cr, (col + 0.5) * gridsize - extents.width * 0.5,
                              (row - 0.5) * gridsize + extents.height * 0.5);
            cairo_show_text(cr, buf);
            if (orientation == ORIENTATION_HORIZONTAL)
                ++col;
            else
                ++row;
            ++offset;
        }
        if (orientation == ORIENTATION_HORIZONTAL) {
            col = 0;
            ++row;
        }
        else {
            row = 1;
            ++col;
        }
    }

    cairo_destroy(cr);
}
开发者ID:lahol,项目名称:nonogram-game,代码行数:35,代码来源:ng-view.c


示例16: addWayPath

void WayRenderer::shield(cairo_t* cr,
		std::list<shared_ptr<Shield> >& shields,
		AssetCache& cache)
{
	if (s->shield_text.str().size() == 0 || s->font_size <= 0.0)
		return;

	// make sure path is initialized
	addWayPath(cr);
	cairo_new_path(cr);

	cairo_save(cr);

	cairo_set_font_size(cr, s->font_size);

	cairo_select_font_face(cr,
				s->font_family.c_str(),
				s->font_style == Style::STYLE_ITALIC ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL,
				s->font_weight == Style::WEIGHT_BOLD ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL
			);

	cairo_text_extents_t textSize;
	cairo_text_extents(cr, s->shield_text.c_str(), &textSize);

	std::list<FloatPoint> positions;
	getShieldPosition(path, positions);

	for (FloatPoint& p : positions)
	{
		addShield(shields, p, &textSize);
	}

	cairo_restore(cr);
}
开发者ID:alacarte-maps,项目名称:alacarte,代码行数:34,代码来源:way_renderer.cpp


示例17: print_area

// Function to write area found on the lower right
void print_area(frame &anim, double area, color clr){

    // Drawing black box underneath "Area"
    cairo_set_source_rgb(anim.frame_ctx[anim.curr_frame], 0, 0, 0);
    cairo_rectangle(anim.frame_ctx[anim.curr_frame], 0, 0, anim.res_x, 20);
    cairo_fill(anim.frame_ctx[anim.curr_frame]);
    std::string area_txt, number;
 
    std::stringstream ss;
    ss << std::setw(3) << area;
    number = ss.str();

    area_txt = "Ratio: " + number;
    //std::cout << area_txt << '\n';

    cairo_set_source_rgb(anim.frame_ctx[anim.curr_frame], clr.r,clr.g,clr.b);

    cairo_text_extents_t textbox;
    cairo_text_extents(anim.frame_ctx[anim.curr_frame], 
                       area_txt.c_str(), &textbox);
    cairo_move_to(anim.frame_ctx[anim.curr_frame], 20, 20);
    cairo_show_text(anim.frame_ctx[anim.curr_frame], area_txt.c_str());

    cairo_stroke(anim.frame_ctx[anim.curr_frame]);

}
开发者ID:leios,项目名称:simuleios,代码行数:27,代码来源:monte_carlo_vis.cpp


示例18: label_tile

static void label_tile(struct _openslide_grid *grid,
                       cairo_t *cr,
                       int64_t tile_col, int64_t tile_row) {
  if (!_openslide_debug(OPENSLIDE_DEBUG_TILES)) {
    return;
  }

  struct bounds bounds = {0, 0, 0, 0};
  grid->ops->get_tile_size(grid, tile_col, tile_row, &bounds);

  cairo_save(cr);
  cairo_set_operator(cr, CAIRO_OPERATOR_OVER);

  cairo_set_source_rgba(cr, 0.6, 0, 0, 0.3);
  cairo_rectangle(cr, 0, 0, bounds.w, bounds.h);
  cairo_stroke(cr);

  cairo_set_source_rgba(cr, 0.6, 0, 0, 1);
  char *str = g_strdup_printf("%" G_GINT64_FORMAT ", %" G_GINT64_FORMAT,
                              tile_col, tile_row);
  cairo_text_extents_t extents;
  cairo_text_extents(cr, str, &extents);
  cairo_move_to(cr,
                (bounds.w - extents.width) / 2,
                (bounds.h + extents.height) / 2);
  cairo_show_text(cr, str);
  g_free(str);

  cairo_restore(cr);
}
开发者ID:AwAkEd,项目名称:openslide,代码行数:30,代码来源:openslide-grid.c


示例19: on_badge_draw

static gboolean on_badge_draw(ClutterCanvas* canvas, cairo_t* cr,
        gint width, gint height, ClutterActor* badge)
{
    g_debug("%s: %d,%d, ", __func__, width, height);

    cairo_set_antialias(cr, CAIRO_ANTIALIAS_BEST);
    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
    cairo_paint_with_alpha(cr, 0.0);

    cairo_arc(cr, width/2, height/2, MIN(width, height)/2.0, 0, 2*M_PI);
    cairo_close_path(cr);

    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_set_source_rgba(cr, 0.6, 0.2, 0.2, 0.8);
    cairo_fill(cr);

    char title[20];
    snprintf(title, 19, "%d", GPOINTER_TO_INT(g_object_get_qdata(G_OBJECT(badge), moses_overview_window_clone_order())));
    cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0);

    cairo_select_font_face(cr, "fantasy", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size(cr, 28.0);

    cairo_text_extents_t te;
    cairo_text_extents(cr, title, &te);
    cairo_move_to(cr, (width - te.width)/2.0 - te.x_bearing, (height - te.height)/2.0 - te.y_bearing);
    cairo_show_text(cr, title);

    return TRUE;
}
开发者ID:AOSC-Dev,项目名称:elsa-shell,代码行数:31,代码来源:overview.c


示例20: on_expose_event_draw_text

static void
on_expose_event_draw_text (GtkWidget *widget, SSWorkspace *workspace)
{
#ifdef HAVE_GTK_2_8
  cairo_t *c;
  cairo_text_extents_t extents;
  int x, y;

  c = gdk_cairo_create (widget->window);
  cairo_select_font_face (c, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
  cairo_set_font_size (c, MINI_WORKSPACE_FONT_HEIGHT);

  cairo_text_extents (c, workspace->title, &extents);
  x = (widget->allocation.width  - extents.width)  / 2;
  y = (widget->allocation.height + extents.height) / 2;

  cairo_set_source_rgba (c, 0, 0, 0, 0.25);
  cairo_move_to (c, x-1, y);
  cairo_show_text (c, workspace->title);
  cairo_set_source_rgba (c, 1, 1, 1, 0.25);
  cairo_move_to (c, x, y+1);
  cairo_show_text (c, workspace->title);
  cairo_destroy (c);
#endif
}
开发者ID:Frenzie,项目名称:smartswitcher,代码行数:25,代码来源:workspace.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cairo_transform函数代码示例发布时间:2022-05-30
下一篇:
C++ cairo_test_log函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap