本文整理汇总了C++中cairo_set_font_face函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_set_font_face函数的具体用法?C++ cairo_set_font_face怎么用?C++ cairo_set_font_face使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_set_font_face函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_keyvalue
int render_keyvalue(cairo_t *cairo, int x, int y, char *k, char *v , int d) {
uint32_t render_x;
cairo_text_extents_t k_extents;
cairo_text_extents_t v_extents;
//we must set the fonts to measure extents
cairo_set_font_face(cairo, conf->keyfont);
cairo_set_font_size(cairo, conf->keyfontsize);
cairo_text_extents(cairo, k, &k_extents);
cairo_set_font_face(cairo, conf->valfont);
cairo_set_font_size(cairo, conf->valfontsize);
cairo_text_extents(cairo, v, &v_extents);
//render key
set_cairo_source_colour(cairo, conf->keycol);
cairo_set_font_face(cairo, conf->keyfont);
cairo_set_font_size(cairo, conf->keyfontsize);
render_x = x;
if(d == RIGHT)
render_x = x - (k_extents.width + v_extents.width + conf->kvpadding);
cairo_move_to(cairo, render_x, y);
cairo_show_text(cairo, k);
//render value
set_cairo_source_colour(cairo, conf->valcol);
cairo_set_font_face(cairo, conf->valfont);
cairo_set_font_size(cairo, conf->valfontsize);
render_x = x + k_extents.width + conf->kvpadding;
if(d == RIGHT)
render_x = x - v_extents.width;
cairo_move_to(cairo, render_x, y);
cairo_show_text(cairo, v);
return k_extents.width + conf->kvpadding + v_extents.width;
}
示例2: cairo_set_font_face
void CairoRenderer::SetFontFace(InputStream *pStream)
{
FT_Face face;
static cairo_user_data_key_t key;
if (m_cairo_face)
{
cairo_set_font_face(m_pCairo, NULL);
cairo_font_face_destroy(m_cairo_face);
m_cairo_face = NULL;
}
if (pStream)
{
face = FreeType::OpenFace(pStream); // face will be destroyed by FT_Done_Face
if (face)
{
m_cairo_face = cairo_ft_font_face_create_for_ft_face(face, 0);
cairo_font_face_set_user_data(m_cairo_face, &key, face, (cairo_destroy_func_t)FT_Done_Face);
}
}
else
m_cairo_face = cairo_toy_font_face_create("unifont", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
if (m_cairo_face)
cairo_set_font_face(m_pCairo, m_cairo_face);
}
示例3: pycairo_set_font_face
static PyObject *
pycairo_set_font_face (PycairoContext *o, PyObject *obj) {
if (PyObject_TypeCheck(obj, &PycairoFontFace_Type))
cairo_set_font_face (o->ctx, ((PycairoFontFace *)obj)->font_face);
else if (obj == Py_None)
cairo_set_font_face (o->ctx, NULL);
else {
PyErr_SetString(PyExc_TypeError,
"Context.set_font_face() argument must be "
"cairo.FontFace or None");
return NULL;
}
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
}
示例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;
}
示例5: cr_set_font_face
static VALUE
cr_set_font_face (VALUE self, VALUE face)
{
cairo_set_font_face (_SELF, NIL_P (face) ? NULL : RVAL2CRFONTFACE (face));
cr_check_status (_SELF);
return self;
}
示例6: clearSurface
void label_t::paint() {
clearSurface();
auto cr = graphics.getContext();
auto bounds = getBounds();
cairo_set_source_rgb(cr, 0, 0, 0);
int textLeft;
int textBot = (bounds.height / 2 - lastExtents.height / 2) + lastExtents.height;
if (alignment == g_text_alignment::CENTER) {
textLeft = bounds.width / 2 - lastExtents.width / 2;
} else if (alignment == g_text_alignment::RIGHT) {
textLeft = bounds.width - lastExtents.width;
} else {
textLeft = 0;
}
cairo_move_to(cr, textLeft, textBot);
cairo_set_font_face(cr, font->getFace());
cairo_set_font_size(cr, fontSize);
cairo_show_text(cr, text.c_str());
}
示例7: draw
static void
draw (GtkWidget *drawing_area,
cairo_t *cr,
FT_Face face)
{
cairo_font_extents_t font_extents;
gint *sizes = NULL, n_sizes, alpha_size, pos_y, i;
const gchar *text;
cairo_font_face_t *font;
text = get_sample_string (face);
sizes = build_sizes_table (face, &n_sizes, &alpha_size);
font = cairo_ft_font_face_create_for_ft_face (face, 0);
cairo_set_font_face (cr, font);
cairo_font_extents (cr, &font_extents);
cairo_font_face_destroy (font);
/* draw text */
pos_y = MAX (font_extents.height, 32) + 4;
cairo_set_font_size (cr, alpha_size);
draw_string (cr, lowercase_text, &pos_y);
draw_string (cr, uppercase_text, &pos_y);
draw_string (cr, punctuation_text, &pos_y);
pos_y += 8;
for (i = 0; i < n_sizes; i++) {
cairo_set_font_size (cr, sizes[i]);
draw_string (cr, text, &pos_y);
}
g_free (sizes);
}
示例8: toolwin_win_create
int toolwin_win_create(ToolWin *tw) {
tw->win = XCreateSimpleWindow(dpy, root, 20, 20, tw->w, tw->h, 0, 0, 0);
tw->buf = XCreatePixmap(dpy, root, tw->w, tw->h, DefaultDepth(dpy,scr));
cairo_surface_t *t = cairo_xlib_surface_create(dpy, tw->buf,
DefaultVisual(dpy,scr), tw->w, tw->h);
tw->ctx = cairo_create(t);
cairo_surface_destroy(t);
cairo_set_font_face(tw->ctx,conf.font);
cairo_set_font_size(tw->ctx,conf.font_size);
XSelectInput(dpy, tw->win, EVENT_MASK);
XSetTransientForHint(dpy, tw->win, win);
XSetWMProtocols(dpy, tw->win, &WM_DELETE_WINDOW, 1);
XSizeHints *hints = XAllocSizeHints();
hints->min_width = hints->max_width = tw->w;
hints->min_height = hints->max_height = tw->h;
hints->flags = PMinSize | PMaxSize;
XSetWMNormalHints(dpy, tw->win, hints);
XFree(hints);
XStoreName(dpy, tw->win, tw->name);
if (tw->backing) tw->backing(tw);
else toolwin_backing(tw);
XSetWindowBackgroundPixmap(dpy, tw->win, tw->buf);
XFlush(dpy);
return 0;
}
示例9: ilG_gui_textlayout_getExtents
void ilG_gui_textlayout_getExtents(ilG_gui_textlayout *self, unsigned *rx, unsigned *ry, int *bx, int *by, int *ax, int *ay)
{
if (!self->have_size) {
self->have_size = 1;
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0);
cairo_t *cr = cairo_create(surface);
il_return_on_fail(self->cairo_glyphs);
cairo_set_font_face(cr, self->cairo_ft_face);
cairo_set_font_size(cr, self->pt);
cairo_glyph_extents(cr, self->cairo_glyphs, self->glyph_count, &self->extents);
cairo_surface_destroy(surface);
cairo_destroy(cr);
}
if (rx) {
*rx = self->extents.width;
}
if (ry) {
*ry = self->extents.height + 1; // TODO: ????
}
if (bx) {
*bx = self->extents.x_bearing;
}
if (by) {
*by = self->extents.y_bearing;
}
if (ax) {
*ax = self->extents.x_advance;
}
if (ay) {
*ay = self->extents.y_advance;
}
}
示例10: info_draw
static int info_draw(ToolWin *tw) {
toolwin_backing(tw);
/* info */
cairo_set_source_rgba(tw->ctx,0,0,0,1.0);
cairo_set_font_face(tw->ctx, conf.bfont);
cairo_move_to(tw->ctx, 0, 8);
info_printf(tw, A_CENTER, "%.3lf sec, %.2lf KHz",
spect->fft->time[mx],spect->fft->freq[my]);
cairo_rel_move_to(tw->ctx,0,12);
info_split_printf(tw, "Threshold:", "%.2lf", -1.0 * conf.thresh);
info_split_printf(tw, "Spectrogram Floor:", "%.2lf",
-1.0 * conf.spect_floor);
info_split_printf(tw, "Path Length:","%.2lf", spect->pex);
info_split_printf(tw, "Path Duration:","%.3lf", spect->tex);
info_split_printf(tw, "Frequency Excursion:","%.3lf", spect->fex);
cairo_move_to(tw->ctx, 0, 145);
/* modes */
info_split_printf(tw, "Modes:","");
cairo_set_font_face(tw->ctx, conf.bfont);
/* erase */
set_color(tw->ctx,RGBA_ERASE1)
if (mode & MODE_ERASE) set_color(tw->ctx,RGBA_ERASE1)
else cairo_set_source_rgba(tw->ctx,0.8,0.8,0.8,1.0);
cairo_rectangle(tw->ctx, 10, 170, tw->w / 2.0 - 15, 20);
cairo_fill_preserve(tw->ctx);
cairo_set_source_rgba(tw->ctx,0,0,0,1.0);
cairo_stroke(tw->ctx);
cairo_text_extents(tw->ctx,"Erase",&ext);
cairo_move_to(tw->ctx, tw->w / 4.0 - ext.width / 2.0, 185);
cairo_set_source_rgba(tw->ctx,0,0,0,1.0);
cairo_show_text(tw->ctx,"Erase");
/* crop */
if (mode & MODE_CROP) set_color(tw->ctx, RGBA_CROP)
else cairo_set_source_rgba(tw->ctx,0.8,0.8,0.8,1.0);
cairo_rectangle(tw->ctx, 5 + tw->w / 2.0, 170, tw->w / 2.0 - 15, 20);
cairo_fill_preserve(tw->ctx);
cairo_set_source_rgba(tw->ctx,0.0,0.0,0.0,1.0);
cairo_stroke(tw->ctx);
cairo_text_extents(tw->ctx,"Crop",&ext);
cairo_move_to(tw->ctx, tw->w * 0.75 - ext.width / 2.0, 185);
cairo_set_source_rgba(tw->ctx,0,0,0,1.0);
cairo_show_text(tw->ctx,"Crop");
/* draw */
toolwin_draw(tw);
return 0;
}
示例11: renderTruetypeSymbolCairo
int renderTruetypeSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol,
symbolStyleObj *s)
{
int unicode;
cairo_glyph_t glyph;
cairo_text_extents_t extents;
cairo_matrix_t trans;
double ox,oy;
cairoCacheData *cache = MS_IMAGE_RENDERER_CACHE(img);
cairo_renderer *r = CAIRO_RENDERER(img);
faceCacheObj *face = getFontFace(cache,symbol->full_font_path);
if(!face) return MS_FAILURE;
cairo_save(r->cr);
cairo_set_font_face(r->cr,face->face);
cairo_set_font_size(r->cr,s->scale*96/72.0);
msUTF8ToUniChar(symbol->character, &unicode);
if (face->ftface->charmap &&
face->ftface->charmap->encoding == FT_ENCODING_MS_SYMBOL)
unicode |= 0xf000;
glyph.index = FT_Get_Char_Index(face->ftface, unicode);
glyph.x=0;
glyph.y=0;
cairo_glyph_extents(r->cr,&glyph,1,&extents);
ox=extents.x_bearing+extents.width/2.;
oy=extents.y_bearing+extents.height/2.;
cairo_matrix_init_rotate(&trans,-s->rotation);
cairo_matrix_transform_point(&trans,&ox,&oy);
/* cairo_translate(cr,-extents.width/2,-extents.height/2); */
cairo_translate(r->cr,x-ox,y-oy);
cairo_rotate(r->cr, -s->rotation);
cairo_glyph_path(r->cr,&glyph,1);
if (s->outlinewidth) {
msCairoSetSourceColor(r->cr, s->outlinecolor);
cairo_set_line_width(r->cr, s->outlinewidth + 1);
cairo_stroke_preserve(r->cr);
}
if(s->color) {
msCairoSetSourceColor(r->cr, s->color);
cairo_fill_preserve(r->cr);
}
cairo_new_path(r->cr);
cairo_restore(r->cr);
return MS_SUCCESS;
}
示例12: cairo_set_font_face_l
static int cairo_set_font_face_l( lua_State* L )
{
lua_cairo_t* lc = lua_cairo_check( L, 1 );
lua_cairo_font_face_t* lcff = lua_cairo_font_face_check( L, 2 );
cairo_set_font_face( lc->cairo, lcff->crface );
return( 0 );
}
示例13: info_split_printf
static int info_split_printf(ToolWin *tw, char *bold, char *fmt, ...) {
char str[MAX_STRING];
va_list arg;
va_start(arg, fmt);
vsprintf(str, fmt, arg);
va_end(arg);
cairo_set_font_face(tw->ctx, conf.bfont);
cairo_text_extents(tw->ctx,bold,&ext);
cairo_rel_move_to(tw->ctx, MARGIN, conf.font_size);
cairo_show_text(tw->ctx,bold);
cairo_rel_move_to(tw->ctx, -1.0 * ext.x_advance - MARGIN, 0);
cairo_set_font_face(tw->ctx, conf.font);
cairo_text_extents(tw->ctx,str,&ext);
cairo_rel_move_to(tw->ctx, tw->w - ext.x_advance - MARGIN, 0);
cairo_show_text(tw->ctx,str);
cairo_rel_move_to(tw->ctx, MARGIN - tw->w, conf.font_size / 3.0);
return 0;
}
示例14: cr_set_font_face
static int
cr_set_font_face (lua_State *L) {
cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
cairo_font_face_t *face = 0;
if (!lua_isnoneornil(L, 2))
face = *(cairo_font_face_t **) luaL_checkudata(L, 2, OOCAIRO_MT_NAME_FONTFACE);
cairo_set_font_face(*obj, face);
return 0;
}
示例15: switch
void Aw::Label::getMetrics(cairo_t *cr, Size& min_size, bool& expandh, bool& expandv)
{
// We over-ride the
switch (m_font_type)
{
case font_type::normal:
cairo_set_font_face(cr, theApp->m_font.m_norm_face);
break;
case font_type::bold:
cairo_set_font_face(cr, theApp->m_font.m_bold_face);
break;
case font_type::mono:
cairo_set_font_face(cr, theApp->m_font.m_mono_face);
break;
}
cairo_text_extents_t te;
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_font_size(cr, m_font_size);
cairo_text_extents (cr, m_text.c_str(), &te);
// anvil_syslog(0, "TEXT: %s %d %d %d %d %d %d\n",
// m_text.c_str(),
// (int)te.width,
// (int)te.height,
// (int)te.x_advance,
// (int)te.y_advance,
// (int)te.x_bearing,
// (int)te.y_bearing
// );
min_size = getMinSize();
if (te.width + 10 > min_size.m_width)
{
min_size.m_width = te.width + 10;
}
if (te.height + 10 > min_size.m_height)
{
min_size.m_height = te.height + 10;
}
expandh = expandH();
expandv = expandV();
}