void
ol_osd_render_paint_text (OlOsdRenderContext *context,
                          cairo_t *cr,
                          const char *text,
                          double xpos,
                          double ypos)
{
  ol_assert (context != NULL);
  ol_assert (cr != NULL);
  ol_assert (text != NULL);
  ol_osd_render_set_text (context, text);
  int width, height;
  xpos += context->outline_width / 2.0 + context->blur_radius;
  ypos += context->outline_width / 2.0 + context->blur_radius;
  pango_layout_get_pixel_size (context->pango_layout, &width, &height);
  /* draws the outline of the text */
  cairo_move_to (cr, xpos, ypos);
  cairo_save (cr);
  pango_cairo_layout_path(cr, context->pango_layout);
  cairo_set_source_rgb (cr, ol_color_black.r, ol_color_black.g, ol_color_black.b);
  if (context->outline_width > 0)
  {
    cairo_set_line_width (cr, context->outline_width);
    if (context->blur_radius > 1e-4)
    {
      cairo_stroke_preserve (cr);
      cairo_fill (cr);
      ol_gussian_blur (cairo_get_target (cr), context->blur_radius);
    }
    else
    {
      cairo_stroke (cr);
    }
  }
  cairo_restore (cr);
  cairo_save (cr);
  cairo_new_path (cr);
  /* creates the linear pattern */
  cairo_pattern_t *pattern = cairo_pattern_create_linear (xpos, ypos, xpos, ypos + height);
  int i;
  for (i = 0; i < OL_LINEAR_COLOR_COUNT; i++)
  {
    cairo_pattern_add_color_stop_rgb(pattern,
                                     context->linear_pos[i],
                                     context->linear_colors[i].r,
                                     context->linear_colors[i].g,
                                     context->linear_colors[i].b);
  }
  cairo_set_source (cr, pattern);
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
  /* draws the text */
  cairo_move_to (cr, xpos, ypos);
  pango_cairo_show_layout (cr, context->pango_layout);
  cairo_pattern_destroy (pattern);
  cairo_restore (cr);
}
static void
gimp_display_shell_canvas_draw_drop_zone (GimpDisplayShell *shell,
                                          cairo_t          *cr)
{
  cairo_save (cr);

  gimp_display_shell_draw_background (shell, cr);

  gimp_cairo_draw_drop_wilber (shell->canvas, cr, shell->blink);

  cairo_restore (cr);

#ifdef GIMP_UNSTABLE
  {
    PangoLayout   *layout;
    const gchar   *version;
    gchar         *short_hash;
    gchar         *msg;
    GtkAllocation  allocation;
    gint           width;
    gint           height;
    gdouble        scale;

    layout = gtk_widget_create_pango_layout (shell->canvas, NULL);

    version = GIMP_GIT_VERSION;
    short_hash = g_strdup (version + strlen (version) - 7);
    msg = g_strdup_printf (_("<big>Unstable Development Version</big>\n\n"
                             "<small>commit <tt>%s</tt></small>\n\n"
                             "<small>Please test bugs against "
                             "latest git master branch\n"
                             "before reporting them.</small>"),
                             short_hash);
    pango_layout_set_markup (layout, msg, -1);
    g_free (msg);
    g_free (short_hash);
    pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);

    pango_layout_get_pixel_size (layout, &width, &height);
    gtk_widget_get_allocation (shell->canvas, &allocation);

    scale = MIN (((gdouble) allocation.width  / 2.0) / (gdouble) width,
                 ((gdouble) allocation.height / 2.0) / (gdouble) height);

    cairo_move_to (cr,
                   (allocation.width  - (width  * scale)) / 2,
                   (allocation.height - (height * scale)) / 2);

    cairo_scale (cr, scale, scale);

    pango_cairo_show_layout (cr, layout);

    g_object_unref (layout);
  }
#endif /* GIMP_UNSTABLE */
}
Beispiel #3
0
static void
karea_get_char_size (GtkWidget *widget,
		     int       *width,
		     int       *height)
{
  PangoLayout *layout = gtk_widget_create_pango_layout (widget, "\xe6\xb6\x88");
  pango_layout_get_pixel_size (layout, width, height);

  g_object_unref (layout);
}
Beispiel #4
0
gint rc_ui_scrollable_label_get_width(RCUiScrollableLabel *widget)
{
    RCUiScrollableLabelPrivate *priv;
    gint width = 0;
    if(widget==NULL) return 0;
    priv = RC_UI_SCROLLABLE_LABEL(widget)->priv;
    if(priv==NULL || priv->layout==NULL) return 0;
    pango_layout_get_pixel_size(priv->layout, &width, NULL);
    return width;
}
Beispiel #5
0
Size pFont::size(PangoFontDescription* font, string text) {
  PangoContext* context = gdk_pango_context_get_for_screen(gdk_screen_get_default());
  PangoLayout* layout = pango_layout_new(context);
  pango_layout_set_font_description(layout, font);
  pango_layout_set_text(layout, text, -1);
  int width = 0, height = 0;
  pango_layout_get_pixel_size(layout, &width, &height);
  g_object_unref((gpointer)layout);
  return {width, height};
}
Beispiel #6
0
void
tViewer::draw (gint status)
{
	gint x1=0, y1=0, x2, y2, h1, h2;

	gdk_gc_set_foreground (gc, &color);
	gint w;
	pango_layout_get_pixel_size(layout_m,&w,&h2);
	x2 = (Skin->revise_skim.viewer.w -
			w
	      /*gdk_string_width (gtk_style_get_font (text_area->style),
				str2)*/) / 2;
	//h2 = gdk_string_height (gtk_style_get_font (text_area->style), str2);
	if (status == 4)
	{
		y2 = (Skin->revise_skim.viewer.h - h2) / 2;
	}
	else
	{
		pango_layout_get_pixel_size(layout_w,&w,&h1);
		x1 = (Skin->revise_skim.viewer.w -
		      w) / 2;
		/*x1 = (Skin->revise_skim.viewer.w -
		      gdk_string_width (Skin->text.font, str1)) / 2;
		h1 = gdk_string_height (Skin->text.font, str1);*/		
		y1 = (Skin->revise_skim.viewer.h - (h1 + h2 + 10)) / 2 ;
		y2 = y1 + h1 + 10;
	}
	if ((status == 1) || (status == 3))
	{
		gdk_draw_layout(draw_pixmap,gc,x1,y1,layout_w);
		/*gdk_draw_string (draw_pixmap, Skin->text.font,
				 gc, x1, y1, str1);*/
	}
	if ((status == 2) || (status == 3) || (status == 4))
	{
		gdk_draw_layout(draw_pixmap,gc,x2,y2,layout_m);
		/*gdk_draw_string (draw_pixmap,
				 gtk_style_get_font (text_area->style), gc,
				 x2, y2, str2);*/
	}
	gtk_widget_queue_draw (text_area);
}
			void GuiSolidLabelElementRenderer::Render(Rect bounds)
			{
				if(cairoContext)
				{
					cairo_save(cairoContext);
					Color color = element->GetColor();
					FontProperties font = element->GetFont();

					cairo_set_source_rgba(cairoContext, 
							1.0 * color.r / 255, 
							1.0 * color.g / 255, 
							1.0 * color.b / 255,
							1.0 * color.a / 255
							);

					if(element->GetWrapLine()) pango_layout_set_width(layout, bounds.Width() * PANGO_SCALE);
					pango_cairo_update_layout(cairoContext, layout);
					int layoutWidth, layoutHeight;
					int plotX1, plotY1;

					pango_layout_get_pixel_size( layout, &layoutWidth, &layoutHeight);
					switch(element->GetHorizontalAlignment())
					{
					case Alignment::Left:
						plotX1 = bounds.x1;
						break;
					case Alignment::Center:
						plotX1 = bounds.x1 + (bounds.Width() - layoutWidth) / 2;
						break;
					case Alignment::Right:
						plotX1 = bounds.x1 + (bounds.Width() - layoutWidth);
						break;
					}

					switch(element->GetVerticalAlignment())
					{
					case Alignment::Top:
						plotY1 = bounds.y1;
						break;
					case Alignment::Center:
						plotY1 = bounds.y1 + (bounds.Height() - layoutHeight) / 2;
						break;
					case Alignment::Bottom:
						plotY1 = bounds.y1 + (bounds.Height() - layoutHeight);
						break;
					}

					cairo_move_to(cairoContext, plotX1, plotY1);

					pango_cairo_layout_path(cairoContext, layout);
					cairo_fill(cairoContext);

					cairo_restore(cairoContext);
				}
			}
Beispiel #8
0
// Notice we don't check here the font. It is supposed to be OK before the call.
void wxTextMeasure::DoGetTextExtent(const wxString& string,
                                    wxCoord *width,
                                    wxCoord *height,
                                    wxCoord *descent,
                                    wxCoord *externalLeading)
{
    if ( !m_context )
    {
        if ( width )
            *width = 0;

        if ( height )
            *height = 0;
        return;
    }

    // Set layout's text
    const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(string, GetFont());
    if ( !dataUTF8 )
    {
        // hardly ideal, but what else can we do if conversion failed?
        wxLogLastError(wxT("GetTextExtent"));
        return;
    }
    pango_layout_set_text(m_layout, dataUTF8, -1);

    if ( m_dc )
    {
        // in device units
        pango_layout_get_pixel_size(m_layout, width, height);
    }
    else // win
    {
        // the logical rect bounds the ink rect
        PangoRectangle rect;
        pango_layout_get_extents(m_layout, NULL, &rect);
        *width = PANGO_PIXELS(rect.width);
        *height = PANGO_PIXELS(rect.height);
    }

    if (descent)
    {
        PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
        int baseline = pango_layout_iter_get_baseline(iter);
        pango_layout_iter_free(iter);
        *descent = *height - PANGO_PIXELS(baseline);
    }

    if (externalLeading)
    {
        // No support for MSW-like "external leading" in Pango.
        *externalLeading = 0;
    }
}
static int
text_height (PangoLayout *layout, const gchar *text)
{
	int height;

	pango_layout_set_text (layout, text, -1);

	pango_layout_get_pixel_size (layout, NULL, &height);

	return height;
}
Beispiel #10
0
Datei: font.c Projekt: Airr/Claro
int cgraphics_widget_font_string_width( widget_t *w, char *text, int chars )
{
	PangoLayout *layout = gtk_widget_create_pango_layout( w->native, text );
	int width, height;
	
	pango_layout_get_pixel_size( layout, &width, &height );
	
	g_object_unref( G_OBJECT(layout) );
	
	return width;
}
Beispiel #11
0
EXPORT int audgui_get_digit_width (GtkWidget * widget)
{
    int width;
    PangoLayout * layout = gtk_widget_create_pango_layout (widget, "0123456789");
    PangoFontDescription * desc = pango_font_description_new ();
    pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
    pango_layout_set_font_description (layout, desc);
    pango_layout_get_pixel_size (layout, & width, NULL);
    pango_font_description_free (desc);
    return (width + 9) / 10;
}
Beispiel #12
0
static gint timeout(gpointer user_data)
{
    GtkWidget *image = user_data;
    PangoLayout *layout;
    GdkRectangle area;
    gint offset_x = 0;

    if (about_timeout < 0)
        return FALSE;

    layout = gtk_widget_create_pango_layout(image, NULL);

    pango_layout_set_markup(layout, about_text, -1);
    pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
    pango_layout_set_justify(layout, TRUE);

    if (about_y <= 0 && about_area_y <= 0)
    {
        about_y = image->allocation.width - 80;
        pango_layout_get_pixel_size(layout, &about_area_x, &about_area_y);
        if (about_area_x > image->allocation.width)
        {
            GdkPixmap *old = pixmap;
            gtk_widget_set_size_request(image, about_area_x, 200);

            pixmap = gdk_pixmap_new(image->window, about_area_x, image->allocation.height, -1);
            gdk_pixmap_unref(old);
        }
    }

    if (image->allocation.width > about_area_x)
        offset_x = (image->allocation.width - about_area_x) / 2;

    if (about_y <= 0)
        about_area_y--;

    about_y--;

    area.x = 0;
    area.y = 0;
    area.width = image->allocation.width;
    area.height = image->allocation.height;

    gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, image->allocation.width, image->allocation.height);

    gtk_paint_layout(image->style, pixmap, GTK_WIDGET_STATE(image), FALSE, &area, image, "about", image->allocation.x + offset_x, about_y, layout);

    gdk_draw_drawable(image->window, gc, pixmap, 0, 0, 0, 0, image->allocation.width, image->allocation.height);

    g_object_unref(layout);

    return TRUE;
}
Beispiel #13
0
//	Wyznaczenie obszarów wymaganego do umieszczenia opisow osi. Szerokosci obszarow
//	sa obliczane na podstawie zgrubnych oszacowan maksymalnych wielkosci etykiet.
//	Z zalozenia opisy osi pionowej sa z lewej strony, a opisy osi poziomej u dolu.
//
int t_display_calculate_borders (T_Display *w)
{
		PangoLayout *etykieta, *et_temp ;
		int et_szer, et_wys ;
		unsigned int n_labels_x ;
		
		// rozmiar opisu osi pionowej
		et_temp = gtk_widget_create_pango_layout (w->canvas,"-99");	// temperatura
		pango_layout_get_pixel_size (et_temp, &et_szer, &et_wys) ;
		w->x_pixel_offset = et_szer + 2*LABEL_MARGIN ;	// z lewej strony opisy zawsze poziomo
		
		//rozmiar opisu osi poziomej
		etykieta = gtk_widget_create_pango_layout (w->canvas,"99:99"); // czas
		pango_layout_get_pixel_size (etykieta, &et_szer, &et_wys) ;
		
		// czy trzeba obracac opisy osi poziomej
		n_labels_x = w->time_range / w->time_step ;
		if (n_labels_x*(et_szer + LABEL_MARGIN) > t_display_graph_pixel_width(w)) {
				w->y_pixel_offset = et_szer + 2*LABEL_MARGIN ;		// opisy pionowo
				w->x_labels_vert = TRUE ;
		} else {
				w->y_pixel_offset = et_wys + 2*LABEL_MARGIN ;
				w->x_labels_vert = FALSE ;
		} ;
		
		/*printf ("t_display_calculate_borders: x_offset = %d, y_offset = %d, vertical = ",
		/				w->x_pixel_offset, w->y_pixel_offset) ;
		if (w->x_labels_vert == TRUE) 
		printf ("TRUE\n") ;
		else
		printf ("FALSE\n") ;
		*/
		
		w->y_pixel_offset += w->legend_height ;
		
		g_object_unref(etykieta) ;
		g_object_unref(et_temp) ;
		
		return 0 ;
} ;
static void
ellipsize_layout (PangoLayout *layout, gint width)
{
    PangoLayoutLine *line;
    PangoLayout *ell;
    gint h, w, ell_w, x;
    GString *text;
    
    if (width <= 0) {
        pango_layout_set_text (layout, "", -1);
        return;
    }
    
    pango_layout_get_pixel_size (layout, &w, &h);
    if (w <= width) return;
    
    /* calculate ellipsis width */
    ell = pango_layout_copy (layout);
    pango_layout_set_text (ell, ELLIPSIS, -1);
    pango_layout_get_pixel_size (ell, &ell_w, NULL);
    g_object_unref (ell);

    if (width < ell_w) {
        /* not even ellipsis fits, so hide the text */
        pango_layout_set_text (layout, "", -1);
        return;
    }

    /* shrink total available width by the width of the ellipsis */
    width -= ell_w;
    line = pango_layout_get_line (layout, 0);
    text = g_string_new (pango_layout_get_text (layout));
    if (pango_layout_line_x_to_index (line, width * PANGO_SCALE, &x, NULL)) {
        g_string_set_size (text, x);
        g_string_append (text, ELLIPSIS);
        pango_layout_set_text (layout, text->str, -1);
    }
    g_string_free (text, TRUE);
}
Beispiel #15
0
gint ygtk_steps_append (YGtkSteps *steps, const gchar *text)
{
	GtkWidget *label = gtk_label_new (text);
	GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
	gtk_widget_override_color (label, GTK_STATE_NORMAL, &black);
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
	int mark_width = 10;
	pango_layout_get_pixel_size (steps->check_mark_layout, &mark_width, NULL);
	gtk_misc_set_padding (GTK_MISC (label), mark_width+12, 0);
	gtk_widget_show (label);
	gtk_box_pack_start (GTK_BOX (steps), label, FALSE, TRUE, 0);
	return ygtk_steps_total (steps)-1;
}
Beispiel #16
0
Datei: cawc.c Projekt: Roger/caw
static PyObject *
_pango_layout_get_pixel_size(PyObject *self, PyObject *args)
{
    PangoLayout *layout;
    int width, height;

    if (!PyArg_ParseTuple(args, "l", &layout))
        return NULL;

    pango_layout_get_pixel_size(layout, &width, &height);

    return Py_BuildValue("ii", width, height);
}
Beispiel #17
0
void LeftMargin::updateTextInfo(GtkTextView *textView)
    {
    char str[8];
    snprintf(str, sizeof(str), "%d",
            gtk_text_buffer_get_line_count(gtk_text_view_get_buffer(textView)));
    pango_layout_set_text(mMarginLayout, str, -1);
    pango_layout_get_pixel_size(mMarginLayout, &mTextWidth, NULL);
    int len = strlen(str);
    if(len > 0)
        mPixPerChar = mTextWidth / len;
    else
        mPixPerChar = 10;
    }
