⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkfont-x11.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 2 页
字号:
 * Returns the X Font ID for the given font.  *  * Return value: the numeric X Font ID **/gintgdk_font_id (const GdkFont *font){  const GdkFontPrivateX *font_private;  g_return_val_if_fail (font != NULL, 0);  font_private = (const GdkFontPrivateX*) font;  if (font->type == GDK_FONT_FONT)    {      return ((XFontStruct *) font_private->xfont)->fid;    }  else    {      return 0;    }}/** * gdk_font_equal: * @fonta: a #GdkFont. * @fontb: another #GdkFont. *  * Compares two fonts for equality. Single fonts compare equal * if they have the same X font ID. This operation does * not currently work correctly for fontsets. *  * Return value: %TRUE if the fonts are equal. **/gbooleangdk_font_equal (const GdkFont *fonta,                const GdkFont *fontb){  const GdkFontPrivateX *privatea;  const GdkFontPrivateX *privateb;  g_return_val_if_fail (fonta != NULL, FALSE);  g_return_val_if_fail (fontb != NULL, FALSE);  privatea = (const GdkFontPrivateX*) fonta;  privateb = (const GdkFontPrivateX*) fontb;  if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)    {      return (((XFontStruct *) privatea->xfont)->fid ==	      ((XFontStruct *) privateb->xfont)->fid);    }  else if (fonta->type == GDK_FONT_FONTSET && fontb->type == GDK_FONT_FONTSET)    {      gchar *namea, *nameb;      namea = XBaseFontNameListOfFontSet((XFontSet) privatea->xfont);      nameb = XBaseFontNameListOfFontSet((XFontSet) privateb->xfont);            return (strcmp(namea, nameb) == 0);    }  else    /* fontset != font */    return FALSE;}/** * gdk_text_width: * @font: a #GdkFont * @text: the text to measure. * @text_length: the length of the text in bytes. *  * Determines the width of a given string. *  * Return value: the width of the string in pixels. **/gintgdk_text_width (GdkFont      *font,		const gchar  *text,		gint          text_length){  GdkFontPrivateX *private;  gint width;  XFontStruct *xfont;  XFontSet fontset;  g_return_val_if_fail (font != NULL, -1);  g_return_val_if_fail (text != NULL, -1);  private = (GdkFontPrivateX*) font;  switch (font->type)    {    case GDK_FONT_FONT:      xfont = (XFontStruct *) private->xfont;      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))	{	  width = XTextWidth (xfont, text, text_length);	}      else	{	  width = XTextWidth16 (xfont, (XChar2b *) text, text_length / 2);	}      break;    case GDK_FONT_FONTSET:      fontset = (XFontSet) private->xfont;      width = XmbTextEscapement (fontset, text, text_length);      break;    default:      width = 0;    }  return width;}/** * gdk_text_width_wc: * @font: a #GdkFont * @text: the text to measure. * @text_length: the length of the text in characters. *  * Determines the width of a given wide-character string. *  * Return value: the width of the string in pixels. **/gintgdk_text_width_wc (GdkFont	  *font,		   const GdkWChar *text,		   gint		   text_length){  GdkFontPrivateX *private;  gint width;  XFontStruct *xfont;  XFontSet fontset;  g_return_val_if_fail (font != NULL, -1);  g_return_val_if_fail (text != NULL, -1);  private = (GdkFontPrivateX*) font;  switch (font->type)    {    case GDK_FONT_FONT:      xfont = (XFontStruct *) private->xfont;      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))        {          gchar *text_8bit;          gint i;          text_8bit = g_new (gchar, text_length);          for (i=0; i<text_length; i++) text_8bit[i] = text[i];          width = XTextWidth (xfont, text_8bit, text_length);          g_free (text_8bit);        }      else        {          width = 0;        }      break;    case GDK_FONT_FONTSET:      if (sizeof(GdkWChar) == sizeof(wchar_t))	{	  fontset = (XFontSet) private->xfont;	  width = XwcTextEscapement (fontset, (wchar_t *)text, text_length);	}      else	{	  wchar_t *text_wchar;	  gint i;	  fontset = (XFontSet) private->xfont;	  text_wchar = g_new(wchar_t, text_length);	  for (i=0; i<text_length; i++) text_wchar[i] = text[i];	  width = XwcTextEscapement (fontset, text_wchar, text_length);	  g_free (text_wchar);	}      break;    default:      width = 0;    }  return width;}/** * gdk_text_extents: * @font: a #GdkFont * @text: the text to measure * @text_length: the length of the text in bytes. (If the *    font is a 16-bit font, this is twice the length *    of the text in characters.) * @lbearing: the left bearing of the string. * @rbearing: the right bearing of the string. * @width: the width of the string. * @ascent: the ascent of the string. * @descent: the descent of the string. *  * Gets the metrics of a string. **/voidgdk_text_extents (GdkFont     *font,                  const gchar *text,                  gint         text_length,		  gint        *lbearing,		  gint        *rbearing,		  gint        *width,		  gint        *ascent,		  gint        *descent){  GdkFontPrivateX *private;  XCharStruct overall;  XFontStruct *xfont;  XFontSet    fontset;  XRectangle  ink, logical;  int direction;  int font_ascent;  int font_descent;  g_return_if_fail (font != NULL);  g_return_if_fail (text != NULL);  private = (GdkFontPrivateX*) font;  switch (font->type)    {    case GDK_FONT_FONT:      xfont = (XFontStruct *) private->xfont;      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))	{	  XTextExtents (xfont, text, text_length,			&direction, &font_ascent, &font_descent,			&overall);	}      else	{	  XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,			  &direction, &font_ascent, &font_descent,			  &overall);	}      if (lbearing)	*lbearing = overall.lbearing;      if (rbearing)	*rbearing = overall.rbearing;      if (width)	*width = overall.width;      if (ascent)	*ascent = overall.ascent;      if (descent)	*descent = overall.descent;      break;    case GDK_FONT_FONTSET:      fontset = (XFontSet) private->xfont;      XmbTextExtents (fontset, text, text_length, &ink, &logical);      if (lbearing)	*lbearing = ink.x;      if (rbearing)	*rbearing = ink.x + ink.width;      if (width)	*width = logical.width;      if (ascent)	*ascent = -ink.y;      if (descent)	*descent = ink.y + ink.height;      break;    }}/** * gdk_text_extents_wc: * @font: a #GdkFont * @text: the text to measure. * @text_length: the length of the text in character. * @lbearing: the left bearing of the string. * @rbearing: the right bearing of the string. * @width: the width of the string. * @ascent: the ascent of the string. * @descent: the descent of the string. *  * Gets the metrics of a string of wide characters. **/voidgdk_text_extents_wc (GdkFont        *font,		     const GdkWChar *text,		     gint            text_length,		     gint           *lbearing,		     gint           *rbearing,		     gint           *width,		     gint           *ascent,		     gint           *descent){  GdkFontPrivateX *private;  XCharStruct overall;  XFontStruct *xfont;  XFontSet    fontset;  XRectangle  ink, logical;  int direction;  int font_ascent;  int font_descent;  g_return_if_fail (font != NULL);  g_return_if_fail (text != NULL);  private = (GdkFontPrivateX*) font;  switch (font->type)    {    case GDK_FONT_FONT:      {	gchar *text_8bit;	gint i;	xfont = (XFontStruct *) private->xfont;	g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));	text_8bit = g_new (gchar, text_length);	for (i=0; i<text_length; i++) 	  text_8bit[i] = text[i];	XTextExtents (xfont, text_8bit, text_length,		      &direction, &font_ascent, &font_descent,		      &overall);	g_free (text_8bit);		if (lbearing)	  *lbearing = overall.lbearing;	if (rbearing)	  *rbearing = overall.rbearing;	if (width)	  *width = overall.width;	if (ascent)	  *ascent = overall.ascent;	if (descent)	  *descent = overall.descent;	break;      }    case GDK_FONT_FONTSET:      fontset = (XFontSet) private->xfont;      if (sizeof(GdkWChar) == sizeof(wchar_t))	XwcTextExtents (fontset, (wchar_t *)text, text_length, &ink, &logical);      else	{	  wchar_t *text_wchar;	  gint i;	  	  text_wchar = g_new (wchar_t, text_length);	  for (i = 0; i < text_length; i++)	    text_wchar[i] = text[i];	  XwcTextExtents (fontset, text_wchar, text_length, &ink, &logical);	  g_free (text_wchar);	}      if (lbearing)	*lbearing = ink.x;      if (rbearing)	*rbearing = ink.x + ink.width;      if (width)	*width = logical.width;      if (ascent)	*ascent = -ink.y;      if (descent)	*descent = ink.y + ink.height;      break;    }}/** * gdk_x11_font_get_xdisplay: * @font: a #GdkFont. *  * Returns the display of a #GdkFont. *  * Return value:  an Xlib <type>Display*</type>. **/Display *gdk_x11_font_get_xdisplay (GdkFont *font){  g_return_val_if_fail (font != NULL, NULL);  return GDK_DISPLAY_XDISPLAY (((GdkFontPrivateX *)font)->display);}/** * gdk_x11_font_get_xfont: * @font: a #GdkFont. *  * Returns the X font belonging to a #GdkFont. *  * Return value: an Xlib <type>XFontStruct*</type> or an <type>XFontSet</type>. **/gpointergdk_x11_font_get_xfont (GdkFont *font){  g_return_val_if_fail (font != NULL, NULL);  return ((GdkFontPrivateX *)font)->xfont;}/** * gdk_x11_font_get_name: * @font: a #GdkFont. *  * Return the X Logical Font Description (for font->type == GDK_FONT_FONT) * or comma separated list of XLFDs (for font->type == GDK_FONT_FONTSET) * that was used to load the font. If the same font was loaded * via multiple names, which name is returned is undefined. *  * Return value: the name of the font. This string is owned *   by GDK and must not be modified or freed. **/G_CONST_RETURN char *gdk_x11_font_get_name (GdkFont *font){  GdkFontPrivateX *private = (GdkFontPrivateX *)font;  g_return_val_if_fail (font != NULL, NULL);  g_assert (private->names);  return private->names->data;}     #define __GDK_FONT_X11_C__#include "gdkaliasdef.c"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -