本文整理汇总了C++中cairo_select_font_face函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_select_font_face函数的具体用法?C++ cairo_select_font_face怎么用?C++ cairo_select_font_face使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_select_font_face函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gtk_clock_draw
static gboolean gtk_clock_draw (GtkWidget *widget, cairo_t *ctx)
{
struct tm *tms;
time_t t;
GtkClockPrivate *priv = GTK_CLOCK(widget)->priv;
g_free(priv->time);
t = time (NULL);
tms = localtime(&t);
priv->time =
g_strdup_printf ("%.2d%c%.2d", tms->tm_hour, priv->secflash ? ':' : ' ', tms->tm_min);
priv->date =
g_strdup_printf ("%s %s , %s", month[tms->tm_mon], day[tms->tm_mday], weekday[tms->tm_wday]);
cairo_set_source_rgba (ctx, 0.0, 0.0, 0.0, 0.6);
cairo_paint (ctx);
cairo_move_to (ctx, 20, 50);
cairo_select_font_face (ctx, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (ctx, 45);
cairo_set_source_rgb (ctx, 1.0, 1.0, 1.0);
cairo_show_text (ctx, priv->time);
cairo_select_font_face (ctx, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (ctx, 24);
cairo_move_to (ctx, 20, 84);
cairo_show_text (ctx, priv->date);
return FALSE;
}
示例2: redraw_handler
static void
redraw_handler(struct widget *widget, void *data)
{
struct cliptest *cliptest = data;
struct geometry *g = cliptest->view.geometry;
struct rectangle allocation;
cairo_t *cr;
cairo_surface_t *surface;
GLfloat ex[8];
GLfloat ey[8];
int n;
n = calculate_edges(&cliptest->view, &g->clip, &g->surf, ex, ey);
widget_get_allocation(cliptest->widget, &allocation);
surface = window_get_surface(cliptest->window);
cr = cairo_create(surface);
widget_get_allocation(cliptest->widget, &allocation);
cairo_rectangle(cr, allocation.x, allocation.y,
allocation.width, allocation.height);
cairo_clip(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba(cr, 0, 0, 0, 1);
cairo_paint(cr);
cairo_translate(cr, allocation.x, allocation.y);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, allocation.width / 2.0, 0.0);
cairo_line_to(cr, allocation.width / 2.0, allocation.height);
cairo_move_to(cr, 0.0, allocation.height / 2.0);
cairo_line_to(cr, allocation.width, allocation.height / 2.0);
cairo_set_source_rgba(cr, 0.5, 0.5, 0.5, 1.0);
cairo_stroke(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_push_group(cr);
cairo_translate(cr, allocation.width / 2.0,
allocation.height / 2.0);
cairo_scale(cr, 4.0, 4.0);
cairo_set_line_width(cr, 0.5);
cairo_set_line_join(cr, CAIRO_LINE_JOIN_BEVEL);
cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr, 5.0);
draw_geometry(cr, &cliptest->view, ex, ey, n);
cairo_pop_group_to_source(cr);
cairo_paint(cr);
cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0);
cairo_select_font_face(cr, "monospace", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 12.0);
draw_coordinates(cr, 10.0, 10.0, ex, ey, n);
cairo_destroy(cr);
cairo_surface_destroy(surface);
}
示例3: draw
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_set_source_rgb (cr, 0, 0, 0); /* black */
cairo_select_font_face (cr, "Bitstream Vera Serif",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, TEXT_SIZE);
cairo_move_to (cr, 0, TEXT_SIZE);
cairo_show_text (cr, "i-am-serif");
cairo_select_font_face (cr, "Bitstream Vera Sans",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_show_text (cr, " i-am-sans");
cairo_select_font_face (cr, "Bitstream Vera Sans Mono",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_show_text (cr, " i-am-mono");
return CAIRO_TEST_SUCCESS;
}
示例4: 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);
}
}
示例5: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 0, 0, 1);
cairo_paint (cr);
cairo_reset_clip (cr);
cairo_clip (cr);
cairo_translate (cr, .5, .5);
cairo_set_source_rgb (cr, 0, 1, 0);
cairo_rectangle (cr, 0, 0, SIZE, SIZE);
cairo_fill_preserve (cr);
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_stroke (cr);
/* https://bugs.freedesktop.org/show_bug.cgi?id=13084 */
cairo_select_font_face (cr,
"Bitstream Vera Sans",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_move_to (cr, 0., SIZE);
cairo_show_text (cr, "cairo");
return CAIRO_TEST_SUCCESS;
}
示例6: selectFontFace_func
static JSBool
selectFontFace_func(JSContext *context,
unsigned argc,
jsval *vp)
{
JS::CallArgs argv = JS::CallArgsFromVp (argc, vp);
JSObject *obj = JSVAL_TO_OBJECT(argv.thisv());
char *family;
cairo_font_slant_t slant;
cairo_font_weight_t weight;
cairo_t *cr;
if (!gjs_parse_call_args(context, "selectFontFace", "sii", argv,
"family", &family,
"slang", &slant,
"weight", &weight))
return JS_FALSE;
cr = gjs_cairo_context_get_context(context, obj);
cairo_select_font_face(cr, family, slant, weight);
g_free(family);
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return JS_FALSE;
argv.rval().set(JSVAL_VOID);
return JS_TRUE;
}
示例7: paint_message
void paint_message(cairo_t *cr, const char *from, const char *content)
{
static char from_buffer[256];
if (strlen(from) > 0)
snprintf(from_buffer, sizeof(from_buffer), "[%s]", from);
else
strncpy(from_buffer, "", sizeof(from_buffer));
cairo_save(cr);
//清空背景
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
//设置字体
cairo_select_font_face (cr, font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, font_size);
//计算文字位置
cairo_text_extents_t extents_from, extents_content;
cairo_text_extents(cr, from_buffer, &extents_from);
cairo_text_extents(cr, content, &extents_content);
int x = (window_width - extents_from.width - extents_content.width) / 2;
if (x < 0)
x = 0;
int y = window_height - 10;
//实现昵称和消息内容
paint_text(cr, from_buffer, x, y, 1, 2, font_color, border_color, shadow_color);
paint_text(cr, content, x + extents_from.width + font_size / 2, y, 1, 2, font_color, border_color, shadow_color);
cairo_restore (cr);
check_cairo_status();
}
示例8: 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);
}
示例9: cairo_select_font_face
// -------------------------------------------------------------------
// - Font services -
// -------------------------------------------------------------------
void CairoDevice::SelectFont( const VGFont * font )
{
cairo_font_slant_t slant = font->GetProperties() & VGFont::kFontItalic ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL;
cairo_font_weight_t weight = font->GetProperties() & VGFont::kFontBold ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL;
cairo_select_font_face (fNativeDevice, font->GetName(), slant, weight);
cairo_set_font_size (fNativeDevice, font->GetSize());
}
示例10: _draw_chip_vectorized
static void
_draw_chip_vectorized(drawing_context_t *ctx,
const chip_descr_t *chip) {
cairo_t *cr = ctx->cr;
debit_log(L_DRAW, "vectorized chip draw");
cairo_rectangle(cr, 0., 0.,
chip->width * SITE_WIDTH,
chip->height * SITE_HEIGHT);
cairo_clip (cr);
/* 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);
iterate_over_sites(chip, draw_site_vector, ctx);
}
示例11: text_entry_draw
static void
text_entry_draw(struct text_entry *entry, cairo_t *cr)
{
cairo_save(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_rectangle(cr, entry->allocation.x, entry->allocation.y, entry->allocation.width, entry->allocation.height);
cairo_clip(cr);
cairo_translate(cr, entry->allocation.x, entry->allocation.y);
cairo_rectangle(cr, 0, 0, entry->allocation.width, entry->allocation.height);
cairo_set_source_rgba(cr, 1, 1, 1, 0.5);
cairo_fill(cr);
if (entry->active) {
cairo_rectangle(cr, 0, 0, entry->allocation.width, entry->allocation.height);
cairo_set_source_rgba(cr, 0, 0, 1, 0.5);
cairo_stroke(cr);
}
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_select_font_face(cr, "sans",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr, 14);
cairo_translate(cr, 10, entry->allocation.height / 2);
cairo_show_text(cr, entry->text);
cairo_restore(cr);
}
示例12: set_font
static void
set_font(DiaRenderer *self, DiaFont *font, real height)
{
DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self);
/* pango/cairo wants the font size, not the (line-) height */
real size = dia_font_get_size (font) * (height / dia_font_get_height (font));
PangoFontDescription *pfd = pango_font_description_copy (dia_font_get_description (font));
DIAG_NOTE(g_message("set_font %f %s", height, dia_font_get_family(font)));
#ifdef HAVE_PANGOCAIRO_H
/* select font and size */
pango_font_description_set_absolute_size (pfd, (int)(size * PANGO_SCALE));
pango_layout_set_font_description (renderer->layout, pfd);
pango_font_description_free (pfd);
#else
if (renderer->cr) {
DiaFontStyle style = dia_font_get_style (font);
const char *family_name = dia_font_get_family(font);
cairo_select_font_face (
renderer->cr,
family_name,
DIA_FONT_STYLE_GET_SLANT(style) == DIA_FONT_NORMAL ? CAIRO_FONT_SLANT_NORMAL : CAIRO_FONT_SLANT_ITALIC,
DIA_FONT_STYLE_GET_WEIGHT(style) < DIA_FONT_MEDIUM ? CAIRO_FONT_WEIGHT_NORMAL : CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (renderer->cr, size);
DIAG_STATE(renderer->cr)
}
示例13: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
const cairo_test_context_t *ctx = cairo_test_get_context (cr);
cairo_pattern_t *pattern;
cairo_set_source_rgb (cr, 1., 1., 1.);
cairo_paint (cr);
cairo_set_source_rgb (cr, 0., 0., 0.);
cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
draw_text (cr);
cairo_translate (cr, SIZE, SIZE);
cairo_rotate (cr, M_PI);
pattern = cairo_test_create_pattern_from_png (ctx, png_filename);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
draw_text (cr);
return CAIRO_TEST_SUCCESS;
}
示例14: main
int main (int argc, char *argv[])
{
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_linuxfb_surface_create(NULL);
cr = cairo_create(surface);
cairo_paint(cr);
cairo_select_font_face(cr, "serif", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr, 80.0);
cairo_set_source_rgb(cr, 1.0, 0.0, 1.0);
cairo_move_to(cr, 00.0, 100.0);
cairo_show_text(cr, "Hello");
cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
cairo_move_to(cr, 00.0, 180.0);
cairo_show_text(cr, "World!");
cairo_destroy(cr);
cairo_surface_destroy(surface);
return 0;
}
示例15: selectFontFace_func
static bool
selectFontFace_func(JSContext *context,
unsigned argc,
JS::Value *vp)
{
GJS_GET_PRIV(context, argc, vp, argv, obj, GjsCairoContext, priv);
char *family;
cairo_font_slant_t slant;
cairo_font_weight_t weight;
cairo_t *cr = priv ? priv->cr : NULL;
if (!gjs_parse_call_args(context, "selectFontFace", argv, "sii",
"family", &family,
"slang", &slant,
"weight", &weight))
return false;
cairo_select_font_face(cr, family, slant, weight);
g_free(family);
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return false;
argv.rval().setUndefined();
return true;
}