Example #1
0
static
void do_query_font (Display *dpy, char *name)
{
    register int i;
    register XFontStruct *info = XLoadQueryFont (dpy, name);

    if (!info) {
        fprintf (stderr, "%s:  unable to get info about font \"%s\"\n",
                 program_name, name);
        return;
    }
    printf ("name:  %s\n", name ? name : "(nil)");
    printf ("  direction:\t\t%s\n", ((info->direction == FontLeftToRight)
                                     ? "left to right" : "right to left"));
    printf ("  indexing:\t\t%s\n", 
            ((info->min_byte1 == 0 && info->max_byte1 == 0) ? "linear" :
             "matrix"));
    printf ("  rows:\t\t\t0x%02x thru 0x%02x (%d thru %d)\n",
            info->min_byte1, info->max_byte1,
            info->min_byte1, info->max_byte1);
    printf ("  columns:\t\t0x%02x thru 0x%02x (%d thru %d)\n",
            info->min_char_or_byte2, info->max_char_or_byte2,
            info->min_char_or_byte2, info->max_char_or_byte2);
    printf ("  all chars exist:\t%s\n",
        (info->all_chars_exist) ? "yes" : "no");
    printf ("  default char:\t\t0x%04x (%d)\n",
            info->default_char, info->default_char);
    printf ("  ascent:\t\t%d\n", info->ascent);
    printf ("  descent:\t\t%d\n", info->descent);
    ComputeFontType (info);
    printf ("  bounds:\t\t%s", bounds_metrics_title);
    PrintBounds ("min", &info->min_bounds);
    PrintBounds ("max", &info->max_bounds);
    if (info->per_char && long_list >= L_VERYLONG) 
        print_character_metrics (info);
    printf ("  properties:\t\t%d\n", info->n_properties);
    for (i = 0; i < info->n_properties; i++)
        PrintProperty (&info->properties[i]);
    printf ("\n");

    XFreeFontInfo (NULL, info, 1);
}
Example #2
0
int
_dxfPlineDraw (tdmPortHandleP portHandle, xfieldT *xf, int buttonUp)
{
  Vector *normals ;
  Point *points = 0 ;
  struct p2d {float x, y ;} *pnts2d = 0 ;
  RGBColor *fcolors, *color_map ;
  char *cache_id ;
  enum approxE approx ;
  tdmStripArraySB *stripsSB = 0 ;
  int type, rank, shape, is_2d ;

  DEFPORT(portHandle) ;

  ENTRY(("_dxfPlineDraw(0x%x, 0x%x, %d)", portHandle, xf, buttonUp));

  /*
   *  Transparent surfaces are stripped for those ports which implement
   *  transparency with the screen door technique, but we need to sort them
   *  as individual polygons to apply the more accurate alpha composition
   *  method supported by Starbase.
   *
   *  Connection-dependent colors are not supported by Starbase strips.
   */

  approx = buttonUp ? xf->attributes.buttonUp.approx :
	              xf->attributes.buttonDown.approx ;

  if (
#ifdef ALLOW_LINES_APPROX_BY_DOTS
      (approx == approx_dots) ||
#endif
      (xf->colorsDep == dep_connections))
    {
      int status ;
      PRINT(("drawing as individual polygons"));
      status = _dxfLineDraw (portHandle, xf, buttonUp) ;
      EXIT((""));
      return status ;
    }

  /*
   *  Extract rendering data from the xfield.
   */

  if (DXGetArrayClass(xf->fcolors_array) == CLASS_CONSTANTARRAY)
      fcolors = (Pointer) DXGetArrayEntry(xf->fcolors, 0, NULL) ;
  else
      fcolors = (Pointer) DXGetArrayData(xf->fcolors_array) ;

  color_map = (RGBColor *) DXGetArrayData(xf->cmap_array) ;

  if (DXGetArrayClass(xf->normals_array) == CLASS_CONSTANTARRAY)
      normals = (Pointer) DXGetArrayEntry(xf->normals, 0, NULL) ;
  else
      normals = (Pointer) DXGetArrayData(xf->normals_array) ;

#if 0
  if (xf->colorsDep != dep_field)
  {
    /*
     *  Dense fields of varying colors are visually confusing
     *  without hidden surface, even with wireframe approximation.
     */
    hidden_surface (FILDES, TRUE, FALSE) ;
  }
  else /* RE : <LUMBA281> */
  {
     hidden_surface(FILDES, TRUE, FALSE);
  }
#endif 

  hidden_surface(FILDES, TRUE, FALSE);

  if (xf->colorsDep == dep_field)
    {
      /* render field in constant color */
      cache_id = "CpfPline" ;
      SET_COLOR(fill_color, 0) ;
      SET_COLOR(line_color, 0) ;
    }
  else
    {
      cache_id = "CpfPline" ;
    }

  /*
   *  Render strips.
   */
  
  PRINT(("%s", cache_id));
  if (stripsSB = tdmGetTmeshCacheSB (cache_id, xf))
    {
      /*
       *  Use pre-constructed Starbase strips obtained from executive cache.
       */
      
      register tdmTmeshCacheSB *stripArray, *end ;
      PRINT(("got strips from cache"));
      PrintBounds() ;
      
      stripArray = stripsSB->stripArray ;
      end = &stripArray[stripsSB->num_strips] ;
      
      for ( ; stripArray < end ; stripArray++)
	{
	  polyline_with_data3d
	    (FILDES, stripArray->clist, stripArray->numverts,
	     stripArray->numcoords, stripArray->vertex_flags, NULL) ;
	}
    }
  else
    {
      /*
       *  Construct an array of Starbase strips and cache it.
       */

      register int vsize ;
      int *connections, (*strips)[2] ;
      int cOffs, nOffs, vertex_flags, facet_flags, numStrips ;
      tdmTmeshCacheSB *stripArray ;
      PRINT(("building new strips"));

      /* determine vertex and facet types and sizes */
      vertex_flags = 0 ;
      facet_flags = UNIT_NORMALS ;
      vsize = 3 ;

      if (fcolors && xf->colorsDep != dep_field)
	{
	  /* vertex has at least 6 floats, with color at float 3 */
	  vsize = 6 ; cOffs = 3 ;
	  vertex_flags |= VERTEX_COLOR ;
	}
      
      /* get positions */
      if (is_2d = IS_2D (xf->positions_array, type, rank, shape))
	pnts2d = (struct p2d *) DXGetArrayData(xf->positions_array) ;
      else
	points = (Point *) DXGetArrayData(xf->positions_array) ;
      
      /* get strip topology */
      connections = (int *)DXGetArrayData(xf->connections_array) ;
      strips = (int (*)[2])DXGetArrayData(xf->meshes) ;
      numStrips = xf->nmeshes ;
      
      DebugMessage() ;
      
      /* allocate space for Starbase strip data */
      stripsSB = (tdmStripArraySB *) tdmAllocate(sizeof(tdmStripArraySB)) ;
      if (!stripsSB)
	{
	  PRINT(("out of memory allocating strip structure"));
	  DXErrorGoto (ERROR_INTERNAL, "#13000") ;
	}
      
      stripsSB->stripArray = 0 ;
      stripsSB->num_strips = 0 ;
      
      /* allocate array of Starbase strips */
      stripArray =
	stripsSB->stripArray = (tdmTmeshCacheSB *)
	  tdmAllocate(numStrips*sizeof(tdmTmeshCacheSB));
      
      if (!stripArray)
	{
	  PRINT(("out of memory allocating array of strips"));
	  DXErrorGoto (ERROR_INTERNAL, "#13000") ;
	}
      
      for ( ; stripsSB->num_strips < numStrips ; stripsSB->num_strips++)
	{
	  /* each iteration constructs and draws one Starbase strip */
	  register float *clist = 0, *gnormals = 0 ;
	  register int i, dV, *pntIdx, numPnts ;
	  
	  stripArray->clist = 0 ;
	  stripArray->gnormals = 0 ;
	  
	  /* get the number of points in this strip */
	  numPnts = strips[stripsSB->num_strips][1] ;
	  
	  /* allocate coordinate list */
	  stripArray->clist = clist =
	    (float *) tdmAllocate(numPnts*vsize*sizeof(float)) ;
	  
	  if (!clist)
	    {
	      PRINT(("out of memory allocating coordinate list"));
	      DXErrorGoto(ERROR_INTERNAL, "#13000") ;
	    }
	  
	  /* get the sub-array of connections making up this strip */
	  pntIdx = &connections[strips[stripsSB->num_strips][0]] ;
	  
	  /* copy vertex coordinates into clist */
	  if (is_2d)
	    for (i=0, dV=0 ; i<numPnts ; i++, dV+=vsize)
	      {
		*(struct p2d *)(clist+dV) = pnts2d[pntIdx[i]] ;
		((Point *)(clist+dV))->z = 0 ;
	      }
	  else
	    for (i=0, dV=0 ; i<numPnts ; i++, dV+=vsize)
	      *(Point *)(clist+dV) = points[pntIdx[i]] ;
	  
	  /* copy vertex colors */
	  if (vertex_flags & VERTEX_COLOR)
	    if (color_map)
	      for (i=0, dV=cOffs ; i<numPnts ; i++, dV+=vsize)
		*(RGBColor *)(clist+dV) =
		  color_map[((char *)fcolors)[pntIdx[i]]] ;
	    else
	      for (i=0, dV=cOffs ; i<numPnts ; i++, dV+=vsize)
		*(RGBColor *)(clist+dV) = fcolors[pntIdx[i]] ;
	  
	  /* save other strip info */
	  stripArray->numverts = numPnts ;
	  stripArray->numcoords = vsize-3 ;
	  stripArray->vertex_flags = vertex_flags ;
	  stripArray->facet_flags = facet_flags ;
	  
	  polyline_with_data3d (FILDES, clist, numPnts,
				vsize-3, vertex_flags, NULL) ;
	  
	  /* increment strip */
	  stripArray++ ;
	}
      
      /* cache strip array */
      tdmPutTmeshCacheSB (cache_id, xf, stripsSB) ;
    }

  /* restore hidden surface OFF */
  hidden_surface(FILDES, FALSE, FALSE) ;
  EXIT(("OK"));
  return OK ;

 error:
  tdmFreeTmeshCacheSB((Pointer)stripsSB) ;
  hidden_surface(FILDES, FALSE, FALSE) ;
  EXIT(("ERROR"));
  return ERROR ;
}