xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vhenneb...@apache.org
Subject svn commit: r959010 - in /xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src: java/org/apache/xmlgraphics/ps/ resources/org/apache/xmlgraphics/ps/
Date Tue, 29 Jun 2010 15:35:43 GMT
Author: vhennebert
Date: Tue Jun 29 15:35:42 2010
New Revision: 959010

URL: http://svn.apache.org/viewvc?rev=959010&view=rev
Log:
Added CMap and CIDFont resource types
Added possibility to embed Identity-H CMap into PostScript output

Added:
    xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/ps/
    xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/ps/Identity-H
Modified:
    xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
    xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSResource.java

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java?rev=959010&r1=959009&r2=959010&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
(original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
Tue Jun 29 15:35:42 2010
@@ -24,6 +24,7 @@ import java.awt.color.ColorSpace;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.text.DateFormat;
 import java.text.DecimalFormat;
@@ -59,6 +60,8 @@ public class PSGenerator implements PSCo
     /** Line feed used by PostScript */
     public static final char LF = '\n';
 
+    private static final String IDENTITY_H = "Identity-H";
+
     private OutputStream out;
     private int psLevel = DEFAULT_LANGUAGE_LEVEL;
     private boolean commentsEnabled = true;
@@ -73,6 +76,12 @@ public class PSGenerator implements PSCo
 
     private StringBuffer tempBuffer = new StringBuffer(256);
 
+    private boolean identityHEmbedded;
+
+    private PSResource procsetCIDInitResource;
+
+    private PSResource identityHCMapResource;
+
     /**
      * Creates a new instance.
      * @param out the OutputStream to write the generated PostScript code to
@@ -761,4 +770,66 @@ public class PSGenerator implements PSCo
         return getResourceTracker().isResourceSupplied(res);
     }
 
+    /**
+     * Embeds the Identity-H CMap file into the output stream, if that has not
+     * already been done.
+     *
+     * @return true if embedding has actually been performed, false otherwise
+     * (which means that a call to this method had already been made earlier)
+     * @throws IOException in case of an I/O problem
+     */
+    public boolean embedIdentityH() throws IOException {
+        if (identityHEmbedded) {
+            return false;
+        } else {
+            resTracker.registerNeededResource(getProcsetCIDInitResource());
+            writeDSCComment(DSCConstants.BEGIN_DOCUMENT, IDENTITY_H);
+            InputStream cmap = PSGenerator.class.getResourceAsStream(IDENTITY_H);
+            int b;
+            while ((b = cmap.read()) != -1) {
+                out.write(b);
+            }
+            cmap.close();
+            writeDSCComment(DSCConstants.END_DOCUMENT);
+            resTracker.registerSuppliedResource(getIdentityHCMapResource());
+            identityHEmbedded = true;
+            return true;
+        }
+    }
+
+    /**
+     * Returns the PSResource instance corresponding to the Identity-H CMap
+     * resource.
+     *
+     * @return the Identity-H CMap resource.
+     */
+    public PSResource getIdentityHCMapResource() {
+        if (identityHCMapResource == null) {
+            identityHCMapResource = new PSResource(PSResource.TYPE_CMAP, IDENTITY_H);
+        }
+        return identityHCMapResource;
+    }
+
+    /**
+     * Returns the PSResource instance corresponding to the CIDInit ProcSet
+     * resource.
+     *
+     * @return the <q>ProcSet CIDInit</q> resource
+     */
+    public PSResource getProcsetCIDInitResource() {
+        if (procsetCIDInitResource == null) {
+            procsetCIDInitResource = new PSResource(PSResource.TYPE_PROCSET, "CIDInit");
+        }
+        return procsetCIDInitResource;
+    }
+
+    /**
+     * Adds a PostScript DSC comment to the output stream requiring the
+     * inclusion of the CIDInit ProcSet resource.
+     *
+     * @throws IOException in case of an I/O problem
+     */
+    public void includeProcsetCIDInitResource() throws IOException {
+        writeDSCComment(DSCConstants.INCLUDE_RESOURCE, getProcsetCIDInitResource());
+    }
  }
\ No newline at end of file

Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSResource.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSResource.java?rev=959010&r1=959009&r2=959010&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSResource.java
(original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSResource.java
Tue Jun 29 15:35:42 2010
@@ -36,6 +36,10 @@ public class PSResource implements Compa
     public static final String TYPE_FORM = "form";
     /** a procset resource */
     public static final String TYPE_ENCODING = "encoding";
+    /** A CMap resource. */
+    public static final String TYPE_CMAP = "cmap";
+    /** A CIDFont resource. */
+    public static final String TYPE_CIDFONT = "cidfont";
 
     private String type;
     private String name;

Added: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/ps/Identity-H
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/ps/Identity-H?rev=959010&view=auto
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/ps/Identity-H
(added)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/ps/Identity-H
Tue Jun 29 15:35:42 2010
@@ -0,0 +1,339 @@
+%!PS-Adobe-3.0 Resource-CMap
+%%DocumentNeededResources: ProcSet (CIDInit)
+%%IncludeResource: ProcSet (CIDInit)
+%%BeginResource: CMap (Identity-H)
+%%Title: (Identity-H Adobe Identity 0)
+%%Version: 10.003
+%%Copyright: -----------------------------------------------------------
+%%Copyright: Copyright 1990-2009 Adobe Systems Incorporated.
+%%Copyright: All rights reserved.
+%%Copyright:
+%%Copyright: Redistribution and use in source and binary forms, with or
+%%Copyright: without modification, are permitted provided that the
+%%Copyright: following conditions are met:
+%%Copyright:
+%%Copyright: Redistributions of source code must retain the above
+%%Copyright: copyright notice, this list of conditions and the following
+%%Copyright: disclaimer.
+%%Copyright:
+%%Copyright: Redistributions in binary form must reproduce the above
+%%Copyright: copyright notice, this list of conditions and the following
+%%Copyright: disclaimer in the documentation and/or other materials
+%%Copyright: provided with the distribution. 
+%%Copyright:
+%%Copyright: Neither the name of Adobe Systems Incorporated nor the names
+%%Copyright: of its contributors may be used to endorse or promote
+%%Copyright: products derived from this software without specific prior
+%%Copyright: written permission. 
+%%Copyright:
+%%Copyright: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+%%Copyright: CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+%%Copyright: INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+%%Copyright: MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+%%Copyright: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+%%Copyright: CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+%%Copyright: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+%%Copyright: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+%%Copyright: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+%%Copyright: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+%%Copyright: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+%%Copyright: OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+%%Copyright: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+%%Copyright: -----------------------------------------------------------
+%%EndComments
+
+/CIDInit /ProcSet findresource begin
+
+12 dict begin
+
+begincmap
+
+/CIDSystemInfo 3 dict dup begin
+  /Registry (Adobe) def
+  /Ordering (Identity) def
+  /Supplement 0 def
+end def
+
+/CMapName /Identity-H def
+/CMapVersion 10.003 def
+/CMapType 1 def
+
+/XUID [1 10 25404 9999] def
+
+/WMode 0 def
+
+1 begincodespacerange
+  <0000> <FFFF>
+endcodespacerange
+
+100 begincidrange
+<0000> <00ff> 0
+<0100> <01ff> 256
+<0200> <02ff> 512
+<0300> <03ff> 768
+<0400> <04ff> 1024
+<0500> <05ff> 1280
+<0600> <06ff> 1536
+<0700> <07ff> 1792
+<0800> <08ff> 2048
+<0900> <09ff> 2304
+<0a00> <0aff> 2560
+<0b00> <0bff> 2816
+<0c00> <0cff> 3072
+<0d00> <0dff> 3328
+<0e00> <0eff> 3584
+<0f00> <0fff> 3840
+<1000> <10ff> 4096
+<1100> <11ff> 4352
+<1200> <12ff> 4608
+<1300> <13ff> 4864
+<1400> <14ff> 5120
+<1500> <15ff> 5376
+<1600> <16ff> 5632
+<1700> <17ff> 5888
+<1800> <18ff> 6144
+<1900> <19ff> 6400
+<1a00> <1aff> 6656
+<1b00> <1bff> 6912
+<1c00> <1cff> 7168
+<1d00> <1dff> 7424
+<1e00> <1eff> 7680
+<1f00> <1fff> 7936
+<2000> <20ff> 8192
+<2100> <21ff> 8448
+<2200> <22ff> 8704
+<2300> <23ff> 8960
+<2400> <24ff> 9216
+<2500> <25ff> 9472
+<2600> <26ff> 9728
+<2700> <27ff> 9984
+<2800> <28ff> 10240
+<2900> <29ff> 10496
+<2a00> <2aff> 10752
+<2b00> <2bff> 11008
+<2c00> <2cff> 11264
+<2d00> <2dff> 11520
+<2e00> <2eff> 11776
+<2f00> <2fff> 12032
+<3000> <30ff> 12288
+<3100> <31ff> 12544
+<3200> <32ff> 12800
+<3300> <33ff> 13056
+<3400> <34ff> 13312
+<3500> <35ff> 13568
+<3600> <36ff> 13824
+<3700> <37ff> 14080
+<3800> <38ff> 14336
+<3900> <39ff> 14592
+<3a00> <3aff> 14848
+<3b00> <3bff> 15104
+<3c00> <3cff> 15360
+<3d00> <3dff> 15616
+<3e00> <3eff> 15872
+<3f00> <3fff> 16128
+<4000> <40ff> 16384
+<4100> <41ff> 16640
+<4200> <42ff> 16896
+<4300> <43ff> 17152
+<4400> <44ff> 17408
+<4500> <45ff> 17664
+<4600> <46ff> 17920
+<4700> <47ff> 18176
+<4800> <48ff> 18432
+<4900> <49ff> 18688
+<4a00> <4aff> 18944
+<4b00> <4bff> 19200
+<4c00> <4cff> 19456
+<4d00> <4dff> 19712
+<4e00> <4eff> 19968
+<4f00> <4fff> 20224
+<5000> <50ff> 20480
+<5100> <51ff> 20736
+<5200> <52ff> 20992
+<5300> <53ff> 21248
+<5400> <54ff> 21504
+<5500> <55ff> 21760
+<5600> <56ff> 22016
+<5700> <57ff> 22272
+<5800> <58ff> 22528
+<5900> <59ff> 22784
+<5a00> <5aff> 23040
+<5b00> <5bff> 23296
+<5c00> <5cff> 23552
+<5d00> <5dff> 23808
+<5e00> <5eff> 24064
+<5f00> <5fff> 24320
+<6000> <60ff> 24576
+<6100> <61ff> 24832
+<6200> <62ff> 25088
+<6300> <63ff> 25344
+endcidrange
+
+100 begincidrange
+<6400> <64ff> 25600
+<6500> <65ff> 25856
+<6600> <66ff> 26112
+<6700> <67ff> 26368
+<6800> <68ff> 26624
+<6900> <69ff> 26880
+<6a00> <6aff> 27136
+<6b00> <6bff> 27392
+<6c00> <6cff> 27648
+<6d00> <6dff> 27904
+<6e00> <6eff> 28160
+<6f00> <6fff> 28416
+<7000> <70ff> 28672
+<7100> <71ff> 28928
+<7200> <72ff> 29184
+<7300> <73ff> 29440
+<7400> <74ff> 29696
+<7500> <75ff> 29952
+<7600> <76ff> 30208
+<7700> <77ff> 30464
+<7800> <78ff> 30720
+<7900> <79ff> 30976
+<7a00> <7aff> 31232
+<7b00> <7bff> 31488
+<7c00> <7cff> 31744
+<7d00> <7dff> 32000
+<7e00> <7eff> 32256
+<7f00> <7fff> 32512
+<8000> <80ff> 32768
+<8100> <81ff> 33024
+<8200> <82ff> 33280
+<8300> <83ff> 33536
+<8400> <84ff> 33792
+<8500> <85ff> 34048
+<8600> <86ff> 34304
+<8700> <87ff> 34560
+<8800> <88ff> 34816
+<8900> <89ff> 35072
+<8a00> <8aff> 35328
+<8b00> <8bff> 35584
+<8c00> <8cff> 35840
+<8d00> <8dff> 36096
+<8e00> <8eff> 36352
+<8f00> <8fff> 36608
+<9000> <90ff> 36864
+<9100> <91ff> 37120
+<9200> <92ff> 37376
+<9300> <93ff> 37632
+<9400> <94ff> 37888
+<9500> <95ff> 38144
+<9600> <96ff> 38400
+<9700> <97ff> 38656
+<9800> <98ff> 38912
+<9900> <99ff> 39168
+<9a00> <9aff> 39424
+<9b00> <9bff> 39680
+<9c00> <9cff> 39936
+<9d00> <9dff> 40192
+<9e00> <9eff> 40448
+<9f00> <9fff> 40704
+<a000> <a0ff> 40960
+<a100> <a1ff> 41216
+<a200> <a2ff> 41472
+<a300> <a3ff> 41728
+<a400> <a4ff> 41984
+<a500> <a5ff> 42240
+<a600> <a6ff> 42496
+<a700> <a7ff> 42752
+<a800> <a8ff> 43008
+<a900> <a9ff> 43264
+<aa00> <aaff> 43520
+<ab00> <abff> 43776
+<ac00> <acff> 44032
+<ad00> <adff> 44288
+<ae00> <aeff> 44544
+<af00> <afff> 44800
+<b000> <b0ff> 45056
+<b100> <b1ff> 45312
+<b200> <b2ff> 45568
+<b300> <b3ff> 45824
+<b400> <b4ff> 46080
+<b500> <b5ff> 46336
+<b600> <b6ff> 46592
+<b700> <b7ff> 46848
+<b800> <b8ff> 47104
+<b900> <b9ff> 47360
+<ba00> <baff> 47616
+<bb00> <bbff> 47872
+<bc00> <bcff> 48128
+<bd00> <bdff> 48384
+<be00> <beff> 48640
+<bf00> <bfff> 48896
+<c000> <c0ff> 49152
+<c100> <c1ff> 49408
+<c200> <c2ff> 49664
+<c300> <c3ff> 49920
+<c400> <c4ff> 50176
+<c500> <c5ff> 50432
+<c600> <c6ff> 50688
+<c700> <c7ff> 50944
+endcidrange
+
+56 begincidrange
+<c800> <c8ff> 51200
+<c900> <c9ff> 51456
+<ca00> <caff> 51712
+<cb00> <cbff> 51968
+<cc00> <ccff> 52224
+<cd00> <cdff> 52480
+<ce00> <ceff> 52736
+<cf00> <cfff> 52992
+<d000> <d0ff> 53248
+<d100> <d1ff> 53504
+<d200> <d2ff> 53760
+<d300> <d3ff> 54016
+<d400> <d4ff> 54272
+<d500> <d5ff> 54528
+<d600> <d6ff> 54784
+<d700> <d7ff> 55040
+<d800> <d8ff> 55296
+<d900> <d9ff> 55552
+<da00> <daff> 55808
+<db00> <dbff> 56064
+<dc00> <dcff> 56320
+<dd00> <ddff> 56576
+<de00> <deff> 56832
+<df00> <dfff> 57088
+<e000> <e0ff> 57344
+<e100> <e1ff> 57600
+<e200> <e2ff> 57856
+<e300> <e3ff> 58112
+<e400> <e4ff> 58368
+<e500> <e5ff> 58624
+<e600> <e6ff> 58880
+<e700> <e7ff> 59136
+<e800> <e8ff> 59392
+<e900> <e9ff> 59648
+<ea00> <eaff> 59904
+<eb00> <ebff> 60160
+<ec00> <ecff> 60416
+<ed00> <edff> 60672
+<ee00> <eeff> 60928
+<ef00> <efff> 61184
+<f000> <f0ff> 61440
+<f100> <f1ff> 61696
+<f200> <f2ff> 61952
+<f300> <f3ff> 62208
+<f400> <f4ff> 62464
+<f500> <f5ff> 62720
+<f600> <f6ff> 62976
+<f700> <f7ff> 63232
+<f800> <f8ff> 63488
+<f900> <f9ff> 63744
+<fa00> <faff> 64000
+<fb00> <fbff> 64256
+<fc00> <fcff> 64512
+<fd00> <fdff> 64768
+<fe00> <feff> 65024
+<ff00> <ffff> 65280
+endcidrange
+endcmap
+CMapName currentdict /CMap defineresource pop
+end
+end
+
+%%EndResource
+%%EOF



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message