~uhh-ssd/+junk/humidity_readout

« back to all changes in this revision

Viewing changes to plplot/plplot-5.9.9/fonts/xtndfont.c

  • Committer: Joachim Erfle
  • Date: 2013-07-24 13:53:41 UTC
  • Revision ID: joachim.erfle@desy.de-20130724135341-1qojpp701zsn009p
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// $Id: xtndfont.c 11289 2010-10-29 20:44:17Z airwin $
 
2
//
 
3
//      xtndfont.c
 
4
//
 
5
//      Utility to generate extended font set.
 
6
//
 
7
 
 
8
#include "plplotP.h"
 
9
 
 
10
extern short int *hersh[];
 
11
extern short int *findex[];
 
12
extern short int *buffer[];
 
13
 
 
14
int
 
15
main( void )
 
16
{
 
17
    short       j, k, ib, nindx, nchars, nleng, htab, zero;
 
18
    short       *hrshlst;
 
19
    signed char ix, iy;
 
20
    long        fpos;
 
21
    PDFstrm     *pdfs;
 
22
 
 
23
    hrshlst = (short *) malloc( 4 * 176 * sizeof ( short ) );
 
24
 
 
25
    ib = 0;
 
26
    for ( j = 0; j < 4; j++ )
 
27
        for ( k = 0; k < 176; k++ )
 
28
            hrshlst[ib++] = *( hersh[j] + k );
 
29
 
 
30
    pdfs = pdf_fopen( PL_XFONT, "wb+" );
 
31
    if ( !pdfs )
 
32
    {
 
33
        printf( "Error opening extended font file.\n" );
 
34
        exit( 1 );
 
35
    }
 
36
 
 
37
    htab = 4 * 256 + 176;
 
38
 
 
39
    pdf_wr_2bytes( pdfs, htab );
 
40
    pdf_wr_2nbytes( pdfs, (U_SHORT *) hrshlst, 4 * 176 );
 
41
 
 
42
    nleng = 1;
 
43
    zero  = 0;
 
44
    nindx = 0;
 
45
    fpos  = ftell( pdfs->file );
 
46
    pdf_wr_2bytes( pdfs, nindx );
 
47
    for ( j = 0; j < 30; j++ )
 
48
    {
 
49
        for ( k = 0; k < 100; k++ )
 
50
        {
 
51
            ib = *( findex[j] + k );
 
52
            if ( ib == 0 )
 
53
            {
 
54
                pdf_wr_2bytes( pdfs, zero );
 
55
                nindx++;
 
56
            }
 
57
            else
 
58
            {
 
59
                pdf_wr_2bytes( pdfs, nleng );
 
60
                nindx++;
 
61
                for (;; )
 
62
                {
 
63
                    ix = *( buffer[ib / 100] + ib % 100 ) / 128 - 64;
 
64
                    iy = *( buffer[ib / 100] + ib % 100 ) % 128 - 64;
 
65
                    ib++;
 
66
                    if ( ix == -64 )
 
67
                        ix = 64;
 
68
                    if ( iy == -64 )
 
69
                        iy = 64;
 
70
                    nleng++;
 
71
                    if ( ix == 64 && iy == 64 )
 
72
                        break;
 
73
                }
 
74
            }
 
75
        }
 
76
    }
 
77
    fseek( pdfs->file, fpos, 0 );
 
78
    pdf_wr_2bytes( pdfs, nindx );
 
79
 
 
80
    fseek( pdfs->file, 0, 2 );
 
81
    fpos   = ftell( pdfs->file );
 
82
    nleng  = 1;
 
83
    nchars = 0;
 
84
    pdf_wr_2bytes( pdfs, nleng );
 
85
    for ( j = 0; j < 30; j++ )
 
86
    {
 
87
        for ( k = 0; k < 100; k++ )
 
88
        {
 
89
            ib = *( findex[j] + k );
 
90
            if ( ib != 0 )
 
91
            {
 
92
                for (;; )
 
93
                {
 
94
                    ix = *( buffer[ib / 100] + ib % 100 ) / 128 - 64;
 
95
                    iy = *( buffer[ib / 100] + ib % 100 ) % 128 - 64;
 
96
                    ib++;
 
97
                    if ( ix == -64 )
 
98
                        ix = 64;
 
99
                    if ( iy == -64 )
 
100
                        iy = 64;
 
101
                    fputc( ix, pdfs->file );
 
102
                    fputc( iy, pdfs->file );
 
103
                    nleng++;
 
104
                    if ( ix == 64 && iy == 64 )
 
105
                        break;
 
106
                }
 
107
                nchars++;
 
108
            }
 
109
        }
 
110
    }
 
111
    nleng--;
 
112
    fseek( pdfs->file, fpos, 0 );
 
113
    pdf_wr_2bytes( pdfs, nleng );
 
114
    pdf_close( pdfs );
 
115
 
 
116
    printf( "There are %d characters in font set.\n", nchars - 1 );
 
117
    exit( 0 );
 
118
}