~hjd/ubuntu/wily/xmlgraphics-commons/debian-merged

« back to all changes in this revision

Viewing changes to src/java/org/apache/xmlgraphics/ps/PSFontUtils.java

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Fourmond
  • Date: 2011-02-11 14:15:14 UTC
  • mfrom: (8.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110211141514-h67achft6x31gju1
Tags: 1.4.dfsg-3
Uploading to unstable, hoping we won't break too many things ;-)...

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * limitations under the License.
16
16
 */
17
17
 
18
 
/* $Id: PSFontUtils.java 641399 2008-03-26 16:54:02Z jeremias $ */
 
18
/* $Id: PSFontUtils.java 924674 2010-03-18 09:41:26Z jeremias $ */
19
19
 
20
20
package org.apache.xmlgraphics.ps;
21
21
 
88
88
    /** the PSResource representing the WinAnsiEncoding. */
89
89
    public static final PSResource WINANSI_ENCODING_RESOURCE
90
90
            = new PSResource(PSResource.TYPE_ENCODING, "WinAnsiEncoding");
91
 
    
 
91
 
92
92
    /**
93
93
     * Defines the WinAnsi encoding for use in PostScript files.
94
94
     * @param gen the PostScript generator
120
120
        gen.getResourceTracker().registerSuppliedResource(WINANSI_ENCODING_RESOURCE);
121
121
    }
122
122
 
 
123
    /** the PSResource representing the AdobeStandardCyrillicEncoding. */
 
124
    public static final PSResource ADOBECYRILLIC_ENCODING_RESOURCE
 
125
            = new PSResource(PSResource.TYPE_ENCODING, "AdobeStandardCyrillicEncoding");
 
126
 
 
127
    /**
 
128
     * Defines the AdobeStandardCyrillic encoding for use in PostScript files.
 
129
     * @param gen the PostScript generator
 
130
     * @throws IOException In case of an I/O problem
 
131
     */
 
132
    public static void defineAdobeCyrillicEncoding(PSGenerator gen) throws IOException {
 
133
        gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, ADOBECYRILLIC_ENCODING_RESOURCE);
 
134
        gen.writeln("/AdobeStandardCyrillicEncoding [");
 
135
        for (int i = 0; i < Glyphs.ADOBECYRILLIC_ENCODING.length; i++) {
 
136
            if (i > 0) {
 
137
                if ((i % 5) == 0) {
 
138
                    gen.newLine();
 
139
                } else {
 
140
                    gen.write(" ");
 
141
                }
 
142
            }
 
143
            final char ch = Glyphs.ADOBECYRILLIC_ENCODING[i];
 
144
            final String glyphname = Glyphs.charToGlyphName(ch);
 
145
            if ("".equals(glyphname)) {
 
146
                gen.write("/" + Glyphs.NOTDEF);
 
147
            } else {
 
148
                gen.write("/");
 
149
                gen.write(glyphname);
 
150
            }
 
151
        }
 
152
        gen.newLine();
 
153
        gen.writeln("] def");
 
154
        gen.writeDSCComment(DSCConstants.END_RESOURCE);
 
155
        gen.getResourceTracker().registerSuppliedResource(ADOBECYRILLIC_ENCODING_RESOURCE);
 
156
    }
 
157
 
 
158
 
123
159
    /**
124
160
     * Redefines the encoding of a font.
125
161
     * @param gen the PostScript generator
127
163
     * @param encoding the new encoding (must be predefined in the PS file)
128
164
     * @throws IOException In case of an I/O problem
129
165
     */
130
 
    public static void redefineFontEncoding(PSGenerator gen, String fontName, String encoding) 
 
166
    public static void redefineFontEncoding(PSGenerator gen, String fontName, String encoding)
131
167
                throws IOException {
132
168
        gen.writeln("/" + fontName + " findfont");
133
169
        gen.writeln("dup length dict begin");