/*
 * 	FontDemo - 
 *		This demonstrates drawing WEBFONT text.
 *
 *			Paul Haeberli - 1995
 */
import java.awt.*;
import java.lang.*;
import java.awt.image.*;
import java.util.Random;
import java.io.PrintStream;

public class FontDemo extends java.applet.Applet {
    Image offscrImg;
    Graphics offscrG, myG;
    int wxsize, wysize, height;
    GifFont pf;

    public void init() {
	wxsize = size().width;
	wysize = size().height;
	resize(wxsize,wysize);
	offscrImg = createImage(wxsize,wysize);
	offscrG = offscrImg.getGraphics();
 	myG = getGraphics();
        pf = new GifFont(this,getDocumentBase(),getParameter("font"));
	height = pf.getSize();
	drawtext(wxsize/2,wysize/2,"Downloaded bitmaps!");

    }
    public void drawtext(int x,int y, String str) {
	offscrG.setColor(Color.white);
	offscrG.fillRect(0,0,size().width,size().height);
	/* pf.setPosition(wxsize/2,wysize/2); */
	pf.setPosition(x,y);
	pf.drawCenteredString(offscrG,str);
    }
    public boolean mouseDown(Event evt, int x, int y) {
	offscrG.setColor(Color.white);
	offscrG.fillRect(0,0,size().width,size().height);
	return true;
    }
    public boolean mouseDrag(Event evt, int x, int y) {
	/* y = y-100; */
	/* pf.setSpacing((int)(y/10.0)); */
	drawtext(x,y+0*height,"Downloaded bitmaps!");
	paint(myG);
	return true;
    }
    public void paint(Graphics g) {
	g.drawImage(offscrImg,0,0,this);
    }
}
