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


C++ pango_layout_get_pixel_extents函数代码示例

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


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

示例1: tooltip_update_geometry

void tooltip_update_geometry()
{
	Panel *panel = g_tooltip.panel;
	int screen_width = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width;

	cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height);
	cairo_t *c = cairo_create(cs);
	PangoLayout *layout = pango_cairo_create_layout(c);

	pango_layout_set_font_description(layout, g_tooltip.font_desc);
	PangoRectangle r1, r2;
	pango_layout_set_text(layout, "1234567890", -1);
	pango_layout_get_pixel_extents(layout, &r1, &r2);
	int max_width = MIN(r2.width * 7, screen_width * 2 / 3);
	pango_layout_set_width(layout, max_width * PANGO_SCALE);

	pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
	pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
	pango_layout_get_pixel_extents(layout, &r1, &r2);
	width = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingx + r2.width;
	height = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingy + r2.height;

	if (panel_horizontal && panel_position & BOTTOM)
		y = panel->posy - height;
	else if (panel_horizontal && panel_position & TOP)
		y = panel->posy + panel->area.height;
	else if (panel_position & LEFT)
		x = panel->posx + panel->area.width;
	else
		x = panel->posx - width;

	g_object_unref(layout);
	cairo_destroy(c);
	cairo_surface_destroy(cs);
}
开发者ID:alaricljs,项目名称:tint2,代码行数:35,代码来源:tooltip.c

示例2: gtk_entry_set_text

      /* clean entries */
      gtk_entry_set_text(GTK_ENTRY(lib->gui.plabel), "");
      gtk_entry_set_text(GTK_ENTRY(lib->gui.pname), "");
    }
  }
}


static void _toggle_capture_mode_clicked(GtkWidget *widget, gpointer user_data)
{
  dt_lib_camera_t *lib = (dt_lib_camera_t *)user_data;
  GtkWidget *w = NULL;
  if(widget == GTK_WIDGET(lib->gui.tb1))
    w = lib->gui.sb1;
  else if(widget == GTK_WIDGET(lib->gui.tb2))
    w = lib->gui.sb2;
  else if(widget == GTK_WIDGET(lib->gui.tb3))
  {
    gtk_widget_set_sensitive(lib->gui.sb3, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
    gtk_widget_set_sensitive(lib->gui.sb4, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
  }

  if(w) gtk_widget_set_sensitive(w, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
}


#define BAR_HEIGHT DT_PIXEL_APPLY_DPI(18) /* also change in views/tethering.c */
static void _expose_info_bar(dt_lib_module_t *self, cairo_t *cr, int32_t width, int32_t height,
                             int32_t pointerx, int32_t pointery)
{
  dt_lib_camera_t *lib = (dt_lib_camera_t *)self->data;

  // Draw infobar background at top
  cairo_set_source_rgb(cr, .0, .0, .0);
  cairo_rectangle(cr, 0, 0, width, BAR_HEIGHT);
  cairo_fill(cr);

  cairo_set_source_rgb(cr, .8, .8, .8);

  // Draw left aligned value camera model value
  PangoLayout *layout;
  PangoRectangle ink;
  PangoFontDescription *desc = pango_font_description_copy_static(darktable.bauhaus->pango_font_desc);
  pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
  layout = pango_cairo_create_layout(cr);
  const int fontsize = DT_PIXEL_APPLY_DPI(11.5);
  pango_font_description_set_absolute_size(desc, fontsize * PANGO_SCALE);
  pango_layout_set_font_description(layout, desc);
  char model[4096] = { 0 };
  sprintf(model + strlen(model), "%s", lib->data.camera_model);
  pango_layout_set_text(layout, model, -1);
  pango_layout_get_pixel_extents(layout, &ink, NULL);
  cairo_move_to(cr, DT_PIXEL_APPLY_DPI(5), DT_PIXEL_APPLY_DPI(1) + BAR_HEIGHT - ink.height / 2 - fontsize);
  pango_cairo_show_layout(cr, layout);

  // Draw right aligned battery value
  const char *battery_value = dt_camctl_camera_get_property(darktable.camctl, NULL, "batterylevel");
  char battery[4096] = { 0 };
  snprintf(battery, sizeof(battery), "%s: %s", _("battery"), battery_value ? battery_value : _("n/a"));
  pango_layout_set_text(layout, battery, -1);
  pango_layout_get_pixel_extents(layout, &ink, NULL);
  cairo_move_to(cr, width - ink.width - DT_PIXEL_APPLY_DPI(5), DT_PIXEL_APPLY_DPI(1) + BAR_HEIGHT - ink.height / 2 - fontsize);
  pango_cairo_show_layout(cr, layout);

  // Let's cook up the middle part of infobar
  gchar center[1024] = { 0 };
  for(guint i = 0; i < g_list_length(lib->gui.properties); i++)
  {
    dt_lib_camera_property_t *prop = (dt_lib_camera_property_t *)g_list_nth_data(lib->gui.properties, i);
    if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prop->osd)) == TRUE)
    {
      g_strlcat(center, "      ", sizeof(center));
      g_strlcat(center, prop->name, sizeof(center));
      g_strlcat(center, ": ", sizeof(center));
      g_strlcat(center, dt_bauhaus_combobox_get_text(prop->values), sizeof(center));
    }
  }
  g_strlcat(center, "      ", sizeof(center));

  // Now lets put it in center view...
  pango_layout_set_text(layout, center, -1);
  pango_layout_get_pixel_extents(layout, &ink, NULL);
  cairo_move_to(cr, (width / 2) - (ink.width / 2), DT_PIXEL_APPLY_DPI(1) + BAR_HEIGHT - ink.height / 2 - fontsize);
  pango_cairo_show_layout(cr, layout);
  pango_font_description_free(desc);
  g_object_unref(layout);
}
开发者ID:mueller-physics,项目名称:darktable,代码行数:87,代码来源:camera.c

示例3: i7_cell_renderer_transcript_get_size

static void 
i7_cell_renderer_transcript_get_size(GtkCellRenderer *self, GtkWidget *widget, GdkRectangle *cell_area, int *x_offset, int *y_offset, int *width, int *height) 
{
	I7_CELL_RENDERER_TRANSCRIPT_USE_PRIVATE;

	PangoRectangle command_rect, transcript_rect, expected_rect;
	PangoLayout *layout;
	unsigned xpad, ypad, transcript_width, calc_width, calc_height;
	
	g_object_get(self, "xpad", &xpad, "ypad", &ypad, NULL);
	transcript_width = (priv->default_width / 2) - xpad;

	/* Get size of command */
	layout = gtk_widget_create_pango_layout(widget, priv->command);
	pango_layout_get_pixel_extents(layout, NULL, &command_rect);
	g_object_unref(layout);

	/* Get size of transcript text */
	layout = gtk_widget_create_pango_layout(widget, priv->transcript_text);
	pango_layout_set_width(layout, (int)(transcript_width - priv->text_padding * 2) * PANGO_SCALE);
	pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
	pango_layout_get_pixel_extents(layout, NULL, &transcript_rect);
	g_object_unref(layout);

	/* Get size of expected text */
	layout = gtk_widget_create_pango_layout(widget, priv->expected_text);
	pango_layout_set_width(layout, (int)(transcript_width - priv->text_padding * 2) * PANGO_SCALE);
	pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
	pango_layout_get_pixel_extents(layout, NULL, &expected_rect);
	g_object_unref (layout);

	/* Calculate the required width and height for the cell */
	calc_width = priv->default_width;
	calc_height = (unsigned)(command_rect.height + MAX(transcript_rect.height, expected_rect.height)) + ypad * 2 + priv->text_padding * 4;

	/* Set the passed-in parameters; if the available cell area is larger than
	 the required width and height, just use that instead */
	if(cell_area) {
		if(width)
			*width = MAX(cell_area->width, (int)calc_width);
		if(height)
			*height = MAX(cell_area->height, (int)calc_height);
	} else {
		if(width)
			*width = (int)calc_width;
		if(height)
			*height = (int)calc_height;
	}
	if(x_offset)
		*x_offset = 0;
	if(y_offset)
		*y_offset = 0;
}
开发者ID:ptomato,项目名称:gnome-inform7,代码行数:53,代码来源:transcript-renderer.c

示例4: GTK_WIDGET

//__________________________________________________________________
_HYRect _HYPullDown::_SuggestDimensions (void)
{
    _HYRect res = {25,100,25,100,HY_COMPONENT_NO_SCROLL};

    if (theMenu) {
        long            naturalWidth = 0;
        PangoLayout *   fontMeasurer = nil;
        for (long k=0; k<widgetList.lLength; k+=2) {
            GtkWidget * dropWidget = GTK_WIDGET (widgetList(k));
            if (!fontMeasurer) {
                fontMeasurer = pango_layout_new (gtk_widget_get_pango_context (dropWidget));
            }

            pango_layout_set_text(fontMeasurer,GetMenuItem(k/2)->sData ,GetMenuItem(k/2)->sLength);
            PangoRectangle extents,
                           log_ext;
            pango_layout_get_pixel_extents (fontMeasurer,&extents,nil);
            if (extents.width > naturalWidth) {
                naturalWidth = extents.width;
            }
        }
        if (fontMeasurer) {
            g_object_unref (fontMeasurer);
        }

        res.right = res.left = naturalWidth+25;
    }

    return res;
}
开发者ID:ArtPoon,项目名称:hyphy,代码行数:31,代码来源:HYPlatformPullDown.cpp

示例5: get_font_size

void get_font_size(term_data* td)
{
	PangoRectangle r;
	PangoLayout *temp;
	PangoFontDescription* temp_font;
	cairo_t *cr;
	cairo_surface_t *surface;
	
	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 200, 200);
	cr = cairo_create(surface);
	
	temp = pango_cairo_create_layout(cr);
	
	/* Draw an @, and measure it */
	temp_font = pango_font_description_from_string(td->font.name);
	pango_layout_set_font_description(temp, temp_font);
	pango_layout_set_text(temp, "@", 1);
	pango_cairo_show_layout(cr, temp);
	pango_layout_get_pixel_extents(temp, NULL, &r);
	
	td->font.w = r.width;
	td->font.h = r.height;
	
	pango_font_description_free(temp_font);
	cairo_destroy(cr);
	g_object_unref(temp);
	
	td->win.w = td->font.w * td->cols;
	td->win.h = td->font.h * td->rows;
//	printf("font width == %d, height = %d.\n", td->font.w, td->font.h);
}
开发者ID:arcum42,项目名称:angband,代码行数:31,代码来源:gtk-drawing.c

示例6: shell_search_renderer_render

static void
shell_search_renderer_render (GtkCellRenderer      *cell,
                              cairo_t              *cr,
                              GtkWidget            *widget,
                              const GdkRectangle   *background_area,
                              const GdkRectangle   *cell_area,
                              GtkCellRendererState  flags)
{
  ShellSearchRendererPrivate *priv = SHELL_SEARCH_RENDERER (cell)->priv;
  PangoRectangle rect;
  GtkStyleContext *context;
  gint layout_height;
  gint vcenter_offset;

  context = gtk_widget_get_style_context (widget);

  shell_search_renderer_set_layout (SHELL_SEARCH_RENDERER (cell), widget);

  pango_layout_get_pixel_extents (priv->layout, NULL, &rect);

  pango_layout_get_pixel_size (priv->layout, NULL, &layout_height);
  vcenter_offset = (cell_area->height - layout_height) / 2;

  cairo_save (cr);

  gtk_render_layout (context, cr,
                     cell_area->x,
                     cell_area->y + vcenter_offset,
                     priv->layout);

  cairo_restore (cr);
}
开发者ID:wrouesnel,项目名称:gnome-control-center,代码行数:32,代码来源:shell-search-renderer.c

