Ejemplo n.º 1
0
void
plD_line_plm(PLStream *pls, short x1, short y1, short x2, short y2)
{
    PLmDev *dev = (PLmDev *) pls->dev;
    U_CHAR c;
    U_SHORT xy[4];

    /* dbug_enter("plD_line_plm"); */

    /* Failsafe check */

#ifdef DEBUG
    if (x1 < dev->xmin || x1 > dev->xmax ||
	x2 < dev->xmin || x2 > dev->xmax ||
	y1 < dev->ymin || y1 > dev->ymax ||
	y2 < dev->ymin || y2 > dev->ymax) {

	pldebug("plD_line_plm",
		"coordinates out of bounds -- \nActual: (%i,%i), (%i,%i) Bounds: (%i,%i,%i,%i)\n", 
		x1, y1, x2, y2, dev->xmin, dev->xmax, dev->ymin, dev->ymax);
    }
#endif

/* If continuation of previous line send the LINETO command, which uses
   the previous (x,y) point as it's starting location.  This results in a
   storage reduction of not quite 50%, since the instruction length for
   a LINETO is 5/9 of that for the LINE command, and given that most
   graphics applications use this command heavily.

   Still not quite as efficient as tektronix format since we also send the
   command each time (so shortest command is 25% larger), but a lot easier
   to implement than the tek method.  
 */
    if (x1 == dev->xold && y1 == dev->yold) {

	c = (U_CHAR) LINETO;
	plm_wr( pdf_wr_1byte(pls->pdfs, c) );

	xy[0] = x2;
	xy[1] = y2;
	plm_wr( pdf_wr_2nbytes(pls->pdfs, xy, 2) );
    }
    else {
	c = (U_CHAR) LINE;
	plm_wr( pdf_wr_1byte(pls->pdfs, c) );

	xy[0] = x1;
	xy[1] = y1;
	xy[2] = x2;
	xy[3] = y2;
	plm_wr( pdf_wr_2nbytes(pls->pdfs, xy, 4) );
    }
    dev->xold = x2;
    dev->yold = y2;
}
Ejemplo n.º 2
0
static void
plm_fill(PLStream *pls)
{
    PLmDev *dev = (PLmDev *) pls->dev;

    dbug_enter("plm_fill");

    plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->dev_npts) );

    plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) pls->dev_x, pls->dev_npts) );
    plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) pls->dev_y, pls->dev_npts) );

    dev->xold = PL_UNDEFINED;
    dev->yold = PL_UNDEFINED;
}
Ejemplo n.º 3
0
void
plD_polyline_plm(PLStream *pls, short *xa, short *ya, PLINT npts)
{
    PLmDev *dev = (PLmDev *) pls->dev;
    U_CHAR c = (U_CHAR) POLYLINE;

    dbug_enter("plD_polyline_plm");

    plm_wr( pdf_wr_1byte(pls->pdfs, c) );

    plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) npts) );

    plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) xa, npts) );
    plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) ya, npts) );

    dev->xold = xa[npts - 1];
    dev->yold = ya[npts - 1];
}
Ejemplo n.º 4
0
int
main( void )
{
    short       j, k, ib, nindx, nchars, nleng, htab, zero;
    short       *hrshlst;
    signed char ix, iy;
    long        fpos;
    PDFstrm     *pdfs;

    hrshlst = (short *) malloc( 4 * 176 * sizeof ( short ) );

    ib = 0;
    for ( j = 0; j < 4; j++ )
        for ( k = 0; k < 176; k++ )
            hrshlst[ib++] = *( hersh[j] + k );

    pdfs = pdf_fopen( PL_XFONT, "wb+" );
    if ( !pdfs )
    {
        printf( "Error opening extended font file.\n" );
        exit( 1 );
    }

    htab = 4 * 256 + 176;

    pdf_wr_2bytes( pdfs, htab );
    pdf_wr_2nbytes( pdfs, (U_SHORT *) hrshlst, 4 * 176 );

    nleng = 1;
    zero  = 0;
    nindx = 0;
    fpos  = ftell( pdfs->file );
    pdf_wr_2bytes( pdfs, nindx );
    for ( j = 0; j < 30; j++ )
    {
        for ( k = 0; k < 100; k++ )
        {
            ib = *( findex[j] + k );
            if ( ib == 0 )
            {
                pdf_wr_2bytes( pdfs, zero );
                nindx++;
            }
            else
            {
                pdf_wr_2bytes( pdfs, nleng );
                nindx++;
                for (;; )
                {
                    ix = *( buffer[ib / 100] + ib % 100 ) / 128 - 64;
                    iy = *( buffer[ib / 100] + ib % 100 ) % 128 - 64;
                    ib++;
                    if ( ix == -64 )
                        ix = 64;
                    if ( iy == -64 )
                        iy = 64;
                    nleng++;
                    if ( ix == 64 && iy == 64 )
                        break;
                }
            }
        }
    }
    fseek( pdfs->file, fpos, 0 );
    pdf_wr_2bytes( pdfs, nindx );

    fseek( pdfs->file, 0, 2 );
    fpos   = ftell( pdfs->file );
    nleng  = 1;
    nchars = 0;
    pdf_wr_2bytes( pdfs, nleng );
    for ( j = 0; j < 30; j++ )
    {
        for ( k = 0; k < 100; k++ )
        {
            ib = *( findex[j] + k );
            if ( ib != 0 )
            {
                for (;; )
                {
                    ix = *( buffer[ib / 100] + ib % 100 ) / 128 - 64;
                    iy = *( buffer[ib / 100] + ib % 100 ) % 128 - 64;
                    ib++;
                    if ( ix == -64 )
                        ix = 64;
                    if ( iy == -64 )
                        iy = 64;
                    fputc( ix, pdfs->file );
                    fputc( iy, pdfs->file );
                    nleng++;
                    if ( ix == 64 && iy == 64 )
                        break;
                }
                nchars++;
            }
        }
    }
    nleng--;
    fseek( pdfs->file, fpos, 0 );
    pdf_wr_2bytes( pdfs, nleng );
    pdf_close( pdfs );

    printf( "There are %d characters in font set.\n", nchars - 1 );
    exit( 0 );
}
Ejemplo n.º 5
0
int
main( void )
{
    size_t  i, j, k, ib, nstd;
    U_SHORT nchars, nleng, htab, nindx, zero;
    U_SHORT *hrshlst, *hrshidx;
    int     ix, iy;
    long    fpos;
    PDFstrm *pdfs;

    hrshlst = (U_SHORT *) malloc( 176 * sizeof ( U_SHORT ) );
    hrshidx = (U_SHORT *) malloc( 176 * sizeof ( U_SHORT ) );

    ib = 0;
    for ( k = 0; k < 176; k++ )
        hrshlst[ib++] = (U_SHORT) *( hersh[0] + k );

// Sort list

    qsort( (char *) hrshlst, ib, sizeof ( U_SHORT ), compare );

// Remove duplicates

    k = 0;
    j = 0;
    do
    {
        if ( hrshlst[k] == hrshlst[j] )
            j++;
        else
            hrshlst[++k] = hrshlst[j];
    } while ( j < ib );

    nstd = k + 1;

// Now reindex the fonts

    for ( k = 0; k < 176; k++ )
        for ( i = 0; i < nstd; i++ )
            if ( *( hersh[0] + k ) == hrshlst[i] )
            {
                hrshidx[k] = (U_SHORT) ( i + 1 );
                break;
            }

    pdfs = pdf_fopen( PL_SFONT, "wb+" );
    if ( !pdfs )
    {
        printf( "Error opening standard font file.\n" );
        exit( 1 );
    }

    htab = 1 * 256 + 176;
    pdf_wr_2bytes( pdfs, htab );
    pdf_wr_2nbytes( pdfs, hrshidx, 176 );

    zero  = 0;
    nindx = 0;
    nleng = 1;
    fpos  = ftell( pdfs->file );

    pdf_wr_2bytes( pdfs, nindx );
    for ( j = 0; j < nstd; j++ )
    {
        ib = (size_t) *( findex[( hrshlst[j] - 1 ) / 100] + ( hrshlst[j] - 1 ) % 100 );
        if ( ib == 0 )
        {
            pdf_wr_2bytes( pdfs, zero );
            nindx++;
        }
        else
        {
            pdf_wr_2bytes( pdfs, nleng );
            nindx++;
            for (;; )
            {
                ix = *( buffer[ib / 100] + ib % 100 ) / 128 - 64;
                iy = *( buffer[ib / 100] + ib % 100 ) % 128 - 64;
                ib++;
                if ( ix == -64 )
                    ix = 64;
                if ( iy == -64 )
                    iy = 64;
                nleng++;
                if ( ix == 64 && iy == 64 )
                    break;
            }
        }
    }
    fseek( pdfs->file, fpos, 0 );
    pdf_wr_2bytes( pdfs, nindx );

    nchars = 0;
    nleng  = 1;
    fseek( pdfs->file, 0, 2 );            // Go to end of file
    fpos = ftell( pdfs->file );           // Save current position
    pdf_wr_2bytes( pdfs, nleng );

    for ( j = 0; j < nstd; j++ )
    {
        ib = (size_t) *( findex[( hrshlst[j] - 1 ) / 100] + ( hrshlst[j] - 1 ) % 100 );
        if ( ib != 0 )
        {
            for (;; )
            {
                ix = *( buffer[ib / 100] + ib % 100 ) / 128 - 64;
                iy = *( buffer[ib / 100] + ib % 100 ) % 128 - 64;
                ib++;
                if ( ix == -64 )
                    ix = 64;
                if ( iy == -64 )
                    iy = 64;
                fputc( ix, pdfs->file );
                fputc( iy, pdfs->file );
                nleng++;
                if ( ix == 64 && iy == 64 )
                    break;
            }
            nchars++;
        }
    }
    nleng--;
    fseek( pdfs->file, fpos, 0 );
    pdf_wr_2bytes( pdfs, nleng );
    pdf_close( pdfs );
    free( hrshlst );
    free( hrshidx );
    printf( "There are %d characters in standard font set.\n", nchars - 1 );
    exit( 0 );
}