Beispiel #18
0
static int
get_font_height(GtkWidget *widget, const char *str)
{
  int width, height;

  PangoLayout *layout = pango_layout_new (gtk_widget_get_pango_context (widget));

  pango_layout_set_text(layout, str, -1);
  pango_layout_set_font_description(layout, NULL);
  pango_layout_get_pixel_size (layout, &width, &height);

  g_object_unref (layout);
  return height;
}
Beispiel #19
0
static void mosaic_search_box_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
  PangoLayout *pl = gtk_widget_create_pango_layout (widget, "|");
  PangoFontDescription *pfd = pango_font_description_from_string (MOSAIC_BOX (widget)->font);
  pango_layout_set_font_description (pl, pfd);
  pango_font_description_free (pfd);

  int pwidth, pheight;
  pango_layout_get_pixel_size (pl, &pwidth, &pheight);

  requisition->width = BOX_DEFAULT_WIDTH;
  requisition->height = pheight + 10;
  g_object_unref (pl);
}
Beispiel #20
0
int
go_pango_measure_string (PangoContext *context, const PangoFontDescription *font_desc, const char *str)
{
	PangoLayout *layout = pango_layout_new (context);
	int width;

	pango_layout_set_text (layout, str, -1);
	pango_layout_set_font_description (layout, font_desc);
	pango_layout_get_pixel_size (layout, &width, NULL);

	g_object_unref (layout);

	return width;
}
Beispiel #21
0
/*!
  \brief Calculate the bounding box for a string rendered with a widget's 
  default font. Set geo to a rect with 0,0 positioned on the left-hand 
  baseline.
  \param widget is the pointer to the Widget in question
  \param text is the text we want to get the dimensions of
  \param geo is the pointer to PangoRectangle representation of the 
  text dimensions
  */