示例7: __MCGContextMeasurePlatformText

MCGFloat __MCGContextMeasurePlatformText(MCGContextRef self, const unichar_t *p_text, uindex_t p_length, const MCGFont &p_font)
{	
	// MW-2013-12-19: [[ Bug 11559 ]] Do nothing if no text support.
	if (!s_has_text_support)
		return 0.0;
	
	bool t_success;
	t_success = true;		
	
	if (t_success)
		t_success = s_layout != NULL;
	
	char *t_text;
	t_text = nil;
	if (t_success)
		t_success = MCCStringFromUnicodeSubstring(p_text, p_length / 2, t_text);
	
	MCGFloat t_width;
	t_width = 0.0;
	if (t_success)
	{
		pango_layout_set_text(s_layout, t_text, -1);		
		pango_layout_set_font_description(s_layout, (PangoFontDescription *) p_font . fid);
		
		PangoRectangle t_bounds;
		pango_layout_get_pixel_extents(s_layout, NULL, &t_bounds);
		t_width = t_bounds . width;		
	}
	
	MCCStringFree(t_text);

	return t_width;
}
开发者ID:runrevelanor,项目名称:livecode,代码行数:33,代码来源:lnxtext.cpp

示例8: draw_valtext

/*!
  \brief draw_valtext() draws the dynamic values for the traces on 
  the left hand side of the logviewer. This is optimized so that if the value
  becomes temporarily static, it won't keep blindly updating the screen and
  wasting CPU time.
  \param force_draw when true to write the values to screen for
  all controls no matter if hte previous value is the same or not.
  */
G_MODULE_EXPORT void draw_valtext(gboolean force_draw)
{
	gint last_index = 0;
	gfloat val = 0.0;
	gfloat last_val = 0.0;
	gint val_x = 0;
	gint val_y = 0;
	gint info_ctr = 0;
	gint h = 0;
	gint i = 0;
	GArray *array = NULL;
	Viewable_Value *v_value = NULL;
	PangoLayout *layout;
	GdkPixmap *pixmap = lv_data->pixmap;
	GtkAllocation allocation;

	gtk_widget_get_allocation(lv_data->darea,&allocation);

	h = allocation.height;

	if (!lv_data->font_desc)
	{
		lv_data->font_desc = pango_font_description_from_string("courier");
		pango_font_description_set_size(lv_data->font_desc,(10)*PANGO_SCALE);
	}
	
	val_x = 7;
	for (i=0;i<lv_data->active_traces;i++)
	{
		v_value = (Viewable_Value *)g_list_nth_data(lv_data->tlist,i);
		info_ctr = (lv_data->spread * (i+1))- (lv_data->spread/2);
		val_y = info_ctr + 1;

		last_index = v_value->last_index;
		array = DATA_GET(v_value->object,v_value->data_source);
		val = g_array_index(array,gfloat,last_index);
		if (array->len > 1)
			last_val = g_array_index(array,gfloat,last_index-1);
		/* IF this value matches the last one,  don't bother
		 * updating the text as there's no point... */
		if ((val == last_val) && (!force_draw) && (!v_value->force_update))
			continue;
		
		v_value->force_update = FALSE;
		gdk_draw_rectangle(pixmap,
				gtk_widget_get_style(lv_data->darea)->black_gc,
				TRUE,
				v_value->ink_rect->x+val_x,
				v_value->ink_rect->y+val_y,
				lv_data->info_width-1-v_value->ink_rect->x-val_x,
				v_value->ink_rect->height);

		layout = gtk_widget_create_pango_layout(lv_data->darea,g_strdup_printf("%1$.*2$f",val,v_value->precision));

		pango_layout_set_font_description(layout,lv_data->font_desc);
		pango_layout_get_pixel_extents(layout,v_value->ink_rect,v_value->log_rect);
		gdk_draw_layout(pixmap,v_value->font_gc,val_x,val_y,layout);
	}

}
开发者ID:toxicgumbo,项目名称:MegaTunix,代码行数:68,代码来源:logviewer_gui.c

