Exemplo n.º 1
0
LONG PrintLine(LONG x, struct line_node *line, LONG line_nr, BOOL doublebuffer, struct InstData *data)
{
  STRPTR text = line->line.Contents;
  LONG length;
  struct RastPort *rp = &data->doublerp;

  ENTER();

  length  = LineCharsWidth(text+x, data);

  if(doublebuffer == FALSE)
    rp = &data->copyrp;

  if((line_nr > 0) && (data->update) && !(data->flags & FLG_Quiet) && data->rport != NULL && data->shown == TRUE)
  {
    LONG c_length = length;
    LONG startx = 0, stopx = 0;
    LONG starty = 0, xoffset = ((data->height-rp->TxBaseline+1)>>1)+1;
    LONG flow = 0;
    UWORD *styles = line->line.Styles;
    UWORD *colors = line->line.Colors;
    struct marking block;
    BOOL cursor = FALSE;

    if(line->line.Color && x == 0 && line->line.Length == 1)
      line->line.Color = FALSE;

    if(doublebuffer == FALSE)
    {
      starty = data->ypos+(data->height * (line_nr-1));
      xoffset = data->xpos;
    }

    flow = FlowSpace(line->line.Flow, text+x, data);
    Move(rp, xoffset+flow, starty+rp->TxBaseline);

    if(Enabled(data))
    {
      struct line_node *blkline;

      NiceBlock(&data->blockinfo, &block);

      blkline = block.startline->next;

      if(block.startline == block.stopline)
      {
        if(block.startline == line)
        {
          startx = block.startx;
          stopx = block.stopx;
        }
      }
      else
      {
        if(block.startline == line)
        {
          startx = block.startx;
          stopx = line->line.Length;
        }
        else
        {
          if(block.stopline == line)
          {
            stopx = block.stopx;
          }
          else
          {
            while((blkline != block.stopline) && (!stopx))
            {
              if(blkline == line)
              {
                stopx = line->line.Length;
              }
              blkline = blkline->next;
            }
          }
        }
      }
    }

    {
      UWORD blockstart = 0;
      UWORD blockwidth = 0;
      struct RastPort *old = muiRenderInfo(data->object)->mri_RastPort;

      if(startx < x+c_length && stopx > x)
      {
        if(startx > x)
          blockstart = TextLength(&data->tmprp, text+x, startx-x);
        else
          startx = x;

        blockwidth = ((stopx >= c_length+x) ? data->innerwidth-(blockstart+flow) : TextLength(&data->tmprp, text+startx, stopx-startx));
      }
      else if(!(data->flags & (FLG_ReadOnly | FLG_Ghosted)) &&
              line == data->actualline && data->CPos_X >= x &&
              data->CPos_X < x+c_length && !Enabled(data) &&
              (data->flags & FLG_Active || data->inactiveCursor == TRUE))
      {
        cursor = TRUE;
        blockstart = TextLength(&data->tmprp, text+x, data->CPos_X-x);

        // calculate the cursor width
        // if it is set to 6 then we should find out how the width of the current char is
        if(data->CursorWidth == 6)
          blockwidth = TextLength(&data->tmprp, (*(text+data->CPos_X) < ' ') ? (char *)" " : (char *)(text+data->CPos_X), 1);
        else
          blockwidth = data->CursorWidth;
      }

      SetDrMd(rp, JAM1);
      muiRenderInfo(data->object)->mri_RastPort = rp;

      // clear the background first
      DoMethod(data->object, MUIM_DrawBackground, xoffset, starty,
                                                  flow+blockstart, data->height,
                                                  (data->flags & FLG_InVGrp) ? 0 : data->xpos,
                                                  (data->flags & FLG_InVGrp) ? data->height*(data->visual_y+line_nr-2) : data->realypos+data->height * (data->visual_y+line_nr-2),
                                                  0);

      if(blockwidth)
      {
        ULONG color;

        // in case the gadget is in inactive state we use a different background
        // color for our selected area
        if((data->flags & FLG_Active) == 0 && (data->flags & FLG_Activated) == 0 &&
           (data->flags & FLG_ActiveOnClick) != 0)
        {
          color = data->inactivecolor;
        }
        else
          color = data->markedcolor;

        // if selectmode == 2 then a whole line should be drawn as being marked, so
        // we have to start at xoffset instead of xoffset+flow+blockstart.
        // Please note that the second part of the following "empiric" evaluation should
        // prevent that centered or right aligned lines are not correctly marked right
        // from the beginning of the line. However, it seems to be not cover 100% of all different
        // cases so that the evaluation if a line should be completely marked should be probably
        // moved elsewhere in future.
        if(data->selectmode == 2 ||
           (flow && data->selectmode != 1 && startx-x == 0 && cursor == FALSE &&
            ((data->blockinfo.startline != data->blockinfo.stopline) || x > 0)))
        {
          SetAPen(rp, color);
          RectFill(rp, xoffset, starty, xoffset+flow+blockwidth-1, starty+data->height-1);
        }
        else
        {
          SetAPen(rp, cursor ? data->cursorcolor : color);
          RectFill(rp, xoffset+flow+blockstart, starty, xoffset+flow+blockstart+blockwidth-1, starty+data->height-1);

          // if the gadget is in inactive state we just draw a skeleton cursor instead
          if(cursor == TRUE &&
             (data->flags & FLG_Active) == 0 && (data->flags & FLG_Activated) == 0)
          {
            DoMethod(data->object, MUIM_DrawBackground, xoffset+flow+blockstart+1, starty+1,
                                                        blockwidth-2, data->height-2,
                                                        (data->flags & FLG_InVGrp) ? 0 : data->xpos,
                                                        (data->flags & FLG_InVGrp) ? data->height*(data->visual_y+line_nr-2) : data->realypos+data->height * (data->visual_y+line_nr-2),
                                                        0);
          }
        }
      }


      {
        LONG  x_start = xoffset+blockstart+blockwidth,
            y_start = starty,
            x_width = data->innerwidth-(blockstart+blockwidth),
            y_width = data->height,
            x_ptrn = blockstart+blockwidth,
            y_ptrn = data->height*(data->visual_y+line_nr-2);

        if(blockwidth)
        {
          x_start += flow;
          x_width -= flow;
          x_ptrn += flow;
        }
        if(!(data->flags & FLG_InVGrp))
        {
          x_ptrn += data->xpos;
          y_ptrn += data->realypos;
        }

        DoMethod(data->object, MUIM_DrawBackground, x_start, y_start, x_width, y_width, x_ptrn, y_ptrn);
      }
      muiRenderInfo(data->object)->mri_RastPort = old;
    }

    if(doublebuffer == FALSE)
      AddClipping(data);

    SetAPen(rp, (line->line.Color ? data->highlightcolor : data->textcolor));

    while(c_length)
    {
      LONG p_length = c_length;

      SetSoftStyle(rp, convert(GetStyle(x, line)), AskSoftStyle(rp));
      if(styles)
      {
        while(*styles-1 <= x)
        {
          styles += 2;
        }
        if(*styles-x-1 < p_length)
        {
          p_length = *styles-x-1;
        }
      }

      if(colors)
      {
        while(*colors-1 <= x)
        {
          SetAPen(rp, ConvertPen(*(colors+1), line->line.Color, data));
          colors += 2;
        }
        if(*colors-x-1 < p_length)
        {
          p_length = *colors-x-1;
        }
      }

/*      if(stopx)
      {
        if((startx > x) && (startx-x < p_length))
        {
          p_length = startx-x;
          SetAPen(rp, 3);
        }
        else
        {
          if((stopx > x) && (stopx-x < p_length))
          {
            p_length = stopx-x;
            SetAPen(rp, 4);
          }
          else
            SetAPen(rp, (line->color ? data->highlightcolor : data->textcolor));
        }
      }
*/

      if(text[x+p_length-1] < ' ')
        Text(rp, text+x, p_length-1);
      else
        Text(rp, text+x, p_length);

      x += p_length;
      c_length -= p_length;
    }
    SetSoftStyle(rp, FS_NORMAL, AskSoftStyle(rp));

    if(line->line.Separator)
    {
        WORD  LeftX, LeftWidth,
            RightX, RightWidth,
            Y, Height;

      LeftX = xoffset;
      LeftWidth = flow-3;
      RightX = rp->cp_x+3;
      RightWidth = xoffset+data->innerwidth - RightX;
      Y = starty;
      Height = (line->line.Separator & LNSF_Thick) ? 2 : 1;

      if(line->line.Separator & LNSF_Middle)
        Y += (data->height/2)-Height;
      else
      {
        if(line->line.Separator & LNSF_Bottom)
          Y += data->height-(2*Height);
      }

      if(line->line.Separator & LNSF_StrikeThru || line->line.Length == 1)
      {
        LeftWidth = data->innerwidth;
      }
      else
      {
        DrawSeparator(rp, RightX, Y, RightWidth, Height, data);
      }
      DrawSeparator(rp, LeftX, Y, LeftWidth, Height, data);
    }


    if(data->flags & FLG_Ghosted)
    {
      UWORD *oldPattern = (UWORD *)rp->AreaPtrn;
      UBYTE oldSize = rp->AreaPtSz;
      UWORD newPattern[] = {0x1111, 0x4444};

      if(doublebuffer == TRUE)
      {
        ULONG ptrn1 = 0x11111111;
        ULONG ptrn2 = 0x44444444;

        ptrn1 = ptrn1>>((data->xpos-xoffset)%16);
        ptrn2 = ptrn2>>((data->xpos-xoffset)%16);

        if((data->height*(data->visual_y+line_nr-2))%2 == 0)
        {
          newPattern[0] = ptrn2;
          newPattern[1] = ptrn1;
        }
        else
        {
          newPattern[0] = ptrn1;
          newPattern[1] = ptrn2;
        }
      }
Exemplo n.º 2
0
// Show font example
void font_show_font(font_data *data,BOOL refresh)
{
	struct Rectangle rect;
	struct Region *region;
	struct RastPort rp;

	// Get display rectangle
	GetObjectRect(data->list,GAD_FONT_DISPLAY,&rect);

	// Move rectangle in
	rect.MinX+=3;
	rect.MinY+=3;
	rect.MaxX-=3;
	rect.MaxY-=3;

	// Copy rastport
	rp=*data->window->RPort;

	// Refresh?
	if (refresh)
	{
		LockLayerInfo(&data->window->WScreen->LayerInfo);
		BeginRefresh(data->window);
	}

	// Clear background
	SetAPen(&rp,DRAWINFO(data->window)->dri_Pens[SHINEPEN]);
	RectFill(&rp,rect.MinX-1,rect.MinY-1,rect.MaxX+1,rect.MaxY+1);

	// Refreshing?
	if (refresh) EndRefresh(data->window,FALSE);

	// Create region
	if ((region=NewRegion()))
	{
		// Set rectangle
		OrRectRegion(region,&rect);

		// Install region
		InstallClipRegion(data->window->WLayer,region);
	}

	// Refreshing?
	if (refresh) BeginRefresh(data->window);

	// Got a font?
	if (data->font)
	{
		ULONG flags;
		short y;
		struct TextExtent extent;
		char *ptr,*end;

		// Set pen and font
		SetAPen(&rp,DRAWINFO(data->window)->dri_Pens[TEXTPEN]);
		SetDrMd(&rp,JAM1);
		SetFont(&rp,data->font);

		// Get style flags
		flags=0;
		if (GetGadgetValue(data->list,GAD_FONT_BOLD)) flags|=FSF_BOLD;
		if (GetGadgetValue(data->list,GAD_FONT_ITALIC)) flags|=FSF_ITALIC;
		if (GetGadgetValue(data->list,GAD_FONT_ULINE)) flags|=FSF_UNDERLINED;

		// Set styles
		SetSoftStyle(&rp,flags,FSF_BOLD|FSF_ITALIC|FSF_UNDERLINED);

		// Valid font to draw?
		if (data->font_text[0])
		{
			// Get end of the string
			end=data->font_text+strlen(data->font_text);

			// Initial coordinates
			y=rect.MinY;

			// Initialise position
			if (!(ptr=strchr(data->font_text,'A')))
				ptr=data->font_text;
			Move(&rp,rect.MinX,y+rp.TxBaseline);

			// Draw until we reach the bottom
			while (y<rect.MaxY)
			{
				// New line
				if (rp.cp_x>rect.MaxX)
				{
					// Bump position
					y+=rp.TxHeight+1;
					Move(&rp,rect.MinX,y+rp.TxBaseline);
				}

				// Otherwise
				else
				{
					short len,maxlen;

					// Get text that will fit
					len=
						TextFit(
							&rp,
							ptr,
							(maxlen=strlen(ptr)),
							&extent,
							0,1,
							rect.MaxX-rp.cp_x+1,
							rp.TxHeight);

					// Check against length, add extra character if ok
					if (len<maxlen) ++len;

					// Draw text
					Text(&rp,ptr,len);

					// Bump text position
					ptr+=len;

					// End of the string?
					if (ptr>=end) ptr=data->font_text;
				}
			}
		}
	}

	// Finished refreshing?
	if (refresh) EndRefresh(data->window,TRUE);

	// Remove region
	if (region)
	{
		InstallClipRegion(data->window->WLayer,0);
		DisposeRegion(region);
	}

	// Unlock layers if we refreshed
	if (refresh) UnlockLayerInfo(&data->window->WScreen->LayerInfo);
}
Exemplo n.º 3
0
IPTR MenuDecorClass__MDM_DRAW_SYSIMAGE(Class *cl, Object *obj, struct mdpDrawSysImage *msg)
{
    struct RastPort 	 *rport = msg->mdp_RPort;
    UWORD   	    	 *pens = DRI(msg->mdp_Dri)->dri_Pens;
    LONG    	     	  left = msg->mdp_X;
    LONG    	     	  top = msg->mdp_Y;
    LONG   	          width = msg->mdp_Width;
    LONG   	    	  height = msg->mdp_Height;
    LONG    	    	  right = left + width - 1;
    LONG    	    	  bottom = top + height - 1;
    
    SetDrMd(rport, JAM1);
    
    switch(msg->mdp_Which)
    {
    	case SUBMENUIMAGE:
        {
            if (MENUS_AMIGALOOK)
            {
                SetAPen(rport, pens[BARBLOCKPEN]);
            }
            else
            {
                SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
            }
            RectFill(rport, left, top, right, bottom);
            SetAPen(rport, pens[BARDETAILPEN]);
            SetDrMd(rport, JAM1);
            WORD x = left;

    	    Move(rport, x, top + rport->Font->tf_Baseline);
            Text(rport, ">>", 2);
            break;
        }

    	case MENUCHECK:
        {
            if (MENUS_AMIGALOOK)
            {
                SetAPen(rport, pens[BARBLOCKPEN]);
            }
            else
            {
                SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
            }

            RectFill(rport, left, top, right, bottom);

            SetAPen(rport, pens[BARDETAILPEN]);
            menu_draw_thick_line(rport, left + 1, top + height / 3 , left + 1, bottom, 0);
            menu_draw_thick_line(rport, left + 2, bottom, right - 2, top, 0);

            break;
        }

	case AMIGAKEY:
	{
            struct TextFont *oldfont;
            UBYTE   	     oldstyle;
            
            if (MENUS_AMIGALOOK)
            {
                SetAPen(rport, pens[BARDETAILPEN]);
            }
            else
            {
                SetAPen(rport, pens[SHINEPEN]);
            }

            RectFill(rport, left, top, right, bottom);

            if (MENUS_AMIGALOOK)
            {
                SetAPen(rport, pens[BARBLOCKPEN]);
    
                oldfont = rport->Font;
                oldstyle = rport->AlgoStyle;
    
                SetFont(rport, GfxBase->DefaultFont);
                SetSoftStyle(rport, FSF_ITALIC, AskSoftStyle(rport));
    
                Move(rport, left + (width - rport->TxWidth) / 2,
                     top  + (height - rport->TxHeight) / 2 + rport->TxBaseline);
                Text(rport, "A", 1);
    
                SetSoftStyle(rport, oldstyle, AskSoftStyle(rport));
                SetFont(rport, oldfont);
    
                SetAPen(rport, pens[BARBLOCKPEN]);
            }
            else
            {
                SetAPen(rport, pens[SHADOWPEN]);
    
                RectFill(rport, left + 1, top, right - 1, top);
                RectFill(rport, right, top + 1, right, bottom - 1);
                RectFill(rport, left + 1, bottom, right - 1, bottom);
                RectFill(rport, left, top + 1, left, bottom - 1);
    
                SetAPen(rport, pens[BACKGROUNDPEN]);
                RectFill(rport, left + 1, bottom - 1, right - 1, bottom - 1);
                RectFill(rport, right - 1, top + 1, right - 1, bottom - 2);
    
                RectFill(rport, left + 2, top + 2, left + 4, top + 2);
                RectFill(rport, left + 2, top + 3, left + 2, top + 4);
    
                SetAPen(rport, pens[SHADOWPEN]);
                RectFill(rport, left + 2, bottom - 2, right - 2, bottom - 2);
                RectFill(rport, right - 2, top + 2, right - 2, bottom - 4);
    
                {
                    WORD a_size   = height - 7;
                    WORD a_left   = left + 5;
                    WORD a_top    = top + 2;
                    WORD a_right  = a_left + a_size;
                    WORD a_bottom = a_top + a_size;
    
                    Move(rport, a_left, a_bottom);
                    Draw(rport, a_right, a_top);
                    Draw(rport, a_right, a_bottom);
                    Move(rport, a_right - 1, a_top + 1);
                    Draw(rport, a_right - 1, a_bottom);
                }
    
                SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
            }
            
            WritePixel(rport, left, top);
            WritePixel(rport, right, top);
            WritePixel(rport, right, bottom);
            WritePixel(rport, left, bottom);
	}
    }
    return TRUE;
}
Exemplo n.º 4
0
/**************************************************************************
   Render tab bar
**************************************************************************/
static void RenderRegisterTab(struct IClass *cl, Object *obj, ULONG flags)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    WORD tabx;

    /*
     * Erase / prepare for drawing
     */
    if (flags & MADF_DRAWOBJECT)
    {
        DoMethod(obj, MUIM_DrawParentBackground, data->left, data->top,
                 data->framewidth, data->tab_height - 1, data->left, data->top, 0);
    }
    else
    {
        /* draw parent bg over oldactive */
        IPTR method;
        WORD old_left, old_top, old_width, old_height;
        struct RegisterTabItem *ri = &data->items[data->oldactive];
        if (data->oldactive >= data->columns) method = MUIM_DrawBackground;
        else method = MUIM_DrawParentBackground;

        old_left = _left(obj) + ri->x1 - 2;
        old_top = _top(obj) + ri->y1;
        old_width = ri->x2 - ri->x1 + 5;
        old_height = data->tab_height - 1;
        DoMethod(obj, method, old_left, old_top,
                 old_width, old_height, old_left, old_top, 0);
        SetDrMd(_rp(obj), JAM1);
        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
        RectFill(_rp(obj), old_left, old_top + old_height, old_left + old_width, old_top + old_height);
    }

    SetDrMd(_rp(obj), JAM1);
    SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
    SetFont(_rp(obj), _font(obj));
    SetSoftStyle(_rp(obj), FS_NORMAL, AskSoftStyle(_rp(obj)));


    /*
     * Draw new graphics
     */
    /* register frame */
    if (flags & MADF_DRAWOBJECT || (data->active / data->columns != data->oldactive / data->columns))
    {
        int i,y,tabs_on_bottom = 0;

        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);

        RectFill(_rp(obj), data->left,
                 data->top + data->tab_height - 1,
                 data->left,
                 data->top + data->tab_height + data->frameheight - 1);

        y = data->top + data->tab_height - 1;

        for (i=0; i<data->rows; i++)
        {
            if (!tabs_on_bottom && (i > data->active/data->columns))
            {
                y = _bottom(obj) - muiAreaData(obj)->mad_InnerBottom + data->tab_height;
                tabs_on_bottom = 1;
            }

            RectFill(_rp(obj), data->left + 1, y, data->left + data->framewidth - 2, y);
            y += data->tab_height;
        }

        SetAPen(_rp(obj), _pens(obj)[MPEN_SHADOW]);

        RectFill(_rp(obj), data->left + data->framewidth - 1,
                 data->top + data->tab_height - 1,
                 data->left + data->framewidth - 1,
                 data->top + data->tab_height + data->frameheight - 1);

        RectFill(_rp(obj), data->left + 1,
                 data->top + data->tab_height + data->frameheight - 1,
                 data->left + data->framewidth - 2,
                 data->top + data->tab_height + data->frameheight - 1);
        for(i = 0, tabx = 0; i < data->numitems; i++)
        {
            RenderRegisterTabItem(cl, obj, i);
        }
    }
    else
    {
        /* If active register has been changed and is on same row we simply draw both registers only */
        RenderRegisterTabItem(cl, obj, data->active);
        RenderRegisterTabItem(cl, obj, data->oldactive);
    }

}
main(int argc, char *argv[])
{
    unsigned char str[256];
    int i;
    int j;
    struct RastPort rp;
    unsigned char *pp;
    struct BitMap bm = {
	256, 	/* bytes per row */
	8,	/* rows */
	0,	/* flags */
	1,	/* depth */
	0,	/* pad */
	0 	/* planes */
	};
    struct TextAttr ta;
    struct TextFont *tf;
    struct FontRequester *fr;
    struct TagItem frtags[] = {
	ASL_Hail, (ULONG)"NetBSD font choices",
	ASL_Width, 640,
	ASL_Height, 400,
	ASL_LeftEdge, 10,
	ASL_TopEdge, 10,
	ASL_OKText, (ULONG)"Dump",
	ASL_CancelText, (ULONG)"Cancel",
	ASL_FontName, (ULONG)"topaz.font",
	ASL_FontHeight, 8L,
	ASL_FontStyles, FS_NORMAL,
	ASL_FuncFlags, FONF_STYLES | FONF_FIXEDWIDTH,
	TAG_DONE
	    };

    /* Let the user pick a font to dump */
    if (fr = (struct FontRequester *)
	AllocAslRequest(ASL_FontRequest, frtags)) {
	if (!AslRequest(fr, NULL)) {
	    FreeAslRequest(fr);
	    fprintf(stderr, "User requested exit\n");
	    exit (0);
	}
	ta.ta_Name = (STRPTR)malloc(strlen(fr->fo_Attr.ta_Name));
	strcpy(ta.ta_Name, fr->fo_Attr.ta_Name);
	ta.ta_YSize = fr->fo_Attr.ta_YSize;
	ta.ta_Style = fr->fo_Attr.ta_Style;
	ta.ta_Flags = fr->fo_Attr.ta_Flags;
	FreeAslRequest(fr);
    } else {
	fprintf(stderr, "Can't allocate Font Requestor\n");
	exit (1);
    }

    /* Open the selected font */
    tf = (struct TextFont *)OpenDiskFont (&ta);
    if (! tf) {
	fprintf (stderr, "Can't open font: %s\n", ta.ta_Name);
	exit (1);
    }
#ifdef DEBUG
    fprintf(stderr, "Information on selected font:\n");
    fprintf(stderr, "Name=%s\n", ta.ta_Name);
    fprintf(stderr, "Height=%d tf_Style=%x tf_Flags=%x Width=%d Baseline=%d\n",
	    tf->tf_YSize, tf->tf_Style, tf->tf_Flags, tf->tf_XSize, tf->tf_Baseline);
#endif

    /* Check for NetBSD restrictions */
    if (tf->tf_Flags & FPF_PROPORTIONAL) {
	fprintf(stderr, "NetBSD does not support proportional fonts\n");
	exit (1);
    }
    if (tf->tf_XSize > NetBSDwidth) {
	fprintf(stderr, "NetBSD does not support fonts wider than %d pixels\n", NetBSDwidth);
	exit (1);
    }

    /* Allocate area to render font in */
    InitBitMap(&bm, 1, 256 * NetBSDwidth, tf->tf_YSize);
    InitRastPort (&rp);
    rp.BitMap = &bm;
    bm.Planes[0] = pp = AllocRaster (256 * NetBSDwidth, tf->tf_YSize);
    if (!pp) {
	fprintf (stderr, "Can't allocate raster!\n");
	exit (1);
    }

    /* Initialize string to be rendered */
    for (i = 32; i < 256; i++) {
	str[i - 32] = i;
    }

    /* Render string with selected font */
    SetFont (&rp, tf);
    SetSoftStyle(&rp, ta.ta_Style ^ tf->tf_Style,
		 FSF_BOLD | FSF_UNDERLINED | FSF_ITALIC);
    Move (&rp, 0, tf->tf_Baseline);
    ClearEOL(&rp);
    if (tf->tf_XSize != NetBSDwidth) {
	/* right-justify char in cell */
	Move (&rp, NetBSDwidth - tf->tf_XSize, tf->tf_Baseline);
	/* Narrow font, put each character in space of normal font */
	for (i = 0; i < (256 - 32); i++) {
	    Text (&rp, &str[i], 1);
	    Move (&rp, rp.cp_x + (NetBSDwidth - tf->tf_XSize), rp.cp_y);
	}
    } else {
	Text (&rp, str, 256 - 32);
    }

    /* Dump them.. */
    printf ("/* Generated automatically by fontdumper.c. *DONT* distribute\n");
    printf ("   this file, it may contain information Copyright by Commodore!\n");
    printf ("\n");
    printf ("   Font: %s/%d\n", ta.ta_Name, tf->tf_YSize);
    printf (" */\n\n");

    printf ("unsigned char kernel_font_width  = %d;\n", tf->tf_XSize);
    printf ("unsigned char kernel_font_height = %d;\n", tf->tf_YSize);
    printf ("unsigned char kernel_font_baseline = %d;\n", tf->tf_Baseline);
    printf ("short         kernel_font_boldsmear = %d;\n", tf->tf_BoldSmear);
    printf ("unsigned char kernel_font_lo = 32;\n");
    printf ("unsigned char kernel_font_hi = 255;\n\n");

    printf ("unsigned char kernel_cursor[] = {\n");
    for (j = 0; j < (tf->tf_YSize -1); j++) {
	printf ("0xff, ");
    }
    printf ("0xff };\n\n");

    printf ("unsigned char kernel_font[] = {\n");
    for (i = 0; i < 256 - 32; i++) {
	printf ("/* %c */", i + 32);
	for (j = 0; j < tf->tf_YSize; j++) {
	    printf (" 0x%02x,", pp[i+j*256]);
	    }
	printf ("\n");
    }
    printf ("};\n");

    CloseFont (tf);
    FreeRaster (pp, 256 * NetBSDwidth, tf->tf_YSize);
    return (0);
}