2 #############################################################################
4 ## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ## All rights reserved.
6 ## Contact: Nokia Corporation (qt-info@nokia.com)
8 ## This file is part of the QtGui module of the Qt Toolkit.
10 ## $QT_BEGIN_LICENSE:LGPL$
11 ## GNU Lesser General Public License Usage
12 ## This file may be used under the terms of the GNU Lesser General Public
13 ## License version 2.1 as published by the Free Software Foundation and
14 ## appearing in the file LICENSE.LGPL included in the packaging of this
15 ## file. Please review the following information to ensure the GNU Lesser
16 ## General Public License version 2.1 requirements will be met:
17 ## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ## In addition, as a special exception, Nokia gives you certain additional
20 ## rights. These rights are described in the Nokia Qt LGPL Exception
21 ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
23 ## GNU General Public License Usage
24 ## Alternatively, this file may be used under the terms of the GNU General
25 ## Public License version 3.0 as published by the Free Software Foundation
26 ## and appearing in the file LICENSE.GPL included in the packaging of this
27 ## file. Please review the following information to ensure the GNU General
28 ## Public License version 3.0 requirements will be met:
29 ## http://www.gnu.org/copyleft/gpl.html.
32 ## Alternatively, this file may be used in accordance with the terms and
33 ## conditions contained in a signed written agreement between you and Nokia.
41 #############################################################################
43 open(INPUT, 'qpsprinter.ps')
44 or die "Can't open qpsprinter.ps";
50 if ( /ENDUNCOMPRESS/ ) {
55 if ( $dontcompress eq 1 ) {
56 push(@uncompressed, $line);
63 $uc = join(" ", @uncompressed);
67 $h = join(" ", @lines);
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;
92 # PDF compatible naming
93 $h =~ s/ setlinewidth / w /g;
94 $h =~ s/ setdash / d /g;
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;
103 $h =~ s/ gsave / gs /g;
104 $h =~ s/ grestore / gr /g;
106 # add the uncompressed part of the header before
114 @head = split(' ', $h);
117 $token = shift @head;
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\"";
137 $header = $header."\n\"".$line."\\n\"";
140 print "static const char *const ps_header =";
141 print $header.";\n\n";
146 open(INPUT, 'qpsprinter.agl')
147 or die "Can't open qpsprinter.ps";
149 print "static const char * const agl =\n";
158 if(length($line) ne 0) {
166 if(length($str.$name) > 76) {
168 $string = $string.$str;
171 $str = $str.$name."\\0";
172 $i += length($name)+1;
176 print $string.";\n\n";
178 print "static const struct { quint16 u; quint16 index; } unicodetoglyph[] = {\n ";
185 print "{".$ch.", ".$i."}";
186 if($ch ne "0xFFFF") {