示例9: _paint_text

static void
_paint_text (OlScrollWindow *scroll, cairo_t *cr)
{
  ol_log_func ();
  ol_assert (OL_IS_SCROLL_WINDOW (scroll));
  ol_assert (cr != NULL);
  GtkWidget *widget = GTK_WIDGET (scroll);
  OlScrollWindowPrivate *priv = OL_SCROLL_WINDOW_GET_PRIVATE (scroll);
  gint width, height;
  PangoRectangle extent;
  PangoLayout *layout;
  gint x, y;
  gdk_drawable_get_size (gtk_widget_get_window (widget),
                         &width, &height);
  
  /* set the font */
  cairo_save (cr);
  cairo_set_source_rgb (cr,
                        priv->inactive_color.r,
                        priv->inactive_color.g,
                        priv->inactive_color.b);
  layout = _get_pango (scroll, cr);
  pango_layout_set_text (layout, priv->text, -1);
  pango_layout_get_pixel_extents (layout, NULL, &extent);
  pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
  x = (width - extent.width) / 2;
  y = (height - extent.height) / 2;
  if (x < 0) x = 0;
  if (y < 0) y = 0;
  cairo_move_to (cr, x, y);
  pango_cairo_update_layout (cr, layout);
  pango_cairo_show_layout (cr, layout);
}
开发者ID:AhmadMAlam,项目名称:osd-lyrics-1,代码行数:33,代码来源:ol_scroll_window.c

示例10: tooltip_update

void tooltip_update()
{
	if (!g_tooltip.tooltip_text) {
		tooltip_hide(0);
		return;
	}

	tooltip_update_geometry();
	if (just_shown) {
		if (!panel_horizontal)
			y -= height / 2; // center vertically
		just_shown = FALSE;
	}
	tooltip_adjust_geometry();
	XMoveResizeWindow(server.display, g_tooltip.window, x, y, width, height);

	// Stuff for drawing the tooltip
	cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height);
	cairo_t *c = cairo_create(cs);
	Color bc = g_tooltip.bg->fill_color;
	Border b = g_tooltip.bg->border;
	if (server.real_transparency) {
		clear_pixmap(g_tooltip.window, 0, 0, width, height);
		draw_rect(c, b.width, b.width, width - 2 * b.width, height - 2 * b.width, b.radius - b.width / 1.571);
		cairo_set_source_rgba(c, bc.rgb[0], bc.rgb[1], bc.rgb[2], bc.alpha);
	} else {
		cairo_rectangle(c, 0., 0, width, height);
		cairo_set_source_rgb(c, bc.rgb[0], bc.rgb[1], bc.rgb[2]);
	}
	cairo_fill(c);
	cairo_set_line_width(c, b.width);
	if (server.real_transparency)
		draw_rect(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width, b.radius);
	else
		cairo_rectangle(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width);
	cairo_set_source_rgba(c, b.color.rgb[0], b.color.rgb[1], b.color.rgb[2], b.color.alpha);
	cairo_stroke(c);

	Color fc = g_tooltip.font_color;
	cairo_set_source_rgba(c, fc.rgb[0], fc.rgb[1], fc.rgb[2], fc.alpha);
	PangoLayout *layout = pango_cairo_create_layout(c);
	pango_layout_set_font_description(layout, g_tooltip.font_desc);
	pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
	pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
	PangoRectangle r1, r2;
	pango_layout_get_pixel_extents(layout, &r1, &r2);
	pango_layout_set_width(layout, width * PANGO_SCALE);
	pango_layout_set_height(layout, height * PANGO_SCALE);
	pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
	// I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and
	// vert.)
	cairo_move_to(c,
				  -r1.x / 2 + g_tooltip.bg->border.width + g_tooltip.paddingx,
				  -r1.y / 2 + 1 + g_tooltip.bg->border.width + g_tooltip.paddingy);
	pango_cairo_show_layout(c, layout);

	g_object_unref(layout);
	cairo_destroy(c);
	cairo_surface_destroy(cs);
}
开发者ID:alaricljs,项目名称:tint2,代码行数:60,代码来源:tooltip.c

