File: xtndfont.c

package info (click to toggle)
plplot 5.15.0%2Bdfsg2-21
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 31,500 kB
  • sloc: ansic: 79,703; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 829; makefile: 75; lisp: 75; sed: 34; fortran: 6
file content (119 lines) | stat: -rw-r--r-- 2,976 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//	xtndfont.c
//
//      Utility to generate extended font set.
//

#include "plplotP.h"

extern short int *hersh[];
extern short int *findex[];
extern short int *buffer[];

int
main( void )
{
    size_t  j, k, ib;
    U_SHORT nchars, nleng, htab, nindx, zero;
    U_SHORT *hrshlst;
    int     ix, iy;
    long    fpos;
    PDFstrm *pdfs;

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

    ib = 0;
    for ( j = 0; j < 4; j++ )
        for ( k = 0; k < 176; k++ )
            hrshlst[ib++] = (U_SHORT) *( 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, 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 = (size_t) *( 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 = (size_t) *( 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 );

    free( hrshlst );

    printf( "There are %d characters in font set.\n", nchars - 1 );
    exit( 0 );
}