当前位置: 首页>>代码示例>>C++>>正文


C++ pango_layout_get_pixel_size函数代码示例

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


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

示例1: ol_osd_render_paint_text

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);
}
开发者ID:AhmadMAlam,项目名称:osd-lyrics-1,代码行数:56,代码来源:ol_osd_render.c

示例2: gimp_display_shell_canvas_draw_drop_zone

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 */
}
开发者ID:ni1son,项目名称:gimp,代码行数:56,代码来源:gimpdisplayshell-callbacks.c

示例3: karea_get_char_size

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);
}
开发者ID:boamaod,项目名称:kanjipad,代码行数:10,代码来源:kanjipad.c

示例4: rc_ui_scrollable_label_get_width

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;
}
开发者ID:horc-fn,项目名称:RhythmCat2,代码行数:10,代码来源:rc-ui-slabel.c

示例5: gdk_pango_context_get_for_screen

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};
}
开发者ID:Brunnis,项目名称:bsnes-mercury,代码行数:10,代码来源:font.cpp

示例6: gdk_gc_set_foreground

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);
}
开发者ID:tamsuiboy,项目名称:reciteword-osx,代码行数:43,代码来源:revise.cpp

示例7: cairo_save

			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);
				}
			}
开发者ID:Ikari2015,项目名称:XGac,代码行数:55,代码来源:GuiSolidLabelElementRenderer.cpp

示例8: wxGTK_CONV_FONT

// 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;
    }
}
开发者ID:CobaltBlues,项目名称:wxWidgets,代码行数:55,代码来源:textmeasure.cpp

示例9: text_height

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;
}
开发者ID:ebbywiselyn,项目名称:evolution,代码行数:11,代码来源:e-addressbook-reflow-adapter.c

示例10: cgraphics_widget_font_string_width

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;
}
开发者ID:Airr,项目名称:Claro,代码行数:11,代码来源:font.c

示例11: audgui_get_digit_width

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;
}
开发者ID:i-tek,项目名称:audacious,代码行数:11,代码来源:util.c

示例12: timeout

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;
}
开发者ID:krzyzanowskim,项目名称:GNUGadu,代码行数:53,代码来源:gui_dialogs.c

示例13: t_display_calculate_borders

//	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 ;
} ;
开发者ID:BackupTheBerlios,项目名称:gtemp1w,代码行数:44,代码来源:t_display.c

示例14: ellipsize_layout

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);
}
开发者ID:step21,项目名称:inkscape-osx-packaging-native,代码行数:39,代码来源:gdl-dock-item-grip.c

示例15: ygtk_steps_append

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;
}
开发者ID:anaselli,项目名称:libyui-gtk,代码行数:13,代码来源:ygtksteps.c


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