Esempio n. 1
0
/* draw_contour() draws all of the contours that make up a line.
   to access the ft font information out of the pango font info.
 */
static void draw_contour(paps_private_t *paps,
			 GString *layout_str,
			 PangoLayoutLine *pango_line,
			 double line_start_pos_x,
			 double line_start_pos_y
			 )
{
  GSList *runs_list;
  double scale = 72.0 / PANGO_SCALE  / PAPS_DPI; 

  g_string_append(layout_str, "(");
  
  /* Loop over the runs and output font info */
  runs_list = pango_line->runs;
  double x_pos = line_start_pos_x;
  while(runs_list)
    {
      PangoLayoutRun *run = runs_list->data;
      PangoItem *item = run->item;
      PangoGlyphString *glyphs = run->glyphs;
      PangoAnalysis *analysis = &item->analysis;
      PangoFont *font = analysis->font;
      FT_Face ft_face = pango_ft2_font_get_face(font);
      int num_glyphs = glyphs->num_glyphs;
      int glyph_idx;
      
      for (glyph_idx=0; glyph_idx<num_glyphs; glyph_idx++)
        {
          PangoGlyphGeometry geometry = glyphs->glyphs[glyph_idx].geometry;
          double glyph_pos_x, glyph_pos_y;

          glyph_pos_x = x_pos + 1.0*geometry.x_offset * scale;
          glyph_pos_y = line_start_pos_y - 1.0*geometry.y_offset * scale;

	  x_pos += geometry.width * scale * paps->scale_x;

          if (glyphs->glyphs[glyph_idx].glyph == PANGO_GLYPH_EMPTY)
            continue;

	  draw_bezier_outline(paps,
			      layout_str,
			      ft_face,
			      &glyphs->glyphs[glyph_idx],
			      glyph_pos_x,
			      glyph_pos_y);
        }

      runs_list = runs_list->next;
    }
  
  g_string_append(layout_str, ")paps_exec\n");
  
}
Esempio n. 2
0
/* postscript_draw_contour() dumps out the information of a line. It shows how
   to access the ft font information out of the pango font info.
*/
void postscript_draw_contour(DiaPsRenderer *renderer,
			     int dpi_x,
			     PangoLayoutLine *pango_line,
			     double line_start_pos_x,
			     double line_start_pos_y)
{
  GSList *runs_list;
  int num_runs = 0;

  /* First calculate number of runs in text */
  runs_list = pango_line->runs;
  while(runs_list)
  {
    num_runs++;
    runs_list = runs_list->next;
  }
  /* Loop over the runs and output font info */
  runs_list = pango_line->runs;
  while(runs_list)
  {
    PangoLayoutRun *run = runs_list->data;
    PangoItem *item = run->item;
    PangoGlyphString *glyphs = run->glyphs;
    PangoAnalysis *analysis = &item->analysis;
    PangoFont *font = analysis->font;
    FT_Face ft_face;
    int bidi_level;
    int num_glyphs;
    int glyph_idx;

    if (font == NULL) {
      fprintf(stderr, "No font found\n");
      continue;
    } 
    ft_face = pango_ft2_font_get_face(font);
    if (ft_face == NULL) {
      fprintf(stderr, "Failed to get face for font %s\n",
	      pango_font_description_to_string(pango_font_describe(font)));
      continue;
    }

    /*
      printf("Got face %s (PS %s) for font %s (diafont %s)\n",
      ft_face->family_name,
      FT_Get_Postscript_Name(ft_face),
      pango_font_description_to_string(pango_font_describe(font)),
      dia_font_get_family(renderer->current_font));
    */

    bidi_level = item->analysis.level;
    num_glyphs = glyphs->num_glyphs;
      
    for (glyph_idx=0; glyph_idx<num_glyphs; glyph_idx++)
    {
      PangoGlyphGeometry geometry = glyphs->glyphs[glyph_idx].geometry;
      double pos_x;
      double pos_y;
      double scale = 2.54/PANGO_SCALE/dpi_x;/*72.0 / PANGO_SCALE  / dpi_x;*/

      pos_x = line_start_pos_x + 1.0* geometry.x_offset * scale;
      pos_y = line_start_pos_y - 1.0*geometry.y_offset * scale;

      line_start_pos_x += 1.0 * geometry.width * scale;

      /*
	printf("Drawing glyph %d: index %d at %f, %f (w %d)\n", glyph_idx, 
	glyphs->glyphs[glyph_idx].glyph, pos_x, pos_y,
	geometry.width);
      */	  
      draw_bezier_outline(renderer,
			  dpi_x,
			  ft_face,
			  (FT_UInt)(glyphs->glyphs[glyph_idx].glyph),
			  pos_x, pos_y
			  );
    }
      
    runs_list = runs_list->next;
  }
  
}