please dont rip this site
////////////////////////////////////////////////////////////
// softfont.cpp

#ifdef __WATCOMC__
#include <mem.h>
#else
#include <memory.h>
#endif
#include <stdlib.h>

#include "rasterop.h"
#include "softfont.h"
#include "util.h"


#define SWAB(w)		((w) = (((w)&0x00FF)<<8) | ((w)>>8)&0x00FF)


static void font_deletechars( FONTNODE *pf );


static FONTLIST fontlist;


FONTNODE *font_find( int id )
{
	for( FONTNODE *pf = fontlist; pf; pf = pf->next )
		if( pf->id == id )
			return pf;
	return NULL;
}

FONTNODE *font_new( int id, char *pdata, int cdata )
{
	FONTNODE *pf = font_find( id );
	if( pf )
	{
		font_deletechars( pf );
	}
	else
	{
		pf = new FONTNODE;
		if( !pf )
			return NULL;
		pf->next = fontlist;
		pf->id = id;
		memset( pf->cd, 0, sizeof(pf->cd) );
		fontlist = pf;
	}
	if( cdata >= sizeof(FONTDESC) )
	{
		memcpy( &pf->fd, pdata, sizeof(FONTDESC) );
	}
	else
	{
		memcpy( &pf->fd, pdata, cdata );
		memset( (char *)&pf->fd + cdata, 0, sizeof(FONTDESC) - cdata );
	}
	SWAB( pf->fd.fdsize );
	SWAB( pf->fd.baseline );
	SWAB( pf->fd.cellwidth );
	SWAB( pf->fd.cellheight );
	SWAB( pf->fd.symbolset );
	SWAB( pf->fd.pitch );
	SWAB( pf->fd.height );
	SWAB( pf->fd.xheight );
	SWAB( pf->fd.textheight );
	SWAB( pf->fd.textwidth );
	SWAB( pf->fd.firstcode );
	SWAB( pf->fd.lastcode );
	SWAB( pf->fd.capheight );
	swap( unsigned char, pf->fd.fontno[0], pf->fd.fontno[3] );
	swap( unsigned char, pf->fd.fontno[1], pf->fd.fontno[2] );
	SWAB( pf->fd.copyrightlen );

	return pf;
}

CHARDESC *font_newchar( int id, int charcode, char *pdata, int cdata )
{
	FONTNODE *pf = font_find( id );

	if( pf && charcode >= 0 && charcode <= 255 && cdata >= sizeof(CHARDESC) )
	{
		unsigned short w, h;

		swab( pdata + 10, (char *)&w, sizeof(unsigned short) );
		swab( pdata + 12, (char *)&h, sizeof(unsigned short) );
		if( pf->cd[charcode] )
		{
			free( pf->cd[charcode] );
			pf->cd[charcode] = NULL;
		}
		int n = sizeof(CHARDESC) + (w+7)/8 * h;
		pf->cd[charcode] = (CHARDESC *)new unsigned char[n];
		if( pf->cd[charcode] )
		{
			if( cdata >= n )
			{
				memcpy( pf->cd[charcode], pdata, n );
			}
			else
			{
				memcpy( pf->cd[charcode], pdata, cdata );
				memset( (char *)pf->cd[charcode] + cdata, 0, n - cdata );
			}
			SWAB( pf->cd[charcode]->leftoffset );
			SWAB( pf->cd[charcode]->topoffset );
			SWAB( pf->cd[charcode]->width );
			SWAB( pf->cd[charcode]->height );
			SWAB( pf->cd[charcode]->deltax );
		}
		return pf->cd[charcode];
	}
	return NULL;
}

int font_drawchar( unsigned char bits[3300][300], int x, int y, FONTNODE *pf, int charcode )
{
	if( pf && charcode >= 0 && charcode <= 255 && pf->cd[charcode] )
	{
		bit_blt( bits, x + pf->cd[charcode]->leftoffset, y - pf->cd[charcode]->topoffset,
				 (unsigned char *)(pf->cd[charcode] + 1), pf->cd[charcode]->width, pf->cd[charcode]->height );
		return pf->cd[charcode]->deltax;
	}
	return 0;
}

//////////////////////////////////////////////////////////////

void font_deletechars( FONTNODE *pf )
{
	for( int i=0; i<256; i++ )
	{
		if( pf->cd[i] )
		{
			free( pf->cd[i] );
			pf->cd[i] = NULL;
		}
	}
}

See also:


file: /Techref/language/pcl/pickle/softfont_cpp.htm, 27KB, , updated: 2001/4/5 15:54, local time: 2012/5/25 08:46,
TOP NEW HELP FIND: 
38.107.179.233:LOG IN

 ©2012 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE! / 

<A HREF="http://www.piclist.com/techref/language/pcl/pickle/softfont_cpp.htm"> Colorized Source Code</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 
Stepper motors CAN be smooth!
And stepper controllers can be strong and cheap. Roman Black's Linistep stepper controller kits:
o 18th microstep
o Linear smoothing
  o Open source
o Full kit $25!
 
miSim DE is an excellent, portable and powerful IDE for developing PIC applications.
The only consistant, simple to use yet powerful development environment. It simulates real-world devices via virtual component "plugins" (LED,LCD,key,motor,TV,etc) in real time, has a syntax highlighting editor, macro assembler and disassembler. Regular updates and third-party plugins keep this software ahead of any other PIC IDE.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .