Debian Codegraph @

contrib/fonttools/rmligamarks.c

raw symbols SCIP
1 /* Copyright (C) 2003 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 /* This little program is designed to fix up a bug in versions of pfaedit */
29 /* before 15 June 2003. PfaEdit would set the ignore-combining-marks flag */
30 /* bit on all ligatures whether appropriate or not */
31 /* This program will unset that bit... whether inappropriate or not */
32
33 /* Takes a list of sfd filenames as arguments. Produces a set of files with */
34 /* -new added before the extension (Caslon.sfd -> Caslon-new.sfd) */
35 /* Will also read from stdin and write to stdout */
36
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40
41 static void ProcessFiles(FILE *in, FILE *out) {
42 char line[1000];
43 const char *match1 = "Ligature: 8", *match2 = "Ligature: 9";
44 int matchlen = strlen(match1);
45
46 while ( fgets(line,sizeof(line),in)!=NULL ) {
47 if ( strncmp(line,match1,matchlen)==0 )
48 line[matchlen-1] = '0';
49 else if ( strncmp(line,match2,matchlen)==0 )
50 line[matchlen-1] = '1';
51 fputs(line,out);
52 }
53 }
54
55 static void ProcessFilename(char *name) {
56 char buffer[1000];
57 FILE *in, *out;
58
59 strcpy(buffer,name);
60 if ( strlen(buffer)>4 && strcmp(buffer+strlen(buffer)-4,".sfd")==0 )
61 strcpy(buffer+strlen(buffer)-4,"-new.sfd");
62 else
63 strcat(buffer,"-new");
64 in = fopen(name,"r");
65 if ( in==NULL ) {
66 fprintf( stderr, "Could not open %s for reading\n", name );
67 exit(1);
68 }
69 out = fopen(buffer,"w");
70 if ( out==NULL ) {
71 fclose(in);
72 fprintf( stderr, "Could not open %s for writing\n", buffer );
73 exit(1);
74 }
75 ProcessFiles(in,out);
76 fclose(in);
77 fclose(out);
78 }
79
80 int main(int argc, char **argv) {
81 int i;
82
83 if ( argc==1 )
84 ProcessFiles(stdin,stdout);
85 else {
86 for ( i=1; i<argc; ++i )
87 ProcessFilename(argv[i]);
88 }
89 return( 0 );
90 }