G_MODULE_EXPORT void get_geo( GtkWidget *widget, const char *text, PangoRectangle *geo )
{
	PangoLayout *layout;
	int width, height;

	layout = gtk_widget_create_pango_layout( widget, text );
	pango_layout_get_pixel_size( layout, &width, &height );
	g_object_unref( layout );

	/* FIXME ... we left/top to 0 for now.
	 *          */
	geo->width = width;
	geo->height = height;
}
static gint
get_label_width (PangoLayout *layout, GitgRef *ref)
{
	gint w;
	gchar *smaller = g_strdup_printf("<span size='smaller'>%s</span>", 
	                                 gitg_ref_get_shortname(ref));

	pango_layout_set_markup(layout, smaller, -1);

	pango_layout_get_pixel_size(layout, &w, NULL);
	g_free(smaller);

	return w + PADDING * 2;
}
Beispiel #23
0
static void rewrap_label_to_parent_size(GtkWidget *widget,
                GtkAllocation *allocation,
                gpointer data)
{
    GtkLabel *label = GTK_LABEL(widget);
    PangoLayout *layout = gtk_label_get_layout(label);

    int lw_old, lh_old;
    pango_layout_get_pixel_size(layout, &lw_old, &lh_old);

    /* Already right size? */
    if (lw_old == allocation->width)
        return;

    /* Rewrap text to new width */
    pango_layout_set_width(layout, allocation->width * PANGO_SCALE);

    /* Did text height change as a result? */
    int lh;
    pango_layout_get_pixel_size(layout, NULL, &lh);
    if (lh != lh_old) /* yes, resize label height */
        gtk_widget_set_size_request(widget, -1, lh);
}
GdkPixmap *make_pixmap(GtkScrollbox *self, gchar *value)
{
        GdkWindow *rootwin;
        PangoLayout *pl;
        gint width, height, middle;
        GdkPixmap *pixmap;
        GtkRequisition widgsize = {0, }; 
        GtkWidget *widget = (GtkWidget *)self;
        

	/* If we can't draw yet, don't do anything to avoid screwing things */
	if (!GDK_IS_GC(widget->style->bg_gc[0]))
		return NULL;

        rootwin = gtk_widget_get_root_window(widget);

        pl = gtk_widget_create_pango_layout(widget, NULL);
        pango_layout_set_markup(pl, value, -1);

        pango_layout_get_pixel_size(pl, &width, &height);

        pixmap = gdk_pixmap_new(GDK_DRAWABLE(rootwin), width, height, -1);

        gdk_draw_rectangle(GDK_DRAWABLE(pixmap), 
                        widget->style->bg_gc[0],
                        TRUE, 0, 0, width, height);

        gdk_draw_layout(GDK_DRAWABLE(pixmap), widget->style->fg_gc[0], 0, 0, pl);

        g_object_unref(pl);

        gtk_widget_size_request(widget, &widgsize);

        if (width <= widgsize.width)
                width = widgsize.width;

        if (height <= widgsize.height)
                height = widgsize.height;
        else
                self->draw_maxoffset = -height;

        if (width != widgsize.width || height != widgsize.height)
                gtk_widget_set_size_request(widget, width, height);

        middle = width / 2;
        if (self->draw_maxmiddle < middle)
                self->draw_maxmiddle = middle;

        return pixmap;
}
Beispiel #25
0
static gint calculate_min_number_window_width(GtkWidget *widget)
{
	PangoLayout *layout;
	gchar *str;
	gint width, col = 4;

	str = g_strnfill(col, 0x20);
	layout = gtk_widget_create_pango_layout(widget, str);
	g_free (str);

	pango_layout_get_pixel_size(layout, &width, NULL);
	g_object_unref(G_OBJECT(layout));

	return width;
}
Beispiel #26
0
static gint
make_string (PangoLayout *layout, gint max_width,
             gchar *buffer, gint buffer_size)
{
   gint utf8len, len, src_len, dots_width, width, height;

   pango_layout_set_text (layout, "...", -1);
   pango_layout_get_pixel_size (layout, &dots_width, &height);

   utf8len = g_utf8_strlen (buffer, -1);
   len = src_len = strlen (buffer);

   while (utf8len > 0 && len > 0) {
      len = g_utf8_offset_to_pointer(buffer, utf8len) - buffer;

      pango_layout_set_text (layout, buffer, len);
      pango_layout_get_pixel_size (layout, &width, &height);
      if (width + dots_width > max_width) {
         utf8len--;
      } else {
         break;
      }
   }

   if (len < src_len && len < buffer_size - 4) {
      gchar *str = g_utf8_offset_to_pointer (buffer, utf8len);
      str[0] = '.';
      str[1] = '.';
      str[2] = '.';
      str[3] = '\0';
      return len + 3;
   } else {
      buffer[buffer_size - 1] = '\0';
      return buffer_size;
   }
}
static gboolean
about_dialog_anim_expose (GtkWidget       *widget,
                          GdkEventExpose  *event,
                          GimpAboutDialog *dialog)
{
  GtkStyle      *style = gtk_widget_get_style (widget);
  cairo_t       *cr;
  GtkAllocation  allocation;
  gint           x, y;
  gint           width, height;

  if (! dialog->visible)
    return FALSE;

  cr = gdk_cairo_create (event->window);

  gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);

  gtk_widget_get_allocation (widget, &allocation);
  pango_layout_get_pixel_size (dialog->layout, &width, &height);

  x = (allocation.width  - width)  / 2;
  y = (allocation.height - height) / 2;

  if (dialog->textrange[1] > 0)
    {
      GdkRegion *covered_region;

      covered_region = gdk_pango_layout_get_clip_region (dialog->layout,
                                                         x, y,
                                                         dialog->textrange, 1);

      gdk_region_intersect (covered_region, event->region);

      gdk_cairo_region (cr, covered_region);
      cairo_clip (cr);

      gdk_region_destroy (covered_region);
    }

  cairo_move_to (cr, x, y);

  pango_cairo_show_layout (cr, dialog->layout);

  cairo_destroy (cr);

  return FALSE;
}
static int
measure_line_height (GtkSourceView *view)
{
	PangoLayout *layout;
	gint height = 12;

	layout = gtk_widget_create_pango_layout (GTK_WIDGET (view), "QWERTY");

	if (layout)
	{
		pango_layout_get_pixel_size (layout, NULL, &height);
		g_object_unref (layout);
	}

	return height - 2;
}
static void
set_label_size (NautilusZoomControl *zoom_control)
{
	const char *text;
	PangoLayout *layout;
	int width;
	int height;
	
	text = gtk_label_get_text (GTK_LABEL (zoom_control->details->zoom_label));
	layout = gtk_label_get_layout (GTK_LABEL (zoom_control->details->zoom_label));
	pango_layout_set_text (layout, "100%", -1);
	pango_layout_get_pixel_size (layout, &width, &height);
	gtk_widget_set_size_request (zoom_control->details->zoom_label, width, height);
	gtk_label_set_text (GTK_LABEL (zoom_control->details->zoom_label), 
			    text);
}
Beispiel #30
0
int
FontHeightWithContextReal(cairo_t* c, PangoFontDescription* fontDesc, int dpi)
{
    int height;

    PangoContext* pc = pango_cairo_create_context(c);
    pango_cairo_context_set_resolution(pc, dpi);
    PangoLayout *layout = pango_layout_new(pc);
    pango_layout_set_text(layout, "Ayg中", -1);
    pango_layout_set_font_description(layout, fontDesc);
    pango_layout_get_pixel_size(layout, NULL, &height);
    g_object_unref(layout);
    g_object_unref(pc);

    return height;
}