示例11: gimp_ruler_size_request

static void
gimp_ruler_size_request (GtkWidget      *widget,
                         GtkRequisition *requisition)
{
  GimpRulerPrivate *priv  = GIMP_RULER_GET_PRIVATE (widget);
  GtkStyle         *style = gtk_widget_get_style (widget);
  PangoLayout      *layout;
  PangoRectangle    ink_rect;
  gint              size;

  layout = gimp_ruler_get_layout (widget, "0123456789");
  pango_layout_get_pixel_extents (layout, &ink_rect, NULL);

  size = 2 + ink_rect.height * 1.7;

  if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
    {
      requisition->width  = style->xthickness * 2 + 1;
      requisition->height = style->ythickness * 2 + size;
    }
  else
    {
      requisition->width  = style->xthickness * 2 + size;
      requisition->height = style->ythickness * 2 + 1;
    }
}
开发者ID:AjayRamanathan,项目名称:gimp,代码行数:26,代码来源:gimpruler.c

示例12: pango_cairo_create_layout

TextAsset::Size
TextAsset::computeSizeOfText(cairo_t* cairoContext,
                             const std::string textString,
                             int bounds,
                             PangoFontDescription* font,
                             Rect* tight,
                             float* lineHeightOut)
{
    PangoLayout* layout = pango_cairo_create_layout(cairoContext);

    // Kerning
    PangoAttrList* attr_list = pango_attr_list_new();
    PangoAttribute* spacing_attr = pango_attr_letter_spacing_new(pango_units_from_double(_kern));
    pango_attr_list_insert(attr_list, spacing_attr);
    pango_layout_set_attributes(layout, attr_list);

    pango_cairo_context_set_resolution(pango_layout_get_context(layout), DISPLAY_RESOLUTION);
    pango_layout_set_text(layout, textString.c_str(), (int)textString.length());
    pango_layout_set_alignment(layout, _alignment);
    pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);

    const Size maxTextureSize(bounds, 1024);
    pango_layout_set_width(layout, pango_units_from_double(maxTextureSize.width));
    pango_layout_set_height(layout, pango_units_from_double(maxTextureSize.height));
    pango_layout_set_font_description(layout, font);
    applyLeading(cairoContext, layout, font);

    PangoRectangle estimateSize;
    PangoRectangle ink;
    pango_layout_get_pixel_extents(layout, &ink, &estimateSize);

    // If the text is right or center aligned the offsets will contain all the
    // leading space.  We ignore that for the size because drawText will draw
    // in the larger box.  The tight box below will get the offsets so we know
    // where to draw so the text lands in the same tight box.
    Size res(estimateSize.width, estimateSize.height);

    if (tight != NULL) {
        float lineHeight;
        float xHeight = charHeight(cairoContext, font, 'x', &lineHeight);
        if (lineHeightOut != NULL) {
            *lineHeightOut = lineHeight;
        }
        const float capHeight = charHeight(cairoContext, font, 'Y');
        const float ascender = pango_units_to_double(pango_layout_get_baseline(layout));
        const float topSpace = ascender - capHeight;
        const float bottomSpace = MAX(lineHeight - ascender - (capHeight - xHeight), 0);
        if (res.height > topSpace + bottomSpace) {
            *tight = Rect(estimateSize.x,
                          estimateSize.y + topSpace,
                          res.width,
                          res.height - topSpace - bottomSpace);
        } else {
            *tight = Rect(0, 0, res.width, res.height);
        }
    }
    g_object_unref(layout);

    return res;
}
开发者ID:CaringLabs,项目名称:MediaFramework,代码行数:60,代码来源:TextAsset.cpp

