|
1 #!/usr/bin/perl |
|
2 ############################################################################# |
|
3 ## |
|
4 ## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
5 ## All rights reserved. |
|
6 ## Contact: Nokia Corporation (qt-info@nokia.com) |
|
7 ## |
|
8 ## This file is part of the QtGui module of the Qt Toolkit. |
|
9 ## |
|
10 ## $QT_BEGIN_LICENSE:LGPL$ |
|
11 ## No Commercial Usage |
|
12 ## This file contains pre-release code and may not be distributed. |
|
13 ## You may use this file in accordance with the terms and conditions |
|
14 ## contained in the Technology Preview License Agreement accompanying |
|
15 ## this package. |
|
16 ## |
|
17 ## GNU Lesser General Public License Usage |
|
18 ## Alternatively, this file may be used under the terms of the GNU Lesser |
|
19 ## General Public License version 2.1 as published by the Free Software |
|
20 ## Foundation and appearing in the file LICENSE.LGPL included in the |
|
21 ## packaging of this file. Please review the following information to |
|
22 ## ensure the GNU Lesser General Public License version 2.1 requirements |
|
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
24 ## |
|
25 ## In addition, as a special exception, Nokia gives you certain additional |
|
26 ## rights. These rights are described in the Nokia Qt LGPL Exception |
|
27 ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
28 ## |
|
29 ## If you have questions regarding the use of this file, please contact |
|
30 ## Nokia at qt-info@nokia.com. |
|
31 ## |
|
32 ## |
|
33 ## |
|
34 ## |
|
35 ## |
|
36 ## |
|
37 ## |
|
38 ## |
|
39 ## $QT_END_LICENSE$ |
|
40 ## |
|
41 ############################################################################# |
|
42 |
|
43 open(INPUT, 'qpsprinter.ps') |
|
44 or die "Can't open qpsprinter.ps"; |
|
45 |
|
46 $dontcompress = 1; |
|
47 while(<INPUT>) { |
|
48 $line = $_; |
|
49 chomp $line; |
|
50 if ( /ENDUNCOMPRESS/ ) { |
|
51 $dontcompress = 0; |
|
52 } |
|
53 $line =~ s/%.*$//; |
|
54 $line = $line; |
|
55 if ( $dontcompress eq 1 ) { |
|
56 push(@uncompressed, $line); |
|
57 } else { |
|
58 push(@lines, $line); |
|
59 } |
|
60 # print "$line\n"; |
|
61 } |
|
62 |
|
63 $uc = join(" ", @uncompressed); |
|
64 $uc =~ s,\t+, ,g; |
|
65 $uc=~ s, +, ,g; |
|
66 |
|
67 $h = join(" ", @lines); |
|
68 $h =~ s,\t+, ,g; |
|
69 $h =~ s, +, ,g; |
|
70 $h = $h.' '; |
|
71 |
|
72 # now compress as much as possible |
|
73 $h =~ s/ bind def / BD /g; |
|
74 $h =~ s/ dup dup / d2 /g; |
|
75 $h =~ s/ exch def / ED /g; |
|
76 $h =~ s/ setfont / F /g; |
|
77 $h =~ s/ rlineto / RL /g; |
|
78 $h =~ s/ newpath / n /g; |
|
79 $h =~ s/ currentmatrix / CM /g; |
|
80 $h =~ s/ setmatrix / SM /g; |
|
81 $h =~ s/ translate / TR /g; |
|
82 $h =~ s/ setdash / SD /g; |
|
83 $h =~ s/ aload pop setrgbcolor / SC /g; |
|
84 $h =~ s/ currentfile read pop / CR /g; |
|
85 $h =~ s/ index / i /g; |
|
86 $h =~ s/ bitshift / bs /g; |
|
87 $h =~ s/ setcolorspace / scs /g; |
|
88 $h =~ s/ dict dup begin / DB /g; |
|
89 $h =~ s/ end def / DE /g; |
|
90 $h =~ s/ ifelse / ie /g; |
|
91 |
|
92 # PDF compatible naming |
|
93 $h =~ s/ setlinewidth / w /g; |
|
94 $h =~ s/ setdash / d /g; |
|
95 |
|
96 $h =~ s/ lineto / l /g; |
|
97 $h =~ s/ moveto / m /g; |
|
98 $h =~ s/ curveto / c /g; |
|
99 $h =~ s/ closepath / h /g; |
|
100 $h =~ s/ clip / W /g; |
|
101 $h =~ s/ eoclip / W* /g; |
|
102 |
|
103 $h =~ s/ gsave / gs /g; |
|
104 $h =~ s/ grestore / gr /g; |
|
105 |
|
106 # add the uncompressed part of the header before |
|
107 $h = $uc.' '.$h; |
|
108 |
|
109 |
|
110 |
|
111 #print $h; |
|
112 |
|
113 # wordwrap at col 76 |
|
114 @head = split(' ', $h); |
|
115 $line = shift @head; |
|
116 while( @head ) { |
|
117 $token = shift @head; |
|
118 chomp $token; |
|
119 # print "\nl=$l, len=$len, token=$token."; |
|
120 $newline = $line.' '.$token; |
|
121 $newline =~ s, /,/,g; |
|
122 $newline =~ s, \{,\{,g; |
|
123 $newline =~ s, \},\},g; |
|
124 $newline =~ s, \[,\[,g; |
|
125 $newline =~ s, \],\],g; |
|
126 $newline =~ s,\{ ,\{,g; |
|
127 $newline =~ s,\} ,\},g; |
|
128 $newline =~ s,\[ ,\[,g; |
|
129 $newline =~ s,\] ,\],g; |
|
130 if ( length( $newline ) > 76 ) { |
|
131 # print "\nline=$line\n"; |
|
132 $header = $header."\n\"".$line."\\n\""; |
|
133 $newline = $token; |
|
134 } |
|
135 $line = $newline; |
|
136 } |
|
137 $header = $header."\n\"".$line."\\n\""; |
|
138 |
|
139 |
|
140 print "static const char *const ps_header ="; |
|
141 print $header.";\n\n"; |
|
142 |
|
143 close(INPUT); |
|
144 exit; |
|
145 |
|
146 open(INPUT, 'qpsprinter.agl') |
|
147 or die "Can't open qpsprinter.ps"; |
|
148 |
|
149 print "static const char * const agl =\n"; |
|
150 |
|
151 $str = "\""; |
|
152 $string =""; |
|
153 $i = 0; |
|
154 while(<INPUT>) { |
|
155 $line = $_; |
|
156 chomp $line; |
|
157 $line =~ s/#.*//; |
|
158 if(length($line) ne 0) { |
|
159 $num = $line; |
|
160 $name = $line; |
|
161 $num =~ s/,.*//; |
|
162 $name =~ s/.*, \"//; |
|
163 $name =~ s/\".*//; |
|
164 push(@qchar, $num); |
|
165 push(@index, $i); |
|
166 if(length($str.$name) > 76) { |
|
167 $str = $str."\"\n"; |
|
168 $string = $string.$str; |
|
169 $str = "\""; |
|
170 } |
|
171 $str = $str.$name."\\0"; |
|
172 $i += length($name)+1; |
|
173 } |
|
174 } |
|
175 |
|
176 print $string.";\n\n"; |
|
177 |
|
178 print "static const struct { quint16 u; quint16 index; } unicodetoglyph[] = {\n "; |
|
179 |
|
180 $loop = 0; |
|
181 while( @qchar ) { |
|
182 $loop = $loop + 1; |
|
183 $ch = shift @qchar; |
|
184 $i = shift @index; |
|
185 print "{".$ch.", ".$i."}"; |
|
186 if($ch ne "0xFFFF") { |
|
187 print ", "; |
|
188 } |
|
189 if(!($loop % 4)) { |
|
190 print "\n "; |
|
191 } |
|
192 }; |
|
193 |
|
194 print "\n};\n\n"; |
|
195 |