// Den Text zeichnen static void draw_text (Lcd *lcd, cairo_t *cr) { LcdPrivate *priv; GtkWidget *widget; cairo_text_extents_t extents; cairo_font_options_t *options; gdouble x, y; gchar *text; priv = LCD_GET_PRIVATE (lcd); widget = GTK_WIDGET (lcd); // Text erstellen text = construct_text (LCD (lcd)); // Farbe setzen cairo_set_source_rgb (cr, 0, 0, 0); // Font setzen //cairo_select_font_face (cr, "Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); //cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); //cairo_select_font_face (cr, "Ubuntu-Title", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_select_font_face (cr, "Purisa", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, 24); cairo_text_extents (cr, text, &extents); // Font-Antialiasing ausschalten options = cairo_font_options_create (); //cairo_get_font_options (cr, options); if (!options) { g_message ("Font-Antialiasing ausschalten"); cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_NONE); cairo_set_font_options (cr, options); } // Nur sliden wenn Text grösser als Platz ist if (extents.width < widget->allocation.width - FRAME_ABSTAND) { // Text horizontal zentrieren priv->current_x = (widget->allocation.width / 2) - (extents.width / 2); } else if ((priv->current_x + extents.width) <= 0) { // falls Text zu Ende -> wieder hinten anfangen priv->current_x = widget->allocation.width; } x = priv->current_x; y = (widget->allocation.height / 2) + (extents.height / 2) - (extents.height + extents.y_bearing); //g_debug ("text position: x=%.1f y=%.1f", x, y); cairo_move_to (cr, x, y); cairo_show_text (cr, text); // Debug Rechteck zeichnen //cairo_set_line_width (cr, 1); //cairo_set_source_rgb (cr, 1, 0, 0); //cairo_rectangle (cr, x, y-extents.height, extents.width, extents.height); //cairo_stroke (cr); }
static PyObject *Revision_get_object_data( Revision *self, PyObject *args, PyObject *kwds) { PyObject *ob_arg = NULL; static char *kwlist[] = { "ob", NULL }; if (!PyArg_ParseTupleAndKeywords( args, kwds, "O!:Revision.get_object_data", kwlist, &ObjectType, &ob_arg)) return NULL; xorn_object_t ob = ((Object *)ob_arg)->ob; xorn_obtype_t type = xorn_get_object_type(self->rev, ob); switch (type) { case xorn_obtype_none: PyErr_SetNone(PyExc_KeyError); return NULL; case xornsch_obtype_arc: return construct_arc(xornsch_get_arc_data(self->rev, ob)); case xornsch_obtype_box: return construct_box(xornsch_get_box_data(self->rev, ob)); case xornsch_obtype_circle: return construct_circle( xornsch_get_circle_data(self->rev, ob)); case xornsch_obtype_component: return construct_component( xornsch_get_component_data(self->rev, ob)); case xornsch_obtype_line: return construct_line(xornsch_get_line_data(self->rev, ob)); case xornsch_obtype_net: return construct_net(xornsch_get_net_data(self->rev, ob)); case xornsch_obtype_path: return construct_path(xornsch_get_path_data(self->rev, ob)); case xornsch_obtype_picture: return construct_picture( xornsch_get_picture_data(self->rev, ob)); case xornsch_obtype_text: return construct_text(xornsch_get_text_data(self->rev, ob)); } char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "Object type not supported (%d)", type); PyErr_SetString(PyExc_ValueError, buf); return NULL; }