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

📄 pangox.c

📁 GTK+-2.0源码之pango-1.15.6.tar.gz
💻 C
📖 第 1 页 / 共 4 页
字号:
			  PangoLanguage *language,			  guint32        ch){  PangoMap *shape_map = NULL;  PangoScript script;  shape_map = pango_x_get_shaper_map (language);  script = pango_script_for_unichar (ch);  return (PangoEngineShape *)pango_map_get_engine (shape_map, script);}/* Utility functions */static XCharStruct *pango_x_get_per_char (PangoFont         *font,		      PangoXSubfontInfo *subfont,		      guint16            char_index){  XFontStruct *fs;  int index;  int byte1;  int byte2;  fs = pango_x_get_font_struct (font, subfont);  if (!fs)    return NULL;  if (subfont->is_1byte)    {      index = (int)char_index - fs->min_char_or_byte2;      if (index < 0 || index >= subfont->range_byte2)	return NULL;    }  else    {      byte1 = (int)(char_index / 256) - fs->min_byte1;      if (byte1 < 0 || byte1 >= subfont->range_byte1)	return NULL;      byte2 = (int)(char_index % 256) - fs->min_char_or_byte2;      if (byte2 < 0 || byte2 >= subfont->range_byte2)	return NULL;      index = byte1 * subfont->range_byte2 + byte2;    }  if (fs->per_char)    return &fs->per_char[index];  else    return &fs->min_bounds;}static gbooleanpango_x_find_glyph (PangoFont *font,		    PangoGlyph glyph,		    PangoXSubfontInfo **subfont_return,		    XCharStruct **charstruct_return){  PangoXSubfontInfo *subfont;  XCharStruct *cs;  guint16 char_index = PANGO_X_GLYPH_INDEX (glyph);  guint16 subfont_index = PANGO_X_GLYPH_SUBFONT (glyph);  subfont = pango_x_find_subfont (font, subfont_index);  if (!subfont)    return FALSE;  cs = pango_x_get_per_char (font, subfont, char_index);  if (cs && (cs->lbearing != cs->rbearing || cs->width != 0))    {      if (subfont_return)	*subfont_return = subfont;      if (charstruct_return)	*charstruct_return = cs;      return TRUE;    }  else    return FALSE;}/** * pango_x_get_unknown_glyph: * @font: a #PangoFont. * * Returns the index of a glyph suitable for drawing unknown characters; * you should generally use PANGO_GET_UNKNOWN_GLYPH() instead, * since that may return a glyph that provides a better representation * of a particular char. (E.g., by showing hex digits, or a glyph * representative of a certain Unicode range.) * * Return value: a glyph index into @font. **/PangoGlyphpango_x_get_unknown_glyph (PangoFont *font){  return PANGO_GET_UNKNOWN_GLYPH (0);}/** * pango_x_render_layout_line: * @display:   the X display. * @drawable:  the drawable on which to draw. * @gc:        GC to use for uncolored drawing. * @line:      a #PangoLayoutLine. * @x:         the x position of start of string (in pixels). * @y:         the y position of baseline (in pixels). * * Renders a #PangoLayoutLine onto an X drawable. */voidpango_x_render_layout_line (Display          *display,			    Drawable          drawable,			    GC                gc,			    PangoLayoutLine  *line,			    int               x,			    int               y){  GSList *tmp_list = line->runs;  PangoRectangle overall_rect;  PangoRectangle logical_rect;  PangoRectangle ink_rect;  PangoContext *context = pango_layout_get_context (line->layout);  PangoXContextInfo *info =    g_object_get_qdata (G_OBJECT (context),			g_quark_from_static_string ("pango-x-info"));  int x_off = 0;  pango_layout_line_get_extents (line,NULL, &overall_rect);  while (tmp_list)    {      PangoUnderline uline = PANGO_UNDERLINE_NONE;      PangoLayoutRun *run = tmp_list->data;      PangoAttrColor fg_color, bg_color;      gboolean fg_set, bg_set;      GC fg_gc;      tmp_list = tmp_list->next;      pango_x_get_item_properties (run->item, &uline, &fg_color, &fg_set, &bg_color, &bg_set);      if (fg_set && info->get_gc_func)	fg_gc = info->get_gc_func (context, &fg_color.color, gc);      else	fg_gc = gc;      if (uline == PANGO_UNDERLINE_NONE)	pango_glyph_string_extents (run->glyphs, run->item->analysis.font,				    NULL, &logical_rect);      else	pango_glyph_string_extents (run->glyphs, run->item->analysis.font,				    &ink_rect, &logical_rect);      if (bg_set && info->get_gc_func)	{	  GC bg_gc = info->get_gc_func (context, &bg_color.color, gc);	  XFillRectangle (display, drawable, bg_gc,			  x + (x_off + logical_rect.x) / PANGO_SCALE,			  y + overall_rect.y / PANGO_SCALE,			  logical_rect.width / PANGO_SCALE,			  overall_rect.height / PANGO_SCALE);	  if (info->free_gc_func)	    info->free_gc_func (context, bg_gc);	}      pango_x_render (display, drawable, fg_gc, run->item->analysis.font, run->glyphs,		      x + x_off / PANGO_SCALE, y);      switch (uline)	{	case PANGO_UNDERLINE_NONE:	  break;	case PANGO_UNDERLINE_DOUBLE:	  XDrawLine (display, drawable, fg_gc,		     x + (x_off + ink_rect.x) / PANGO_SCALE - 1, y + 4,		     x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE, y + 4);	  /* Fall through */	case PANGO_UNDERLINE_SINGLE:	  XDrawLine (display, drawable, fg_gc,		     x + (x_off + ink_rect.x) / PANGO_SCALE - 1, y + 2,		     x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE, y + 2);	  break;	case PANGO_UNDERLINE_ERROR:	  {	    int point_x;	    int counter = 0;	    int end_x = x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE;	    for (point_x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1;		 point_x <= end_x;		 point_x += 2)	      {		if (counter)		  XDrawLine (display, drawable, gc,			     point_x, y + 2, MIN (point_x + 1, end_x), y + 2);		else		  XDrawLine (display, drawable, gc,			     point_x, y + 3, MIN (point_x + 1, end_x), y + 3);		counter = (counter + 1) % 2;	      }	  }	  break;	case PANGO_UNDERLINE_LOW:	  XDrawLine (display, drawable, fg_gc,		     x + (x_off + ink_rect.x) / PANGO_SCALE - 1, y + (ink_rect.y + ink_rect.height) / PANGO_SCALE + 2,		     x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE, y + (ink_rect.y + ink_rect.height) / PANGO_SCALE + 2);	  break;	}      if (fg_set && info->get_gc_func && info->free_gc_func)	info->free_gc_func (context, fg_gc);      x_off += logical_rect.width;    }}/** * pango_x_render_layout: * @display:   the X display. * @drawable:  the drawable on which to draw. * @gc:        GC to use for uncolored drawing. * @layout:    a #PangoLayout. * @x:         the x position of the left of the layout (in pixels). * @y:         the y position of the top of the layout (in pixels). * * Renders a #PangoLayout onto an X drawable. */voidpango_x_render_layout (Display         *display,		       Drawable         drawable,		       GC               gc,		       PangoLayout     *layout,		       int              x,		       int              y){  PangoLayoutIter *iter;  g_return_if_fail (display != NULL);  g_return_if_fail (PANGO_IS_LAYOUT (layout));  iter = pango_layout_get_iter (layout);  do    {      PangoRectangle   logical_rect;      PangoLayoutLine *line;      int              baseline;      line = pango_layout_iter_get_line_readonly (iter);      pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);      baseline = pango_layout_iter_get_baseline (iter);      pango_x_render_layout_line (display, drawable, gc,				  line,				  x + PANGO_PIXELS (logical_rect.x),				  y + PANGO_PIXELS (baseline));    }  while (pango_layout_iter_next_line (iter));  pango_layout_iter_free (iter);}/* This utility function is duplicated here and in pango-layout.c; should it be * public? Trouble is - what is the appropriate set of properties? */static voidpango_x_get_item_properties (PangoItem      *item,			     PangoUnderline *uline,			     PangoAttrColor *fg_color,			     gboolean       *fg_set,			     PangoAttrColor *bg_color,			     gboolean       *bg_set){  GSList *tmp_list = item->analysis.extra_attrs;  if (fg_set)    *fg_set = FALSE;  if (bg_set)    *bg_set = FALSE;  while (tmp_list)    {      PangoAttribute *attr = tmp_list->data;      switch (attr->klass->type)	{	case PANGO_ATTR_UNDERLINE:	  if (uline)	    *uline = ((PangoAttrInt *)attr)->value;	  break;	case PANGO_ATTR_FOREGROUND:	  if (fg_color)	    *fg_color = *((PangoAttrColor *)attr);	  if (fg_set)	    *fg_set = TRUE;	  break;	case PANGO_ATTR_BACKGROUND:	  if (bg_color)	    *bg_color = *((PangoAttrColor *)attr);	  if (bg_set)	    *bg_set = TRUE;	  break;	default:	  break;	}      tmp_list = tmp_list->next;    }}/** * pango_x_apply_ligatures: * @font: unused * @subfont: unused * @glyphs: unused * @n_glyphs: unused * @clusters: unused * * Previously did subfont-specific ligation. Now a no-op. * * Return value: %FALSE, always. */gbooleanpango_x_apply_ligatures (PangoFont     *font,			 PangoXSubfont  subfont_id,			 gunichar     **glyphs,			 int           *n_glyphs,			 int           **clusters){  return FALSE;}/** * pango_x_find_first_subfont: * @font: A #PangoFont. * @rfont: A pointer to a #PangoXSubfont. * @charsets: An array of charsets. * @n_charsets: The number of charsets in @charsets. * * Looks for subfonts with the @charset charset, * in @font, and puts the first one in *@rfont. * * Return value: %TRUE if *@rfont now contains a font. */gbooleanpango_x_find_first_subfont (PangoFont      *font,			    char          **charsets,			    int             n_charsets,			    PangoXSubfont  *rfont){  int n_subfonts;  gboolean result = FALSE;  PangoXSubfont *subfonts;  int *subfont_charsets;  g_return_val_if_fail (font, 0);  g_return_val_if_fail (charsets, 0);  g_return_val_if_fail (rfont, 0);  n_subfonts = pango_x_list_subfonts (font, charsets, n_charsets,				      &subfonts, &subfont_charsets);  if (n_subfonts > 0)    {      *rfont = subfonts[0];      result = TRUE;    }  g_free (subfonts);  g_free (subfont_charsets);  return result;}/** * pango_x_fallback_shape: * @font: A #PangoFont. * @glyphs: A pointer to a #PangoGlyphString. * @text: UTF-8 string. * @n_chars: Number of UTF-8 seqs in @text. * * This is a simple fallback shaper, that can be used * if no subfont that supports a given script is found. * For every character in @text, it puts the unknown glyph. */voidpango_x_fallback_shape (PangoFont        *font,			PangoGlyphString *glyphs,			const char       *text,			int               n_chars){  PangoGlyph unknown_glyph = pango_x_get_unknown_glyph (font);  PangoRectangle logical_rect;  const char *p;  int i;  g_return_if_fail (font);  g_return_if_fail (glyphs);  g_return_if_fail (text);  g_return_if_fail (n_chars >= 0);  pango_font_get_glyph_extents (font, unknown_glyph, NULL, &logical_rect);  pango_glyph_string_set_size (glyphs, n_chars);  p = text;  for (i = 0; i < n_chars; i++)    {      glyphs->glyphs[i].glyph = unknown_glyph;      glyphs->glyphs[i].geometry.x_offset = 0;      glyphs->glyphs[i].geometry.y_offset = 0;      glyphs->glyphs[i].geometry.width = logical_rect.width;      glyphs->log_clusters[i] = p - text;      p = g_utf8_next_char (p);    }}/** * pango_x_font_get_unknown_glyph: * @font: a #PangoFont. * @wc: the Unicode character for which a glyph is needed. * * Returns the index of a glyph suitable for drawing @wc as an * unknown character. * * Use PANGO_GET_UNKNOWN_GLYPH() instead. * * Return value: a glyph index into @font. */PangoGlyphpango_x_font_get_unknown_glyph (PangoFont *font,				gunichar   wc){  return PANGO_GET_UNKNOWN_GLYPH (wc);}

⌨️ 快捷键说明

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