示例13: update_pango_layout

/* Updates the pango layout width */
static void
update_pango_layout (MateIconTextItem *iti)
{
    MateIconTextItemPrivate *priv;
    PangoRectangle bounds;
    const char *text;

    priv = iti->_priv;

    if (iti->editing) {
        text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
    } else {
        text = iti->text;
    }

    pango_layout_set_wrap (priv->layout, PANGO_WRAP_WORD_CHAR);
    pango_layout_set_text (priv->layout, text, strlen (text));
    pango_layout_set_width (priv->layout, iti->width * PANGO_SCALE);

    /* In PANGO_WRAP_WORD mode, words wider than a line of text make
     * PangoLayout overflow the layout width.  If this happens, switch to
     * character-based wrapping.
     */

    pango_layout_get_pixel_extents (iti->_priv->layout, NULL, &bounds);

    priv->layout_width = bounds.width;
    priv->layout_height = bounds.height;
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:30,代码来源:mate-icon-item.c

示例14: get_font_size

void get_font_size(font_info *font)
{
	#ifndef USE_PANGO
	get_toy_font_size(font);
	#else
	PangoRectangle r;
	PangoLayout *temp;
	PangoFontDescription *temp_font;
	
	cairo_t *cr;
	cairo_surface_t *surface;
	
	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 200, 200);
	cr = cairo_create(surface);
	
	temp = pango_cairo_create_layout(cr);
	temp_font = pango_font_description_from_string(font->name);
	
	/* Draw an @, and measure it */
	pango_layout_set_font_description(temp, temp_font);
	pango_layout_set_text(temp, "@", 1);
	pango_cairo_show_layout(cr, temp);
	pango_layout_get_pixel_extents(temp, NULL, &r);
	
	font->w = r.width;
	font->h = r.height;
	
	pango_font_description_free(temp_font);
	cairo_destroy(cr);
	cairo_surface_destroy(surface);
	g_object_unref(temp);
	#endif
}
开发者ID:NickMcConnell,项目名称:RePosBand,代码行数:33,代码来源:cairo-utils.c

示例15: tooltip_update_geometry

void tooltip_update_geometry()
{
	cairo_surface_t *cs;
	cairo_t *c;
	PangoLayout* layout;
	cs = cairo_xlib_surface_create(server.dsp, g_tooltip.window, server.visual, width, height);
	c = cairo_create(cs);
	layout = pango_cairo_create_layout(c);
	pango_layout_set_font_description(layout, g_tooltip.font_desc);
	pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
	PangoRectangle r1, r2;
	pango_layout_get_pixel_extents(layout, &r1, &r2);
	width = 2*g_tooltip.bg->border.width + 2*g_tooltip.paddingx + r2.width;
	height = 2*g_tooltip.bg->border.width + 2*g_tooltip.paddingy + r2.height;

	Panel* panel = g_tooltip.panel;
	if (panel_horizontal && panel_position & BOTTOM)
		y = panel->posy-height;
	else if (panel_horizontal && panel_position & TOP)
		y = panel->posy + panel->area.height;
	else if (panel_position & LEFT)
		x = panel->posx + panel->area.width;
	else
		x = panel->posx - width;

	g_object_unref(layout);
	cairo_destroy(c);
	cairo_surface_destroy(cs);
}
开发者ID:asqz,项目名称:tint2,代码行数:29,代码来源:tooltip.c


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