]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
adds support for type 1 fonts by Jeremias Maerki <jeremias.maerki@outline.ch>
authorfotis <fotis@unknown>
Thu, 2 Nov 2000 12:48:33 +0000 (12:48 +0000)
committerfotis <fotis@unknown>
Thu, 2 Nov 2000 12:48:33 +0000 (12:48 +0000)
based on work by Alain Fagot

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193740 13f79535-47bb-0310-9956-ffa450edef68

37 files changed:
build.xml
docs/xml-docs/fop.xml
docs/xml-docs/fop/fonts.xml [new file with mode: 0644]
docs/xml-docs/xml2xml.xsl
src/codegen/Courier-Bold.xml
src/codegen/Courier-BoldOblique.xml
src/codegen/Courier-Oblique.xml
src/codegen/Courier.xml
src/codegen/Helvetica-Bold.xml
src/codegen/Helvetica-BoldOblique.xml
src/codegen/Helvetica-Oblique.xml
src/codegen/Helvetica.xml
src/codegen/Symbol.xml
src/codegen/Times-Bold.xml
src/codegen/Times-BoldItalic.xml
src/codegen/Times-Italic.xml
src/codegen/Times-Roman.xml
src/codegen/ZapfDingbats.xml
src/codegen/charlist.xml
src/codegen/font-file.xsl
src/org/apache/fop/dom/NodeImpl.java
src/org/apache/fop/fonts/PFMFile.java [new file with mode: 0644]
src/org/apache/fop/fonts/PFMInputStream.java [new file with mode: 0644]
src/org/apache/fop/fonts/apps/FontPostProcess.xsl [new file with mode: 0644]
src/org/apache/fop/fonts/apps/FontPostProcessSort.xsl [new file with mode: 0644]
src/org/apache/fop/fonts/apps/PFMReader.java [new file with mode: 0644]
src/org/apache/fop/layout/FontDescriptor.java [new file with mode: 0644]
src/org/apache/fop/layout/FontMetric.java
src/org/apache/fop/pdf/PDFArray.java [new file with mode: 0644]
src/org/apache/fop/pdf/PDFDocument.java
src/org/apache/fop/pdf/PDFEncoding.java [new file with mode: 0644]
src/org/apache/fop/pdf/PDFFont.java
src/org/apache/fop/pdf/PDFFontDescriptor.java [new file with mode: 0644]
src/org/apache/fop/pdf/PDFFontNonBase14.java [new file with mode: 0644]
src/org/apache/fop/pdf/PDFFontType1.java [new file with mode: 0644]
src/org/apache/fop/pdf/PDFRectangle.java [new file with mode: 0644]
src/org/apache/fop/render/pdf/FontSetup.java

index 8d52fa12cbcfa8b7c57611db2f709c5318d0b1cf..82ae5904b04e4a5a5d45437d5380b0111c137ea0 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -171,6 +171,7 @@ Sometimes ant gives out this warnings, but the build is finished without any pro
     <property name="charlist.xml" value="${build.codegen}/charlist.xml"/>
     <property name="charlist.xsl" value="${build.codegen}/code-point-mapping.xsl"/>  
     <property name="fontfile.xsl" value="${build.codegen}/font-file.xsl"/>  
+    <property name="t1fontfile.xsl" value="${build.codegen}/t1font-file.xsl"/>
     <property name="Courier.xml" value="${build.codegen}/Courier.xml"/>  
     <property name="Courier-Oblique.xml" value="${build.codegen}/Courier-Oblique.xml"/>
     <property name="Courier-Bold.xml" value="${build.codegen}/Courier-Bold.xml"/>  
@@ -186,6 +187,11 @@ Sometimes ant gives out this warnings, but the build is finished without any pro
     <property name="ZapfDingbats.xml" value="${build.codegen}/ZapfDingbats.xml"/>
     <property name="Symbol.xml" value="${build.codegen}/Symbol.xml"/>
 
+    <!-- insert custom font information here (step 1 of 2) -->
+    <!-- use this as a template 
+    <property name="myfont.xml" value="${build.codegen}/myfont.xml"/>
+    -->
+
     <taskdef name="xslt" classname="Xslt"/>
     <available property="xt.present" classname="com.jclark.xsl.sax.XSLProcessor"/>
     <available property="jimi.present" classname="com.sun.jimi.core.Jimi"/>
@@ -306,6 +312,12 @@ Sometimes ant gives out this warnings, but the build is finished without any pro
     <xslt infile="${Symbol.xml}" xsltfile="${fontfile.xsl}"
         outfile="${build.src}/${replacestring}/render/pdf/fonts/Symbol.java" smart="yes"/>
 
+    <!-- custom fonts (Use t1fontfile.xsl instead of fontfile.xsl for Type 1 fonts!) step 2/2 -->
+    <!-- use this as a template 
+    <xslt infile="${myfont.xml}" xsltfile="${t1fontfile.xsl}"
+        outfile="${build.src}/${replacestring}/render/pdf/fonts/myfont.java" smart="yes"/>
+    -->
+
 
   </target>
 
index 4889db95498c61609fe05a99e482a97c6905da37..106fb285d9c2c8242a67382b84beb65bd339d185 100644 (file)
@@ -11,6 +11,7 @@
   <document id="limitations"    label="Limitations" source="fop/limitations.xml"    />
   <document id="bugs"           label="Bugs" source="fop/bugs.xml"    />
   <document id="examples"       label="Examples" source="fop/examples.xml"    />
+  <document id="fonts"       label="Fonts" source="fop/fonts.xml"    />
   <separator/>
   <document id="compiling"      label="Compiling" source="fop/compiling.xml"    />
   <document id="embedding"      label="Embedding" source="fop/embedding.xml"    />
diff --git a/docs/xml-docs/fop/fonts.xml b/docs/xml-docs/fop/fonts.xml
new file mode 100644 (file)
index 0000000..81a94ae
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" standalone="no"?>
+<!-- Font Support -->
+<!-- Author: jeremias.maerki@outline.ch -->
+<s1 title="Font Support ">
+       <s2 title="Status">
+               <p>FOP (building PDF files) normally supports only the base 14 font package defined in the Adobe PDF specification.
+               That includes the following fonts: Helvetica, Times, Courier, Symbol and ZapfDingbats.
+               </p>
+               <p>Font support in FOP can be extended by the addition of font metric files (written in XML) created from Adobe
+               Type 1 fonts. No other font types (TrueType, Type 0, Type 3, etc.) are supported at this time. The current method
+               of adding fonts to FOP requires the package to be recompiled.
+               </p>
+       </s2>
+       <s2 title="Adding additional Type 1 fonts">
+               <p>As mentioned above you need an XML file containing font metrics to be able to use an additional font. FOP
+               contains a tool that can generate such a font metrics file from a PFM file.
+               </p>
+               <s3 title="Generating a font metrics file">
+                       <p>     Run the class org.apache.fop.fonts.apps.PFMReader to generate the XML file. Important: The tool does two
+                       XSL transformations, one of which uses charlist.xml. At the moment in order for the tool to work correctly you
+                       have to copy charlist.xml temporarily to the local directory from where you intend to start the tool.
+                       (If anyone has an improvement on this...)
+                       </p>
+                       <p>
+                               <code>java -cp fop.jar;xerces.jar;xalan.jar;w3c.jar</code>
+                       </p>
+                       <p>
+                               <code>org.apache.fop.fonts.apps.PFMReader pfm-file xml-file</code>
+                       </p>
+                       <p>Put the resulting XML file into the src/codegen directory.
+                       </p>
+                       <p>Note: The tool will construct some values (FontBBox, StemV and ItalicAngle) based on assumptions and
+                       calculations which are only an approximation to the real values. FontBBox and Italic Angle can be found in
+                       the human-readable part of the PFB file. The PFMReader tool does not yet interpret PFB files, so if you want
+                       to be correct, you may have to adjust the values in the XML file manually. The constructed values however
+                       appear to have no visible influence.
+                       </p>
+               </s3>
+               <s3 title="Register the fonts within FOP">
+                       <p>Open the class org.apache.fop.render.pdf.FontSetup and add entries to the ones present according to
+                       the following example:
+                       </p>
+                       <p>
+                               <code>fontInfo.addMetrics("F14", new ZapfDingbats());</code>
+                       </p>
+                       <p>
+                               <code>fontInfo.addMetrics("F15", new BauerBodoniRoman()); //This is the new entry.</code>
+                       </p>
+                       <p>
+                               <code>...</code>
+                       </p>
+                       <p>
+                               <code>fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", "normal");</code>
+                       </p>
+                       <p>
+                               <code>fontInfo.addFontProperties("F15", "BauerBodoni", "normal", "normal"); //This is the new entry.</code>
+                       </p>
+                       <p>Note: The class name to use is visible in the &lt;class-name&gt; element of the font metrics file.
+                       </p>
+               </s3>
+               <s3 title="Adjusting build.xml">
+                       <p>In the src/codegen directory you find the font metrics files for the base 14 fonts. The are being transformed
+                       during build into Java classes and then compiled. The newly generated font metrics file must be included in this 
+                       process. To do that open build.xml and add entries according to the following example:
+                       </p>
+                       <p>
+                               <code>&lt;property name="ZapfDingbats.xml" value="${build.codegen}/ZapfDingbats.xml"/&gt;</code>
+                       </p>
+                       <p>
+                               <code>&lt;property name="BauerBodoni.xml" value="${build.codegen}/BauerBodoni.xml"/&gt;</code>
+                       </p>
+                       <p>
+                               <code>...</code>
+                       </p>
+                       <p>
+                               <code>&lt;xslt infile="${ZapfDingbats.xml}" xsltfile="${fontfile.xsl}"</code>
+                       </p>
+                       <p>
+                               <code>outfile="${build.src}/${replacestring}/render/pdf/fonts/ZapfDingbats.java" smart="yes"/&gt;</code>
+                       </p>
+                       <p>
+                               <code>&lt;xslt infile="${BauerBodoni.xml}" xsltfile="${t1fontfile.xsl}"</code>
+                       </p>
+                       <p>
+                               <code>outfile="${build.src}/${replacestring}/render/pdf/fonts/BauerBodoniRoman.java" smart="yes"/&gt;</code>
+                       </p>
+                       <p>Rebuild FOP!
+                       </p>
+                       <p>Note: Be sure to use ${t1fontfile.xsl} instead of ${fontfile.xsl}. This is neccessary because of the additional metrics
+                       information needed for non base 14 fonts.
+                       </p>
+               </s3>
+       </s2>
+</s1>
index 69333c99ae2c810b64a4c600efa0151f5074f35c..4f14ba59a0bfac6eb296b8fc937d0c6257af6809 100644 (file)
@@ -9,6 +9,7 @@
     <xsl:copy-of select="document('fop/running.xml')"/>
     <xsl:copy-of select="document('fop/implemented.xml')"/>
     <xsl:copy-of select="document('fop/limitations.xml')"/>
+    <xsl:copy-of select="document('fop/fonts.xml')"/>
     <xsl:copy-of select="document('fop/bugs.xml')"/>
     <xsl:copy-of select="document('fop/examples.xml')"/>
     <xsl:copy-of select="document('fop/compiling.xml')"/>
index a2ded8d5363e0717a668d7e6a0cde265f27848d7..53c0a6f20aa4c8f2c559313c8ebaf59e31914661 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>439</x-height>
    <ascender>626</ascender>
    <descender>-142</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="600"/>
       <char name="AE" width="600"/>
index 58a419ec5ae3b0ad06d09c793c77d10fdb55cf8e..5dac9ae2fd48a9a9cdd3b3ee0f03c0a95d32f0a6 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>439</x-height>
    <ascender>626</ascender>
    <descender>-142</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="600"/>
       <char name="AE" width="600"/>
index f43986004058da98a267356bd86a8e232a77a809..701ec85340990349869fc5be83cef5b75e4c8505 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>426</x-height>
    <ascender>629</ascender>
    <descender>-157</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="600"/>
       <char name="AE" width="600"/>
index 80f1bfc6ec95655201b97be65d76291ad84abc3a..8ec2e8492bb8eb2ed087db3bac4b15df4359207a 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>426</x-height>
    <ascender>629</ascender>
    <descender>-157</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="600"/>
       <char name="AE" width="600"/>
index 6c9b6f4b9fd859a4555f23beeaf899e408fe66bd..ca39a70a2623ba718a62709d39c6b4dc77a5bbf6 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>532</x-height>
    <ascender>718</ascender>
    <descender>-207</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="722"/>
       <char name="AE" width="1000"/>
index d07b5de49dc0976dcce9fee2eaa68e15c6b0b489..e2da39782e2089fbb2605dc0ce55c6ab80864e32 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>532</x-height>
    <ascender>718</ascender>
    <descender>-207</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="722"/>
       <char name="AE" width="1000"/>
index 00339df1de77b8ed4abfde649636d1f71593d72b..f002086e61f36ebd73e2cc23d4590dec47870e1a 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>523</x-height>
    <ascender>718</ascender>
    <descender>-207</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="667"/>
       <char name="AE" width="1000"/>
index b5221bfb9770a18318b4aa781f1fc6c9eba62d42..36f8b0b65340b7feb877d1e2b166852cffc7309d 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>523</x-height>
    <ascender>718</ascender>
    <descender>-207</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="667"/>
       <char name="AE" width="1000"/>
index 6e071fe81ae9d1a62ff17b23dd61c5d440a20fa4..cfd3f2061ee50148956f5129c8a61c485268be5e 100644 (file)
@@ -6,6 +6,8 @@
   <x-height>520</x-height>
   <ascender>1010</ascender>
   <descender>-293</descender>
+  <first-char>32</first-char>
+  <last-char>255</last-char>
   <widths>
     <char name="space" width="250"/>
     <char name="exclam" width="333"/>
index f446d298d2f15800709c57f7819d9147f7ed581c..aad20a1039d4a8f04861c7149ed25d6b92218a5b 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>461</x-height>
    <ascender>676</ascender>
    <descender>-205</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="722"/>
       <char name="AE" width="1000"/>
index b79b831792943477e509c2d7a095cf9681068e1b..ea63d3a8df250640c3c43c9666e25721fa5aaeec 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>462</x-height>
    <ascender>699</ascender>
    <descender>-205</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="667"/>
       <char name="AE" width="944"/>
index 5b0242e5ed05bfa70dc6a3ec9c37d47ea77a8c21..83ab113300adb959b2727e4c184cccbc9024461b 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>441</x-height>
    <ascender>683</ascender>
    <descender>-205</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="611"/>
       <char name="AE" width="889"/>
index ae5c16151504736a813c6af4080fcd970194a746..0dee39bbcfc4fa036617785b7c962729cc6b4b55 100644 (file)
@@ -7,6 +7,8 @@
    <x-height>450</x-height>
    <ascender>683</ascender>
    <descender>-217</descender>
+   <first-char>32</first-char>
+   <last-char>255</last-char>
    <widths>
       <char name="A" width="722"/>
       <char name="AE" width="889"/>
index 7a86c635b58726bd4af943c53f703d8e80d6c740..4e051193757a8c4534c95c8aafcb0f4c5277067d 100644 (file)
@@ -6,6 +6,8 @@
   <x-height>426</x-height>
   <ascender>820</ascender>
   <descender>-143</descender>
+  <first-char>32</first-char>
+  <last-char>255</last-char>
   <widths>
     <char name="space" width="278"/>
     <char name="a1" width="974"/>
index 15700eb6eabd697999e98fbde92288146e92e766..8f923d144860015e2ce05a19cdbc2f73afdc2d25 100644 (file)
    <map adobe-name="Edieresis" win-ansi="0x00CB" unicode="0x00CB"/>
    <map adobe-name="Egrave" win-ansi="0x00C8" unicode="0x00C8"/>
    <map adobe-name="Eth" win-ansi="0x00D0" unicode="0x00D0"/>
+   <map adobe-name="Euro" win-ansi="0x0080" unicode="0x20AC"/>
    <map adobe-name="F" win-ansi="0x0046" unicode="0x0046"/>
    <map adobe-name="G" win-ansi="0x0047" unicode="0x0047"/>
-   <map adobe-name="Gcaron" win-ansi="-1" unicode="0x01E6"/> 
+   <map adobe-name="Gcaron" win-ansi="-1" unicode="0x01E6"/>
    <map adobe-name="H" win-ansi="0x0048" unicode="0x0048"/>
    <map adobe-name="I" win-ansi="0x0049" unicode="0x0049"/>
    <map adobe-name="Iacute" win-ansi="0x00CD" unicode="0x00CD"/>
    <map adobe-name="agrave" win-ansi="0x00E0" unicode="0x00E0"/>
    <map adobe-name="ampersand" win-ansi="0x0026" unicode="0x0026"/>
    <map adobe-name="aring" win-ansi="0x00E5" unicode="0x00E5"/>
-<!--  fj  <map adobe-name="arrowboth" win-ansi="-1" unicode="0x2195"/>-->
-<!--  fj     <map adobe-name="arrowdown" win-ansi="-1" unicode="0x2193"/>-->
-<!--  fj     <map adobe-name="arrowleft" win-ansi="-1" unicode="0x2194"/>-->
-<!--  fj     <map adobe-name="arrowright" win-ansi="-1" unicode="0x2192"/>-->
-<!--  fj     <map adobe-name="arrowup" win-ansi="-1" unicode="0x2191"/>-->
+   <!--  fj  <map adobe-name="arrowboth" win-ansi="-1" unicode="0x2195"/>-->
+   <!--  fj     <map adobe-name="arrowdown" win-ansi="-1" unicode="0x2193"/>-->
+   <!--  fj     <map adobe-name="arrowleft" win-ansi="-1" unicode="0x2194"/>-->
+   <!--  fj     <map adobe-name="arrowright" win-ansi="-1" unicode="0x2192"/>-->
+   <!--  fj     <map adobe-name="arrowup" win-ansi="-1" unicode="0x2191"/>-->
    <map adobe-name="asciicircum" win-ansi="0x005E" unicode="0x005E"/>
    <map adobe-name="asciitilde" win-ansi="0x007E" unicode="0x007E"/>
    <map adobe-name="asterisk" win-ansi="0x002A" unicode="0x002A"/>
    <map adobe-name="fl" win-ansi="-1" unicode="-1"/>
    <map adobe-name="florin" win-ansi="0x0083" unicode="0x0083"/>
    <map adobe-name="four" win-ansi="0x0034" unicode="0x0034"/>
-<!-- fj   <map adobe-name="fraction" win-ansi="-1" unicode="0x2044"/> -->
+   <!-- fj   <map adobe-name="fraction" win-ansi="-1" unicode="0x2044"/> -->
    <map adobe-name="g" win-ansi="0x0067" unicode="0x0067"/>
    <map adobe-name="gcaron" win-ansi="-1" unicode="0x01E7"/>
    <map adobe-name="germandbls" win-ansi="0x00DF" unicode="0x00DF"/>
    <map adobe-name="k" win-ansi="0x006B" unicode="0x006B"/>
    <map adobe-name="l" win-ansi="0x006C" unicode="0x006C"/>
    <map adobe-name="less" win-ansi="0x003C" unicode="0x003C"/>
-   <map adobe-name="lira" win-ansi="-1" unicode="0x20A4"/> 
+   <map adobe-name="lira" win-ansi="-1" unicode="0x20A4"/>
    <map adobe-name="logicalnot" win-ansi="0x00AC" unicode="0x00AC"/>
    <map adobe-name="lslash" win-ansi="-1" unicode="0x0142"/>
    <map adobe-name="m" win-ansi="0x006D" unicode="0x006D"/>
    <map adobe-name="macron" win-ansi="0x00AF" unicode="0x00AF"/>
-<!-- fj <map adobe-name="minus" win-ansi="-1" unicode="0x2212"/>-->
+   <!-- fj <map adobe-name="minus" win-ansi="-1" unicode="0x2212"/>-->
    <map adobe-name="mu" win-ansi="0x00B5" unicode="0x00B5"/>
    <map adobe-name="multiply" win-ansi="0x00D7" unicode="0x00D7"/>
    <map adobe-name="n" win-ansi="0x006E" unicode="0x006E"/>
-<!-- JKT: the following is not actually an adobe named character -->
+   <!-- JKT: the following is not actually an adobe named character -->
    <map adobe-name="nbsp" win-ansi="0x00A0" unicode="0x00A0"/>
    <map adobe-name="nine" win-ansi="0x0039" unicode="0x0039"/>
    <map adobe-name="ntilde" win-ansi="0x00F1" unicode="0x00F1"/>
    <map adobe-name="z" win-ansi="0x007A" unicode="0x007A"/>
    <map adobe-name="zcaron" win-ansi="-1" unicode="0x017E"/>
    <map adobe-name="zero" win-ansi="0x0030" unicode="0x0030"/>
-
-
    <!-- the following mappings are used for the font zapfdingbats -->
-
    <map adobe-name="a1" win-ansi="0x0021" unicode="0x2701" unicodeName="UPPER BLADE SCISSORS"/>
    <map adobe-name="a2" win-ansi="0x0022" unicode="0x2702" unicodeName="BLACK SCISSORS"/>
    <map adobe-name="a202" win-ansi="0x0023" unicode="0x2703" unicodeName="LOWER BLADE SCISSORS"/>
    <map adobe-name="a189" win-ansi="0x00FC" unicode="0x27BC" unicodeName="WEDGE-TAILED RIGHTWARDS ARROW"/>
    <map adobe-name="a190" win-ansi="0x00FD" unicode="0x27BD" unicodeName="HEAVY WEDGE-TAILED RIGHTWARDS ARROW"/>
    <map adobe-name="a191" win-ansi="0x00FE" unicode="0x27BE" unicodeName="OPEN-OUTLINED RIGHTWARDS ARROW"/>
-
    <!-- the following mappings are used for the Symbol font 
-     TBD: remove doublettes  -->
-  <map adobe-name="universal" win-ansi="0x22" unicode="0x2200"/>
-  <map adobe-name="numbersign" win-ansi="0x23" unicode="0x0023"/>
-  <map adobe-name="existential" win-ansi="0x24" unicode="0x2203"/>
-  <map adobe-name="percent" win-ansi="0x25" unicode="0x0025"/>
-  <map adobe-name="ampersand" win-ansi="0x26" unicode="0x0026"/>
-  <map adobe-name="suchthat" win-ansi="0x27" unicode="0x220B"/>
-  <map adobe-name="parenleft" win-ansi="0x28" unicode="0x0028"/>
-  <map adobe-name="parenright" win-ansi="0x29" unicode="0x0029"/>
-  <map adobe-name="asteriskmath" win-ansi="0x2A" unicode="0x2217"/>
-  <map adobe-name="plus" win-ansi="0x2B" unicode="0x002B"/>
-  <map adobe-name="comma" win-ansi="0x2C" unicode="0x002C"/>
-  <map adobe-name="minus" win-ansi="0x2D" unicode="0x2212"/>
-  <map adobe-name="period" win-ansi="0x2E" unicode="0x002E"/>
-  <map adobe-name="slash" win-ansi="0x2F" unicode="0x002F"/>
-  <map adobe-name="colon" win-ansi="0x3A" unicode="0x003A"/>
-  <map adobe-name="semicolon" win-ansi="0x3B" unicode="0x003B"/>
-  <map adobe-name="less" win-ansi="0x3C" unicode="0x003C"/>
-  <map adobe-name="equal" win-ansi="0x3D" unicode="0x003D"/>
-  <map adobe-name="greater" win-ansi="0x3E" unicode="0x003E"/>
-  <map adobe-name="question" win-ansi="0x3F" unicode="0x003F"/>
-  <map adobe-name="congruent" win-ansi="0x40" unicode="0x2245"/>
-  <map adobe-name="Alpha" win-ansi="0x41" unicode="0x0391"/>
-  <map adobe-name="Beta" win-ansi="0x42" unicode="0x0392"/>
-  <map adobe-name="Chi" win-ansi="0x43" unicode="0x03A7"/>
-  <map adobe-name="Delta" win-ansi="0x44" unicode="0x2206"/>
-  <map adobe-name="Epsilon" win-ansi="0x45" unicode="0x0395"/>
-  <map adobe-name="Phi" win-ansi="0x46" unicode="0x03A6"/>
-  <map adobe-name="Gamma" win-ansi="0x47" unicode="0x0393"/>
-  <map adobe-name="Eta" win-ansi="0x48" unicode="0x0397"/>
-  <map adobe-name="Iota" win-ansi="0x49" unicode="0x0399"/>
-  <map adobe-name="theta1" win-ansi="0x4A" unicode="0x03D1"/>
-  <map adobe-name="Kappa" win-ansi="0x4B" unicode="0x039A"/>
-  <map adobe-name="Lambda" win-ansi="0x4C" unicode="0x039B"/>
-  <map adobe-name="Mu" win-ansi="0x4D" unicode="0x039C"/>
-  <map adobe-name="Nu" win-ansi="0x4E" unicode="0x039D"/>
-  <map adobe-name="Omicron" win-ansi="0x4F" unicode="0x039F"/>
-  <map adobe-name="Pi" win-ansi="0x50" unicode="0x03A0"/>
-  <map adobe-name="Theta" win-ansi="0x51" unicode="0x0398"/>
-  <map adobe-name="Rho" win-ansi="0x52" unicode="0x03A1"/>
-  <map adobe-name="Sigma" win-ansi="0x53" unicode="0x03A3"/>
-  <map adobe-name="Tau" win-ansi="0x54" unicode="0x03A4"/>
-  <map adobe-name="Upsilon" win-ansi="0x55" unicode="0x03A5"/>
-  <map adobe-name="sigma1" win-ansi="0x56" unicode="0x03C2"/>
-  <map adobe-name="Omega" win-ansi="0x57" unicode="0x2126"/>
-  <map adobe-name="Xi" win-ansi="0x58" unicode="0x039E"/>
-  <map adobe-name="Psi" win-ansi="0x59" unicode="0x03A8"/>
-  <map adobe-name="Zeta" win-ansi="0x5A" unicode="0x0396"/>
-  <map adobe-name="bracketleft" win-ansi="0x5B" unicode="0x005B"/>
-  <map adobe-name="therefore" win-ansi="0x5C" unicode="0x2234"/>
-  <map adobe-name="bracketright" win-ansi="0x5D" unicode="0x005D"/>
-  <map adobe-name="perpendicular" win-ansi="0x5E" unicode="0x22A5"/>
-  <map adobe-name="underscore" win-ansi="0x5F" unicode="0x005F"/>
-  <map adobe-name="radicalex" win-ansi="0x60" unicode="0xF8E5"/>
-  <map adobe-name="alpha" win-ansi="0x61" unicode="0x03B1"/>
-  <map adobe-name="beta" win-ansi="0x62" unicode="0x03B2"/>
-  <map adobe-name="chi" win-ansi="0x63" unicode="0x03C7"/>
-  <map adobe-name="delta" win-ansi="0x64" unicode="0x03B4"/>
-  <map adobe-name="epsilon" win-ansi="0x65" unicode="0x03B5"/>
-  <map adobe-name="phi" win-ansi="0x66" unicode="0x03C6"/>
-  <map adobe-name="gamma" win-ansi="0x67" unicode="0x03B3"/>
-  <map adobe-name="eta" win-ansi="0x68" unicode="0x03B7"/>
-  <map adobe-name="iota" win-ansi="0x69" unicode="0x03B9"/>
-  <map adobe-name="phi1" win-ansi="0x6A" unicode="0x03D5"/>
-  <map adobe-name="kappa" win-ansi="0x6B" unicode="0x03BA"/>
-  <map adobe-name="lambda" win-ansi="0x6C" unicode="0x03BB"/>
-  <map adobe-name="mu" win-ansi="0x6D" unicode="0x00B5"/>
-  <map adobe-name="nu" win-ansi="0x6E" unicode="0x03BD"/>
-  <map adobe-name="omicron" win-ansi="0x6F" unicode="0x03BF"/>
-  <map adobe-name="pi" win-ansi="0x70" unicode="0x03C0"/>
-  <map adobe-name="theta" win-ansi="0x71" unicode="0x03B8"/>
-  <map adobe-name="rho" win-ansi="0x72" unicode="0x03C1"/>
-  <map adobe-name="sigma" win-ansi="0x73" unicode="0x03C3"/>
-  <map adobe-name="tau" win-ansi="0x74" unicode="0x03C4"/>
-  <map adobe-name="upsilon" win-ansi="0x75" unicode="0x03C5"/>
-  <map adobe-name="omega1" win-ansi="0x76" unicode="0x03D6"/>
-  <map adobe-name="omega" win-ansi="0x77" unicode="0x03C9"/>
-  <map adobe-name="xi" win-ansi="0x78" unicode="0x03BE"/>
-  <map adobe-name="psi" win-ansi="0x79" unicode="0x03C8"/>
-  <map adobe-name="zeta" win-ansi="0x7A" unicode="0x03B6"/>
-  <map adobe-name="braceleft" win-ansi="0x7B" unicode="0x007B"/>
-  <map adobe-name="bar" win-ansi="0x7C" unicode="0x007C"/>
-  <map adobe-name="braceright" win-ansi="0x7D" unicode="0x007D"/>
-  <map adobe-name="similar" win-ansi="0x7E" unicode="0x223C"/>
-  <map adobe-name="Upsilon1" win-ansi="0xA1" unicode="0x03D2"/>
-  <map adobe-name="minute" win-ansi="0xA2" unicode="0x2032"/>
-  <map adobe-name="lessequal" win-ansi="0xA3" unicode="0x2264"/>
-  <map adobe-name="fraction" win-ansi="0xA4" unicode="0x2044"/>
-  <map adobe-name="infinity" win-ansi="0xA5" unicode="0x221E"/>
-  <map adobe-name="florin" win-ansi="0xA6" unicode="0x0192"/>
-  <map adobe-name="club" win-ansi="0xA7" unicode="0x2663"/>
-  <map adobe-name="diamond" win-ansi="0xA8" unicode="0x2666"/>
-  <map adobe-name="heart" win-ansi="0xA9" unicode="0x2665"/>
-  <map adobe-name="spade" win-ansi="0xAA" unicode="0x2660"/>
-  <map adobe-name="arrowboth" win-ansi="0xAB" unicode="0x2194"/>
-  <map adobe-name="arrowleft" win-ansi="0xAC" unicode="0x2190"/>
-  <map adobe-name="arrowup" win-ansi="0xAD" unicode="0x2191"/>
-  <map adobe-name="arrowright" win-ansi="0xAE" unicode="0x2192"/>
-  <map adobe-name="arrowdown" win-ansi="0xAF" unicode="0x2193"/>
-  <map adobe-name="degree" win-ansi="0xB0" unicode="0x00B0"/>
-  <map adobe-name="plusminus" win-ansi="0xB1" unicode="0x00B1"/>
-  <map adobe-name="second" win-ansi="0xB2" unicode="0x2033"/>
-  <map adobe-name="greaterequal" win-ansi="0xB3" unicode="0x2265"/>
-  <map adobe-name="multiply" win-ansi="0xB4" unicode="0x00D7"/>
-  <map adobe-name="proportional" win-ansi="0xB5" unicode="0x221D"/>
-  <map adobe-name="partialdiff" win-ansi="0xB6" unicode="0x2202"/>
-  <map adobe-name="bullet" win-ansi="0xB7" unicode="0x2022"/>
-  <map adobe-name="divide" win-ansi="0xB8" unicode="0x00F7"/>
-  <map adobe-name="notequal" win-ansi="0xB9" unicode="0x2260"/>
-  <map adobe-name="equivalence" win-ansi="0xBA" unicode="0x2261"/>
-  <map adobe-name="approxequal" win-ansi="0xBB" unicode="0x2248"/>
-  <map adobe-name="ellipsis" win-ansi="0xBC" unicode="0x2026"/>
-  <map adobe-name="arrowvertex" win-ansi="0xBD" unicode="0xF8E6"/>
-  <map adobe-name="arrowhorizex" win-ansi="0xBE" unicode="0xF8E7"/>
-  <map adobe-name="carriagereturn" win-ansi="0xBF" unicode="0x21B5"/>
-  <map adobe-name="aleph" win-ansi="0xC0" unicode="0x2135"/>
-  <map adobe-name="Ifraktur" win-ansi="0xC1" unicode="0x2111"/>
-  <map adobe-name="Rfraktur" win-ansi="0xC2" unicode="0x211C"/>
-  <map adobe-name="weierstrass" win-ansi="0xC3" unicode="0x2118"/>
-  <map adobe-name="circlemultiply" win-ansi="0xC4" unicode="0x2297"/>
-  <map adobe-name="circleplus" win-ansi="0xC5" unicode="0x2295"/>
-  <map adobe-name="emptyset" win-ansi="0xC6" unicode="0x2205"/>
-  <map adobe-name="intersection" win-ansi="0xC7" unicode="0x2229"/>
-  <map adobe-name="union" win-ansi="0xC8" unicode="0x222A"/>
-  <map adobe-name="propersuperset" win-ansi="0xC9" unicode="0x2283"/>
-  <map adobe-name="reflexsuperset" win-ansi="0xCA" unicode="0x2287"/>
-  <map adobe-name="notsubset" win-ansi="0xCB" unicode="0x2284"/>
-  <map adobe-name="propersubset" win-ansi="0xCC" unicode="0x2282"/>
-  <map adobe-name="reflexsubset" win-ansi="0xCD" unicode="0x2286"/>
-  <map adobe-name="element" win-ansi="0xCE" unicode="0x2208"/>
-  <map adobe-name="notelement" win-ansi="0xCF" unicode="0x2209"/>
-  <map adobe-name="angle" win-ansi="0xD0" unicode="0x2220"/>
-  <map adobe-name="gradient" win-ansi="0xD1" unicode="0x2207"/>
-  <map adobe-name="registerserif" win-ansi="0xD2" unicode="0xF6DA"/>
-  <map adobe-name="copyrightserif" win-ansi="0xD3" unicode="0xF6D9"/>
-  <map adobe-name="trademarkserif" win-ansi="0xD4" unicode="0xF6DB"/>
-  <map adobe-name="product" win-ansi="0xD5" unicode="0x220F"/>
-  <map adobe-name="radical" win-ansi="0xD6" unicode="0x221A"/>
-  <map adobe-name="dotmath" win-ansi="0xD7" unicode="0x22C5"/>
-  <map adobe-name="logicalnot" win-ansi="0xD8" unicode="0x00AC"/>
-  <map adobe-name="logicaland" win-ansi="0xD9" unicode="0x2227"/>
-  <map adobe-name="logicalor" win-ansi="0xDA" unicode="0x2228"/>
-  <map adobe-name="arrowdblboth" win-ansi="0xDB" unicode="0x21D4"/>
-  <map adobe-name="arrowdblleft" win-ansi="0xDC" unicode="0x21D0"/>
-  <map adobe-name="arrowdblup" win-ansi="0xDD" unicode="0x21D1"/>
-  <map adobe-name="arrowdblright" win-ansi="0xDE" unicode="0x21D2"/>
-  <map adobe-name="arrowdbldown" win-ansi="0xDF" unicode="0x21D3"/>
-  <map adobe-name="lozenge" win-ansi="0xE0" unicode="0x25CA"/>
-  <map adobe-name="angleleft" win-ansi="0xE1" unicode="0x2329"/>
-  <map adobe-name="registersans" win-ansi="0xE2" unicode="0xF8E8"/>
-  <map adobe-name="copyrightsans" win-ansi="0xE3" unicode="0xF8E9"/>
-  <map adobe-name="trademarksans" win-ansi="0xE4" unicode="0xF8EA"/>
-  <map adobe-name="summation" win-ansi="0xE5" unicode="0x2211"/>
-  <map adobe-name="parenlefttp" win-ansi="0xE6" unicode="0xF8EB"/>
-  <map adobe-name="parenleftex" win-ansi="0xE7" unicode="0xF8EC"/>
-  <map adobe-name="parenleftbt" win-ansi="0xE8" unicode="0xF8ED"/>
-  <map adobe-name="bracketlefttp" win-ansi="0xE9" unicode="0xF8EE"/>
-  <map adobe-name="bracketleftex" win-ansi="0xEA" unicode="0xF8EF"/>
-  <map adobe-name="bracketleftbt" win-ansi="0xEB" unicode="0xF8F0"/>
-  <map adobe-name="bracelefttp" win-ansi="0xEC" unicode="0xF8F1"/>
-  <map adobe-name="braceleftmid" win-ansi="0xED" unicode="0xF8F2"/>
-  <map adobe-name="braceleftbt" win-ansi="0xEE" unicode="0xF8F3"/>
-  <map adobe-name="braceex" win-ansi="0xEF" unicode="0xF8F4"/>
-  <map adobe-name="angleright" win-ansi="0xF1" unicode="0x232A"/>
-  <map adobe-name="integral" win-ansi="0xF2" unicode="0x222B"/>
-  <map adobe-name="integraltp" win-ansi="0xF3" unicode="0x2320"/>
-  <map adobe-name="integralex" win-ansi="0xF4" unicode="0xF8F5"/>
-  <map adobe-name="integralbt" win-ansi="0xF5" unicode="0x2321"/>
-  <map adobe-name="parenrighttp" win-ansi="0xF6" unicode="0xF8F6"/>
-  <map adobe-name="parenrightex" win-ansi="0xF7" unicode="0xF8F7"/>
-  <map adobe-name="parenrightbt" win-ansi="0xF8" unicode="0xF8F8"/>
-  <map adobe-name="bracketrighttp" win-ansi="0xF9" unicode="0xF8F9"/>
-  <map adobe-name="bracketrightex" win-ansi="0xFA" unicode="0xF8FA"/>
-  <map adobe-name="bracketrightbt" win-ansi="0xFB" unicode="0xF8FB"/>
-  <map adobe-name="bracerighttp" win-ansi="0xFC" unicode="0xF8FC"/>
-  <map adobe-name="bracerightmid" win-ansi="0xFD" unicode="0xF8FD"/>
-  <map adobe-name="bracerightbt" win-ansi="0xFE" unicode="0xF8FE"/>
-  <map adobe-name="apple" win-ansi="-1" unicode="0xF8FE"/>
-
+    TBD: remove doublettes  -->
+   <map adobe-name="universal" win-ansi="0x22" unicode="0x2200"/>
+   <map adobe-name="numbersign" win-ansi="0x23" unicode="0x0023"/>
+   <map adobe-name="existential" win-ansi="0x24" unicode="0x2203"/>
+   <map adobe-name="percent" win-ansi="0x25" unicode="0x0025"/>
+   <map adobe-name="ampersand" win-ansi="0x26" unicode="0x0026"/>
+   <map adobe-name="suchthat" win-ansi="0x27" unicode="0x220B"/>
+   <map adobe-name="parenleft" win-ansi="0x28" unicode="0x0028"/>
+   <map adobe-name="parenright" win-ansi="0x29" unicode="0x0029"/>
+   <map adobe-name="asteriskmath" win-ansi="0x2A" unicode="0x2217"/>
+   <map adobe-name="plus" win-ansi="0x2B" unicode="0x002B"/>
+   <map adobe-name="comma" win-ansi="0x2C" unicode="0x002C"/>
+   <map adobe-name="minus" win-ansi="0x2D" unicode="0x2212"/>
+   <map adobe-name="period" win-ansi="0x2E" unicode="0x002E"/>
+   <map adobe-name="slash" win-ansi="0x2F" unicode="0x002F"/>
+   <map adobe-name="colon" win-ansi="0x3A" unicode="0x003A"/>
+   <map adobe-name="semicolon" win-ansi="0x3B" unicode="0x003B"/>
+   <map adobe-name="less" win-ansi="0x3C" unicode="0x003C"/>
+   <map adobe-name="equal" win-ansi="0x3D" unicode="0x003D"/>
+   <map adobe-name="greater" win-ansi="0x3E" unicode="0x003E"/>
+   <map adobe-name="question" win-ansi="0x3F" unicode="0x003F"/>
+   <map adobe-name="congruent" win-ansi="0x40" unicode="0x2245"/>
+   <map adobe-name="Alpha" win-ansi="0x41" unicode="0x0391"/>
+   <map adobe-name="Beta" win-ansi="0x42" unicode="0x0392"/>
+   <map adobe-name="Chi" win-ansi="0x43" unicode="0x03A7"/>
+   <map adobe-name="Delta" win-ansi="0x44" unicode="0x2206"/>
+   <map adobe-name="Epsilon" win-ansi="0x45" unicode="0x0395"/>
+   <map adobe-name="Phi" win-ansi="0x46" unicode="0x03A6"/>
+   <map adobe-name="Gamma" win-ansi="0x47" unicode="0x0393"/>
+   <map adobe-name="Eta" win-ansi="0x48" unicode="0x0397"/>
+   <map adobe-name="Iota" win-ansi="0x49" unicode="0x0399"/>
+   <map adobe-name="theta1" win-ansi="0x4A" unicode="0x03D1"/>
+   <map adobe-name="Kappa" win-ansi="0x4B" unicode="0x039A"/>
+   <map adobe-name="Lambda" win-ansi="0x4C" unicode="0x039B"/>
+   <map adobe-name="Mu" win-ansi="0x4D" unicode="0x039C"/>
+   <map adobe-name="Nu" win-ansi="0x4E" unicode="0x039D"/>
+   <map adobe-name="Omicron" win-ansi="0x4F" unicode="0x039F"/>
+   <map adobe-name="Pi" win-ansi="0x50" unicode="0x03A0"/>
+   <map adobe-name="Theta" win-ansi="0x51" unicode="0x0398"/>
+   <map adobe-name="Rho" win-ansi="0x52" unicode="0x03A1"/>
+   <map adobe-name="Sigma" win-ansi="0x53" unicode="0x03A3"/>
+   <map adobe-name="Tau" win-ansi="0x54" unicode="0x03A4"/>
+   <map adobe-name="Upsilon" win-ansi="0x55" unicode="0x03A5"/>
+   <map adobe-name="sigma1" win-ansi="0x56" unicode="0x03C2"/>
+   <map adobe-name="Omega" win-ansi="0x57" unicode="0x2126"/>
+   <map adobe-name="Xi" win-ansi="0x58" unicode="0x039E"/>
+   <map adobe-name="Psi" win-ansi="0x59" unicode="0x03A8"/>
+   <map adobe-name="Zeta" win-ansi="0x5A" unicode="0x0396"/>
+   <map adobe-name="bracketleft" win-ansi="0x5B" unicode="0x005B"/>
+   <map adobe-name="therefore" win-ansi="0x5C" unicode="0x2234"/>
+   <map adobe-name="bracketright" win-ansi="0x5D" unicode="0x005D"/>
+   <map adobe-name="perpendicular" win-ansi="0x5E" unicode="0x22A5"/>
+   <map adobe-name="underscore" win-ansi="0x5F" unicode="0x005F"/>
+   <map adobe-name="radicalex" win-ansi="0x60" unicode="0xF8E5"/>
+   <map adobe-name="alpha" win-ansi="0x61" unicode="0x03B1"/>
+   <map adobe-name="beta" win-ansi="0x62" unicode="0x03B2"/>
+   <map adobe-name="chi" win-ansi="0x63" unicode="0x03C7"/>
+   <map adobe-name="delta" win-ansi="0x64" unicode="0x03B4"/>
+   <map adobe-name="epsilon" win-ansi="0x65" unicode="0x03B5"/>
+   <map adobe-name="phi" win-ansi="0x66" unicode="0x03C6"/>
+   <map adobe-name="gamma" win-ansi="0x67" unicode="0x03B3"/>
+   <map adobe-name="eta" win-ansi="0x68" unicode="0x03B7"/>
+   <map adobe-name="iota" win-ansi="0x69" unicode="0x03B9"/>
+   <map adobe-name="phi1" win-ansi="0x6A" unicode="0x03D5"/>
+   <map adobe-name="kappa" win-ansi="0x6B" unicode="0x03BA"/>
+   <map adobe-name="lambda" win-ansi="0x6C" unicode="0x03BB"/>
+   <map adobe-name="mu" win-ansi="0x6D" unicode="0x00B5"/>
+   <map adobe-name="nu" win-ansi="0x6E" unicode="0x03BD"/>
+   <map adobe-name="omicron" win-ansi="0x6F" unicode="0x03BF"/>
+   <map adobe-name="pi" win-ansi="0x70" unicode="0x03C0"/>
+   <map adobe-name="theta" win-ansi="0x71" unicode="0x03B8"/>
+   <map adobe-name="rho" win-ansi="0x72" unicode="0x03C1"/>
+   <map adobe-name="sigma" win-ansi="0x73" unicode="0x03C3"/>
+   <map adobe-name="tau" win-ansi="0x74" unicode="0x03C4"/>
+   <map adobe-name="upsilon" win-ansi="0x75" unicode="0x03C5"/>
+   <map adobe-name="omega1" win-ansi="0x76" unicode="0x03D6"/>
+   <map adobe-name="omega" win-ansi="0x77" unicode="0x03C9"/>
+   <map adobe-name="xi" win-ansi="0x78" unicode="0x03BE"/>
+   <map adobe-name="psi" win-ansi="0x79" unicode="0x03C8"/>
+   <map adobe-name="zeta" win-ansi="0x7A" unicode="0x03B6"/>
+   <map adobe-name="braceleft" win-ansi="0x7B" unicode="0x007B"/>
+   <map adobe-name="bar" win-ansi="0x7C" unicode="0x007C"/>
+   <map adobe-name="braceright" win-ansi="0x7D" unicode="0x007D"/>
+   <map adobe-name="similar" win-ansi="0x7E" unicode="0x223C"/>
+   <map adobe-name="Upsilon1" win-ansi="0xA1" unicode="0x03D2"/>
+   <map adobe-name="minute" win-ansi="0xA2" unicode="0x2032"/>
+   <map adobe-name="lessequal" win-ansi="0xA3" unicode="0x2264"/>
+   <map adobe-name="fraction" win-ansi="0xA4" unicode="0x2044"/>
+   <map adobe-name="infinity" win-ansi="0xA5" unicode="0x221E"/>
+   <map adobe-name="florin" win-ansi="0xA6" unicode="0x0192"/>
+   <map adobe-name="club" win-ansi="0xA7" unicode="0x2663"/>
+   <map adobe-name="diamond" win-ansi="0xA8" unicode="0x2666"/>
+   <map adobe-name="heart" win-ansi="0xA9" unicode="0x2665"/>
+   <map adobe-name="spade" win-ansi="0xAA" unicode="0x2660"/>
+   <map adobe-name="arrowboth" win-ansi="0xAB" unicode="0x2194"/>
+   <map adobe-name="arrowleft" win-ansi="0xAC" unicode="0x2190"/>
+   <map adobe-name="arrowup" win-ansi="0xAD" unicode="0x2191"/>
+   <map adobe-name="arrowright" win-ansi="0xAE" unicode="0x2192"/>
+   <map adobe-name="arrowdown" win-ansi="0xAF" unicode="0x2193"/>
+   <map adobe-name="degree" win-ansi="0xB0" unicode="0x00B0"/>
+   <map adobe-name="plusminus" win-ansi="0xB1" unicode="0x00B1"/>
+   <map adobe-name="second" win-ansi="0xB2" unicode="0x2033"/>
+   <map adobe-name="greaterequal" win-ansi="0xB3" unicode="0x2265"/>
+   <map adobe-name="multiply" win-ansi="0xB4" unicode="0x00D7"/>
+   <map adobe-name="proportional" win-ansi="0xB5" unicode="0x221D"/>
+   <map adobe-name="partialdiff" win-ansi="0xB6" unicode="0x2202"/>
+   <map adobe-name="bullet" win-ansi="0xB7" unicode="0x2022"/>
+   <map adobe-name="divide" win-ansi="0xB8" unicode="0x00F7"/>
+   <map adobe-name="notequal" win-ansi="0xB9" unicode="0x2260"/>
+   <map adobe-name="equivalence" win-ansi="0xBA" unicode="0x2261"/>
+   <map adobe-name="approxequal" win-ansi="0xBB" unicode="0x2248"/>
+   <map adobe-name="ellipsis" win-ansi="0xBC" unicode="0x2026"/>
+   <map adobe-name="arrowvertex" win-ansi="0xBD" unicode="0xF8E6"/>
+   <map adobe-name="arrowhorizex" win-ansi="0xBE" unicode="0xF8E7"/>
+   <map adobe-name="carriagereturn" win-ansi="0xBF" unicode="0x21B5"/>
+   <map adobe-name="aleph" win-ansi="0xC0" unicode="0x2135"/>
+   <map adobe-name="Ifraktur" win-ansi="0xC1" unicode="0x2111"/>
+   <map adobe-name="Rfraktur" win-ansi="0xC2" unicode="0x211C"/>
+   <map adobe-name="weierstrass" win-ansi="0xC3" unicode="0x2118"/>
+   <map adobe-name="circlemultiply" win-ansi="0xC4" unicode="0x2297"/>
+   <map adobe-name="circleplus" win-ansi="0xC5" unicode="0x2295"/>
+   <map adobe-name="emptyset" win-ansi="0xC6" unicode="0x2205"/>
+   <map adobe-name="intersection" win-ansi="0xC7" unicode="0x2229"/>
+   <map adobe-name="union" win-ansi="0xC8" unicode="0x222A"/>
+   <map adobe-name="propersuperset" win-ansi="0xC9" unicode="0x2283"/>
+   <map adobe-name="reflexsuperset" win-ansi="0xCA" unicode="0x2287"/>
+   <map adobe-name="notsubset" win-ansi="0xCB" unicode="0x2284"/>
+   <map adobe-name="propersubset" win-ansi="0xCC" unicode="0x2282"/>
+   <map adobe-name="reflexsubset" win-ansi="0xCD" unicode="0x2286"/>
+   <map adobe-name="element" win-ansi="0xCE" unicode="0x2208"/>
+   <map adobe-name="notelement" win-ansi="0xCF" unicode="0x2209"/>
+   <map adobe-name="angle" win-ansi="0xD0" unicode="0x2220"/>
+   <map adobe-name="gradient" win-ansi="0xD1" unicode="0x2207"/>
+   <map adobe-name="registerserif" win-ansi="0xD2" unicode="0xF6DA"/>
+   <map adobe-name="copyrightserif" win-ansi="0xD3" unicode="0xF6D9"/>
+   <map adobe-name="trademarkserif" win-ansi="0xD4" unicode="0xF6DB"/>
+   <map adobe-name="product" win-ansi="0xD5" unicode="0x220F"/>
+   <map adobe-name="radical" win-ansi="0xD6" unicode="0x221A"/>
+   <map adobe-name="dotmath" win-ansi="0xD7" unicode="0x22C5"/>
+   <map adobe-name="logicalnot" win-ansi="0xD8" unicode="0x00AC"/>
+   <map adobe-name="logicaland" win-ansi="0xD9" unicode="0x2227"/>
+   <map adobe-name="logicalor" win-ansi="0xDA" unicode="0x2228"/>
+   <map adobe-name="arrowdblboth" win-ansi="0xDB" unicode="0x21D4"/>
+   <map adobe-name="arrowdblleft" win-ansi="0xDC" unicode="0x21D0"/>
+   <map adobe-name="arrowdblup" win-ansi="0xDD" unicode="0x21D1"/>
+   <map adobe-name="arrowdblright" win-ansi="0xDE" unicode="0x21D2"/>
+   <map adobe-name="arrowdbldown" win-ansi="0xDF" unicode="0x21D3"/>
+   <map adobe-name="lozenge" win-ansi="0xE0" unicode="0x25CA"/>
+   <map adobe-name="angleleft" win-ansi="0xE1" unicode="0x2329"/>
+   <map adobe-name="registersans" win-ansi="0xE2" unicode="0xF8E8"/>
+   <map adobe-name="copyrightsans" win-ansi="0xE3" unicode="0xF8E9"/>
+   <map adobe-name="trademarksans" win-ansi="0xE4" unicode="0xF8EA"/>
+   <map adobe-name="summation" win-ansi="0xE5" unicode="0x2211"/>
+   <map adobe-name="parenlefttp" win-ansi="0xE6" unicode="0xF8EB"/>
+   <map adobe-name="parenleftex" win-ansi="0xE7" unicode="0xF8EC"/>
+   <map adobe-name="parenleftbt" win-ansi="0xE8" unicode="0xF8ED"/>
+   <map adobe-name="bracketlefttp" win-ansi="0xE9" unicode="0xF8EE"/>
+   <map adobe-name="bracketleftex" win-ansi="0xEA" unicode="0xF8EF"/>
+   <map adobe-name="bracketleftbt" win-ansi="0xEB" unicode="0xF8F0"/>
+   <map adobe-name="bracelefttp" win-ansi="0xEC" unicode="0xF8F1"/>
+   <map adobe-name="braceleftmid" win-ansi="0xED" unicode="0xF8F2"/>
+   <map adobe-name="braceleftbt" win-ansi="0xEE" unicode="0xF8F3"/>
+   <map adobe-name="braceex" win-ansi="0xEF" unicode="0xF8F4"/>
+   <map adobe-name="angleright" win-ansi="0xF1" unicode="0x232A"/>
+   <map adobe-name="integral" win-ansi="0xF2" unicode="0x222B"/>
+   <map adobe-name="integraltp" win-ansi="0xF3" unicode="0x2320"/>
+   <map adobe-name="integralex" win-ansi="0xF4" unicode="0xF8F5"/>
+   <map adobe-name="integralbt" win-ansi="0xF5" unicode="0x2321"/>
+   <map adobe-name="parenrighttp" win-ansi="0xF6" unicode="0xF8F6"/>
+   <map adobe-name="parenrightex" win-ansi="0xF7" unicode="0xF8F7"/>
+   <map adobe-name="parenrightbt" win-ansi="0xF8" unicode="0xF8F8"/>
+   <map adobe-name="bracketrighttp" win-ansi="0xF9" unicode="0xF8F9"/>
+   <map adobe-name="bracketrightex" win-ansi="0xFA" unicode="0xF8FA"/>
+   <map adobe-name="bracketrightbt" win-ansi="0xFB" unicode="0xF8FB"/>
+   <map adobe-name="bracerighttp" win-ansi="0xFC" unicode="0xF8FC"/>
+   <map adobe-name="bracerightmid" win-ansi="0xFD" unicode="0xF8FD"/>
+   <map adobe-name="bracerightbt" win-ansi="0xFE" unicode="0xF8FE"/>
+   <map adobe-name="apple" win-ansi="-1" unicode="0xF8FE"/>
 </font-mappings>
-
 <!--  I couldn't find the following characters in the unicode tables -->
-
 <!--
    <map adobe-name="center" win-ansi="-1" unicode=""/> 
    <map adobe-name="dectab" win-ansi="-1" unicode=""/> 
    <map adobe-name="up" win-ansi="-1" unicode=""/>
    <map adobe-name="zer" win-ansi="-1" unicode=""/>
 
--->
\ No newline at end of file
+-->
index 1ae88770895579f86c341db2e61f4f2b8b775140..3c2f5ee8f52200872ea4c59423aabf082c2f4001 100644 (file)
@@ -28,6 +28,8 @@ public class <xsl:value-of select="class-name"/> extends Font {
     private final static int xHeight = <xsl:value-of select="x-height"/>;
     private final static int ascender = <xsl:value-of select="ascender"/>;
     private final static int descender = <xsl:value-of select="descender"/>;
+    private final static int firstChar = <xsl:value-of select="first-char"/>;
+    private final static int lastChar = <xsl:value-of select="last-char"/>;
     private final static int[] width;
 
     static {
@@ -60,9 +62,23 @@ public class <xsl:value-of select="class-name"/> extends Font {
         return xHeight;
     }
 
+    public int getFirstChar() {
+        return firstChar;
+    }
+
+    public int getLastChar() {
+        return lastChar;
+    }
+
     public int width(int i) {
         return width[i];
     }
+
+    public int[] getWidths() {
+        int[] arr = new int[getLastChar()-getFirstChar()+1];
+        System.arraycopy(width, getFirstChar(), arr, 0, getLastChar()-getFirstChar()+1);
+        return arr;
+    }
 }
 <!--</redirect:write>-->
 </xsl:template>
index 86c6bd246bb0d7f55ccd0847b8b6ab3a24e10b04..7a2c263d64d9d255670f0336f0a2379347efb19f 100644 (file)
@@ -191,6 +191,13 @@ public class NodeImpl implements Node {
                return false;
        }
 
+    public boolean isSupported(String feature,
+                                 String version)
+       {
+               return false;
+       }
+
+
     public String getNamespaceURI()
        {
                return "";
diff --git a/src/org/apache/fop/fonts/PFMFile.java b/src/org/apache/fop/fonts/PFMFile.java
new file mode 100644 (file)
index 0000000..8ab72de
--- /dev/null
@@ -0,0 +1,381 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.fonts;
+
+import java.io.*;
+
+/**
+ * This class represents a PFM file (or parts of it) as a Java object.
+ *
+ * @author  jeremias.maerki@outline.ch
+ */
+public class PFMFile {
+
+    //Header stuff
+    private String  windowsName;
+    private String  postscriptName;
+    private short   dfItalic;
+    private int     dfWeight;
+    private short   dfCharSet;
+    private short   dfPitchAndFamily;
+    private int     dfAvgWidth;
+    private int     dfMaxWidth;
+    private int     dfMinWidth;
+    private short   dfFirstChar;
+    private short   dfLastChar;
+
+    //Extension stuff
+    //---
+
+    //Extend Text Metrics
+    private int     etmCapHeight;
+    private int     etmXHeight;
+    private int     etmLowerCaseAscent;
+    private int     etmLowerCaseDescent;
+
+    //Extent table
+    private int[]   extentTable;
+
+    public PFMFile() {
+    }
+
+    /**
+     * Parses a PFM file
+     * 
+     * @param     inStream The stream from which to read the PFM file.
+     */
+    public void load(InputStream inStream) throws IOException {
+        InputStream bufin = new BufferedInputStream(inStream, 1024);
+        bufin.mark(1024);
+        PFMInputStream in = new PFMInputStream(bufin);
+        int version = in.readShort();
+        long filesize = in.readInt();
+        bufin.reset();
+
+        byte[] buf = new byte[(int)filesize];
+        bufin.read(buf, 0, (int)filesize);
+
+        bufin = new ByteArrayInputStream(buf);
+        in = new PFMInputStream(bufin);
+        loadHeader(in);
+        loadExtension(in);
+    }
+
+    /**
+     * Parses the header of the PFM file.
+     *
+     * @param     inStream The stream from which to read the PFM file.
+     */
+    private void loadHeader(PFMInputStream inStream) throws IOException {
+        inStream.skip(80);
+        dfItalic = inStream.readByte();
+        inStream.skip(2);
+        dfWeight = inStream.readShort();
+        dfCharSet = inStream.readByte();
+        inStream.skip(4);
+        dfPitchAndFamily = inStream.readByte();
+        dfAvgWidth = inStream.readShort();
+        dfMaxWidth = inStream.readShort();
+        dfFirstChar = inStream.readByte();
+        dfLastChar  = inStream.readByte();
+        inStream.skip(8);
+        long faceOffset   = inStream.readInt();
+
+        inStream.reset();
+        inStream.skip(faceOffset);
+        windowsName = inStream.readString();
+
+        inStream.reset();
+        inStream.skip(117);
+    }
+
+    /**
+     * Parses the extension part of the PFM file.
+     * 
+     * @param     inStream The stream from which to read the PFM file.
+     */
+    private void loadExtension(PFMInputStream inStream) throws IOException {
+        int size = inStream.readShort();
+        long extMetricsOffset = inStream.readInt();
+        long extentTableOffset = inStream.readInt();
+        inStream.skip(12);
+        long driverInfoOffset = inStream.readInt();
+        inStream.reset();
+        inStream.skip(driverInfoOffset);
+        postscriptName = inStream.readString();
+
+        if (extMetricsOffset != 0) {
+            inStream.reset();
+            inStream.skip(extMetricsOffset);
+            loadExtMetrics(inStream);
+        }
+        if (extentTableOffset != 0) {
+            inStream.reset();
+            inStream.skip(extentTableOffset);
+            loadExtentTable(inStream);
+        }
+
+    }
+
+    /**
+     * Parses the extended metrics part of the PFM file.
+     * 
+     * @param     inStream The stream from which to read the PFM file.
+     */
+    private void loadExtMetrics(PFMInputStream inStream) throws IOException {
+        int size = inStream.readShort();
+        inStream.skip(12);
+        etmCapHeight        = inStream.readShort();
+        etmXHeight          = inStream.readShort();
+        etmLowerCaseAscent  = inStream.readShort();
+        etmLowerCaseDescent = inStream.readShort();
+    }
+
+    /**
+     * Parses the extent table of the PFM file.
+     * 
+     * @param     inStream The stream from which to read the PFM file.
+     */
+    private void loadExtentTable(PFMInputStream inStream) throws IOException {
+        extentTable = new int[dfLastChar-dfFirstChar];
+        dfMinWidth = dfMaxWidth;
+        for (short i = dfFirstChar; i < dfLastChar; i++) {
+            extentTable[i-dfFirstChar] = inStream.readShort();
+            if (extentTable[i-dfFirstChar] < dfMinWidth) {
+                dfMinWidth = extentTable[i-dfFirstChar];
+            }
+        }
+    }
+
+    /**
+     * Returns the Windows name of the font.
+     * 
+     * @return The Windows name.
+     */
+    public String getWindowsName() {
+        return windowsName;
+    }
+
+    /**
+     * Returns the Postscript name of the font.
+     * 
+     * @return The Postscript name.
+     */
+    public String getPostscriptName() {
+        return postscriptName;
+    }
+
+    /**
+     * Returns the charset used for the font.
+     * 
+     * @return The charset (0=WinAnsi).
+     */
+    public short getCharSet() {
+        return dfCharSet;
+    }
+
+    /**
+     * Returns the charset of the font as a string.
+     * 
+     * @return The name of the charset.
+     */
+    public String getCharSetName() {
+        switch (dfCharSet) {
+            case 0:     return "WinAnsi";
+            case 128:   return "Shift-JIS (Japanese)";
+            default:    return "Unknown";
+        }
+    }
+
+    /**
+     * Returns the number of the character that defines
+     * the first entry in the widths list.
+     * 
+     * @return The number of the first character.
+     */
+    public short getFirstChar() {
+        return dfFirstChar;
+    }
+
+    /**
+     * Returns the number of the character that defines
+     * the last entry in the widths list.
+     * 
+     * @return The number of the last character.
+     */
+    public short getLastChar() {
+        return dfLastChar;
+    }
+
+    /**
+     * Returns the CapHeight parameter for the font (height of uppercase H).
+     * 
+     * @return The CapHeight parameter.
+     */
+    public int getCapHeight() {
+        return etmCapHeight;
+    }
+
+    /**
+     * Returns the XHeight parameter for the font (height of lowercase x).
+     * 
+     * @return The CapHeight parameter.
+     */
+    public int getXHeight() {
+        return etmXHeight;
+    }
+
+    /**
+     * Returns the LowerCaseAscent parameter for the font (height of lowercase d).
+     * 
+     * @return The LowerCaseAscent parameter.
+     */
+    public int getLowerCaseAscent() {
+        return etmLowerCaseAscent;
+    }
+
+    /**
+     * Returns the LowerCaseDescent parameter for the font (height of lowercase p).
+     * 
+     * @return The LowerCaseDescent parameter.
+     */
+    public int getLowerCaseDescent() {
+        return etmLowerCaseDescent;
+    }
+
+    /**
+     * Tells whether the font has proportional character spacing.
+     * 
+     * @return ex. true for Times, false for Courier.
+     */
+    public boolean getIsProportional() {
+        return ((dfPitchAndFamily & 1) == 1);
+    }
+
+    /**
+     * Returns the bounding box for the font.
+     * Note: this value is just an approximation,
+     * it does not really exist in the PFM file.
+     * 
+     * @return The calculated Font BBox.
+     */
+    public int[] getFontBBox() {
+        int[] bbox = new int[4];
+
+        //Just guessing....
+        if (!getIsProportional() && (dfAvgWidth == dfMaxWidth)) {
+            bbox[0] = -20;
+        } else {
+            bbox[0] = -100;
+        }
+        bbox[1] = -(getLowerCaseDescent() + 5);
+        bbox[2] = dfMaxWidth + 10;
+        bbox[3] = getLowerCaseAscent() + 5;
+        return bbox;
+    }
+
+    /**
+     * Returns the characteristics flags for the font as
+     * needed for a PDF font descriptor (See PDF specs).
+     * 
+     * @return The characteristics flags.
+     */
+    public int getFlags() {
+        int flags = 0;
+        if (!getIsProportional()) { flags |= 1; }
+        if ((dfPitchAndFamily & 16) == 16) { flags |= 2; }
+        if ((dfPitchAndFamily & 64) == 64) { flags |= 4; }
+        if (dfCharSet == 0) { flags |= 6; }
+        if (dfItalic != 0) { flags |= 7; }
+        return flags;
+    }
+
+    /**
+     * Returns the width of the dominant vertical stems of the font.
+     * Note: this value is just an approximation,
+     * it does not really exist in the PFM file.
+     * 
+     * @return The vertical stem width.
+     */
+    public int getStemV() {
+        //Just guessing....
+        if (dfItalic != 0) {
+            return (int)Math.round(dfMinWidth * 0.25);
+        } else {
+            return (int)Math.round(dfMinWidth * 0.6);
+        }
+    }
+
+    /**
+     * Returns the italic angle of the font.
+     * Note: this value is just an approximation,
+     * it does not really exist in the PFM file.
+     * 
+     * @return The italic angle.
+     */
+    public int getItalicAngle() {
+        if (dfItalic != 0) {
+            return -16; //Just guessing....
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * Returns the width of a character
+     * 
+     * @param  which The number of the character for which the width is requested.
+     * @return The width of a character.
+     */
+    public int getCharWidth(short which) {
+        return extentTable[which-dfFirstChar];
+    }
+}
\ No newline at end of file
diff --git a/src/org/apache/fop/fonts/PFMInputStream.java b/src/org/apache/fop/fonts/PFMInputStream.java
new file mode 100644 (file)
index 0000000..e45d5e1
--- /dev/null
@@ -0,0 +1,132 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.fonts;
+
+import java.io.*;
+
+/**
+ * This is a helper class for reading PFM files. It defines functions for
+ * extracting specific values out of the stream.
+ *
+ * @author  jeremias.maerki@outline.ch
+ */
+public class PFMInputStream extends java.io.FilterInputStream {
+
+    DataInputStream inStream;
+
+    /**
+     * Constructs a PFMInputStream based on an InputStream representing the PFM file.
+     * 
+     * @param     inStream The stream from which to read the PFM file.
+     */
+    public PFMInputStream(InputStream in) {
+        super(in);
+        inStream = new DataInputStream(in);
+    }
+
+    /**
+     * Parses a one byte value out of the stream.
+     * 
+     * @return The value extracted.
+     */
+    public short readByte() throws IOException {
+        short s = inStream.readByte();
+        //Now, we've got to trick Java into forgetting the sign
+        int s1 = (((s & 0xF0) >>> 4) << 4) + (s & 0x0F);
+        return (short)s1;
+    }
+
+    /**
+     * Parses a two byte value out of the stream.
+     * 
+     * @return The value extracted.
+     */
+    public int readShort() throws IOException {
+        int i = inStream.readShort();
+
+        //Change byte order
+        int high = (i & 0xFF00) >>> 8;
+        int low  = (i & 0x00FF) << 8;
+        return low + high;
+    }
+
+    /**
+     * Parses a four byte value out of the stream.
+     * 
+     * @return The value extracted.
+     */
+    public long readInt() throws IOException {
+        int i = inStream.readInt();
+
+        //Change byte order
+        int i1 = (i & 0xFF000000) >>> 24;
+        int i2 = (i & 0x00FF0000) >>> 8;
+        int i3 = (i & 0x0000FF00) << 8;
+        int i4 = (i & 0x000000FF) << 24;
+        return i1 + i2 + i3 + i4;
+    }
+
+    /**
+     * Parses a zero-terminated string out of the stream.
+     * 
+     * @return The value extracted.
+     */
+    public String readString() throws IOException {
+        InputStreamReader reader = new InputStreamReader(in, "ISO-8859-1");
+        StringBuffer buf = new StringBuffer();
+        int ch = reader.read();
+        while (ch != 0) {
+          buf.append((char) ch);
+          ch = reader.read();
+        }
+        return buf.toString();
+    }
+} 
\ No newline at end of file
diff --git a/src/org/apache/fop/fonts/apps/FontPostProcess.xsl b/src/org/apache/fop/fonts/apps/FontPostProcess.xsl
new file mode 100644 (file)
index 0000000..5739a07
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- xslt stylesheets belonging to the pfmreader -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="xml"/>
+
+<xsl:template match="@*|node()">
+       <xsl:copy>
+               <xsl:apply-templates select="@*|node()"/>
+       </xsl:copy>
+</xsl:template>
+
+<xsl:template match="widths">
+       <xsl:element name="widths">
+               <xsl:for-each select="char">
+                       <xsl:variable name="char-num" select="@ansichar"/>
+                       <xsl:variable name="char-name" select="document('charlist.xml')/font-mappings/map[@win-ansi=$char-num]/@adobe-name"/>
+                       <xsl:if test="$char-name!=''">
+                               <xsl:element name="char">
+                                       <xsl:attribute name="name"><xsl:value-of select="$char-name"/></xsl:attribute>
+                                       <xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
+                               </xsl:element>
+                       </xsl:if>
+               </xsl:for-each>
+       </xsl:element>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/src/org/apache/fop/fonts/apps/FontPostProcessSort.xsl b/src/org/apache/fop/fonts/apps/FontPostProcessSort.xsl
new file mode 100644 (file)
index 0000000..63ca434
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="xml"/>
+
+<xsl:template match="@*|node()">
+       <xsl:copy>
+               <xsl:apply-templates select="@*|node()"/>
+       </xsl:copy>
+</xsl:template>
+
+<xsl:template match="widths">
+       <xsl:copy>
+               <xsl:apply-templates select="char">
+                       <xsl:sort select="@name" case-order="upper-first"/>
+               </xsl:apply-templates>
+       </xsl:copy>
+</xsl:template>
+
+
+</xsl:stylesheet>
diff --git a/src/org/apache/fop/fonts/apps/PFMReader.java b/src/org/apache/fop/fonts/apps/PFMReader.java
new file mode 100644 (file)
index 0000000..3a9eadd
--- /dev/null
@@ -0,0 +1,358 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.fonts.apps;
+
+import java.io.*;
+import org.w3c.dom.*;
+import org.apache.xerces.dom.*;
+import org.apache.xml.serialize.*;
+import org.apache.xalan.xslt.*;
+import org.apache.fop.fonts.*;
+
+/**
+ * A tool which reads PFM files from Adobe Type 1 fonts and creates
+ * XML font metrics file for use in FOP.
+ *
+ * @author  jeremias.maerki@outline.ch
+ */
+public class PFMReader {
+
+    static private final String XSL_POSTPROCESS = "FontPostProcess.xsl";
+    static private final String XSL_SORT        = "FontPostProcessSort.xsl";
+
+    private boolean invokedStandalone = false;
+
+    public PFMReader() {
+    }
+
+    /**
+     * The main method for the PFM reader tool.
+     * 
+     * @param  args Command-line arguments: [pfm-file] {[xml-file]}
+     *               If [xml-file] is not provided, then just a little preview of
+     *               the PFM ist displayed.
+     */
+    public static void main(String[] args) {
+        PFMReader app = new PFMReader();
+        app.invokedStandalone = true;
+
+        System.out.println("PFM Reader v1.0");
+        System.out.println();
+
+        if (args.length > 0) {
+            PFMFile pfm = app.loadPFM(args[0]);
+            if (pfm != null) {
+                app.preview(pfm);
+
+                if (args.length > 1) {
+                    org.w3c.dom.Document doc = app.constructFontXML(pfm);
+                    doc = app.postProcessXML(doc);
+                    if (doc != null) {
+                        app.writeFontXML(doc, args[1]);
+                    }
+                }
+            }
+        } else {
+            System.out.println("Arguments: <source> [<target>]");
+            System.out.println("Example: COM_____.pfm COM_____.xml");
+        }
+    }
+
+    /**
+     * Read a PFM file and returns it as an object.
+     *
+     * @param   filename The filename of the PFM file.
+     * @return  The PFM as an object.
+     */
+    public PFMFile loadPFM(String filename) {
+        try {
+            System.out.println("Reading " + filename + "...");
+            System.out.println();
+            FileInputStream in = new FileInputStream(filename);
+            PFMFile pfm = new PFMFile();
+            pfm.load(in);
+            return pfm;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * Displays a preview of the PFM file on the console.
+     * 
+     * @param   pfm The PFM file to preview.
+     */
+    public void preview(PFMFile pfm) {
+        PrintStream out = System.out;
+
+        out.print("Font: ");
+        out.println(pfm.getWindowsName());
+        out.print("Name: ");
+        out.println(pfm.getPostscriptName());
+        out.print("CharSet: ");
+        out.println(pfm.getCharSetName());
+        out.print("CapHeight: ");
+        out.println(pfm.getCapHeight());
+        out.print("XHeight: ");
+        out.println(pfm.getXHeight());
+        out.print("LowerCaseAscent: ");
+        out.println(pfm.getLowerCaseAscent());
+        out.print("LowerCaseDescent: ");
+        out.println(pfm.getLowerCaseDescent());
+        out.print("Having widths for ");
+        out.print(pfm.getLastChar()-pfm.getFirstChar());
+        out.print(" characters (");
+        out.print(pfm.getFirstChar());
+        out.print("-");
+        out.print(pfm.getLastChar());
+        out.println(").");
+        out.print("for example: Char ");
+        out.print(pfm.getFirstChar());
+        out.print(" has a width of ");
+        out.println(pfm.getCharWidth(pfm.getFirstChar()));
+        out.println();
+    }
+
+    /**
+     * Writes the generated DOM Document to a file.
+     * 
+     * @param   doc The DOM Document to save.
+     * @param   target The target filename for the XML file.
+     */
+    public void writeFontXML(org.w3c.dom.Document doc, String target) {
+        System.out.println("Writing xml font file " + target + "...");
+        System.out.println();
+
+        try {
+            OutputFormat format = new OutputFormat(doc);     //Serialize DOM
+            FileWriter out = new FileWriter(target);         //Writer will be a String
+            XMLSerializer serial = new XMLSerializer(out, format);
+            serial.asDOMSerializer();                        // As a DOM Serializer
+
+            serial.serialize(doc.getDocumentElement());
+            out.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Generates the font metrics file from the PFM file.
+     * 
+     * @param   pfm The PFM file to generate the font metrics from.
+     * @return  The DOM document representing the font metrics file.
+     */
+    public org.w3c.dom.Document constructFontXML(PFMFile pfm) {
+        System.out.println("Creating xml font file...");
+        System.out.println();
+
+        Document doc = new DocumentImpl();
+        Element root = doc.createElement("font-metrics");
+        doc.appendChild(root);
+
+        Element el = doc.createElement("font-name");
+        root.appendChild(el);
+        el.appendChild(doc.createTextNode(pfm.getPostscriptName()));
+
+        String s = pfm.getPostscriptName();
+        int pos = s.indexOf("-");
+        if (pos >= 0) {
+            StringBuffer sb = new StringBuffer(s);
+            sb.deleteCharAt(pos);
+            s = sb.toString();
+        }
+
+        el = doc.createElement("class-name");
+        root.appendChild(el);
+        el.appendChild(doc.createTextNode(s));
+
+        el = doc.createElement("subtype");
+        root.appendChild(el);
+        el.appendChild(doc.createTextNode("Type1"));
+
+        el = doc.createElement("encoding");
+        root.appendChild(el);
+        el.appendChild(doc.createTextNode(pfm.getCharSetName()+"Encoding"));
+
+        el = doc.createElement("cap-height");
+        root.appendChild(el);
+        Integer value = new Integer(pfm.getCapHeight());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        el = doc.createElement("x-height");
+        root.appendChild(el);
+        value = new Integer(pfm.getXHeight());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        el = doc.createElement("ascender");
+        root.appendChild(el);
+        value = new Integer(pfm.getLowerCaseAscent());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        el = doc.createElement("descender");
+        root.appendChild(el);
+        value = new Integer(-pfm.getLowerCaseDescent());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        Element bbox = doc.createElement("bbox");
+        root.appendChild(bbox);
+        int[] bb = pfm.getFontBBox();
+        String[] names = {"left","bottom","right","top"};
+        for (int i=0; i<4; i++) {
+            el = doc.createElement(names[i]);
+            bbox.appendChild(el);
+            value = new Integer(bb[i]);
+            el.appendChild(doc.createTextNode(value.toString()));
+        }
+
+        el = doc.createElement("flags");
+        root.appendChild(el);
+        value = new Integer(pfm.getFlags());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        el = doc.createElement("stemv");
+        root.appendChild(el);
+        value = new Integer(pfm.getStemV());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        el = doc.createElement("italicangle");
+        root.appendChild(el);
+        value = new Integer(pfm.getItalicAngle());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        el = doc.createElement("first-char");
+        root.appendChild(el);
+        value = new Integer(pfm.getFirstChar());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        el = doc.createElement("last-char");
+        root.appendChild(el);
+        value = new Integer(pfm.getLastChar());
+        el.appendChild(doc.createTextNode(value.toString()));
+
+        Element widths = doc.createElement("widths");
+        root.appendChild(widths);
+
+        for (short i = pfm.getFirstChar(); i < pfm.getLastChar(); i++) {
+            el = doc.createElement("char");
+            widths.appendChild(el);
+            el.setAttribute("ansichar", "0x00" + Integer.toHexString(i).toUpperCase());
+            el.setAttribute("width", new Integer(pfm.getCharWidth(i)).toString());
+        }
+
+        return doc;
+    }
+
+    /**
+     * Modifies the generated font metrics file. First, it processes the
+     * character mmappings, then it sorts them.
+     * 
+     * @param   doc The DOM document representing the font metrics file.
+     * @return  A DOM document representing the processed font metrics file.
+     */
+    public org.w3c.dom.Document postProcessXML(org.w3c.dom.Document doc) {
+        try {
+
+            System.out.println("Postprocessing...");
+            System.out.println();
+
+            // Create the 3 objects the XSLTProcessor needs to perform the transformation.
+            org.apache.xalan.xslt.XSLTInputSource xmlSource =
+                new org.apache.xalan.xslt.XSLTInputSource(doc);
+
+            InputStream xsl = this.getClass().getResourceAsStream(XSL_POSTPROCESS);
+            if (xsl == null) {
+                throw new Exception("Resource " + XSL_POSTPROCESS + " not found");
+            }
+            org.apache.xalan.xslt.XSLTInputSource xslSheet =
+                new org.apache.xalan.xslt.XSLTInputSource(xsl);
+
+            Document targetDoc = new DocumentImpl();
+            org.apache.xalan.xslt.XSLTResultTarget xmlResult =
+                new org.apache.xalan.xslt.XSLTResultTarget(targetDoc);
+
+            // Use XSLTProcessorFactory to instantiate an XSLTProcessor.
+            org.apache.xalan.xslt.XSLTProcessor processor =
+                org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor(
+                    new org.apache.xalan.xpath.xdom.XercesLiaison());
+
+            // Perform the transformation.
+            processor.process(xmlSource, xslSheet, xmlResult);
+
+
+            System.out.println("Sorting...");
+            System.out.println();
+
+            // Sort the whole thing
+            xmlSource.setNode(targetDoc);
+
+            xsl = this.getClass().getResourceAsStream(XSL_SORT);
+            if (xsl == null) {
+                throw new Exception("Resource " + XSL_SORT + " not found");
+            }
+            xslSheet = new org.apache.xalan.xslt.XSLTInputSource(xsl);
+
+            org.w3c.dom.Document targetDocSorted = new DocumentImpl();
+            xmlResult =
+                new org.apache.xalan.xslt.XSLTResultTarget(targetDocSorted);
+
+            // Perform the transformation (sort).
+            processor.process(xmlSource, xslSheet, xmlResult);
+
+            return targetDocSorted;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+}
diff --git a/src/org/apache/fop/layout/FontDescriptor.java b/src/org/apache/fop/layout/FontDescriptor.java
new file mode 100644 (file)
index 0000000..defc715
--- /dev/null
@@ -0,0 +1,69 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.layout;
+
+
+public interface FontDescriptor {
+
+    //Required
+    public int getAscender(); //Ascent in pdf spec
+       public int getCapHeight();
+    public int getDescender(); //Descent in pdf spec
+       public int getFlags();
+    public int[] getFontBBox();
+    public String fontName(); //should be getFontName(). not?
+       public int getItalicAngle();
+       public int getStemV();
+
+    //Optional
+    //public int getXHeight();
+
+}
index 68398b0a9d874c672cdf80b4feca854f0af82456..426702f8e4c8c096c6a69a1f909b84fe0a9087a9 100644 (file)
@@ -54,14 +54,19 @@ package org.apache.fop.layout;
  * interface for font metric classes
  */
 public interface FontMetric {
-    int getAscender();
-    int getCapHeight();
-    int getDescender();
-    int getXHeight();
+
+    public int getAscender();
+    public int getCapHeight();
+    public int getDescender();
+    public int getXHeight();
+
+    public int getFirstChar();
+    public int getLastChar();
 
     /**
      * return width (in 1/1000ths of point size) of character at
      * code point i
      */
     public int width(int i);
+    public int[] getWidths();
 }
diff --git a/src/org/apache/fop/pdf/PDFArray.java b/src/org/apache/fop/pdf/PDFArray.java
new file mode 100644 (file)
index 0000000..012bd90
--- /dev/null
@@ -0,0 +1,90 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.pdf;
+
+/**
+ * class representing an array object
+ */
+public class PDFArray extends PDFObject {
+
+       protected int[] values;
+
+       /**
+        * create the array object
+        *
+        * @param number the object's number
+        * @param values the actual array wrapped by this object
+        */
+       public PDFArray(int number, int[] values) {
+
+               /* generic creation of PDF object */
+               super(number);
+
+               /* set fields using paramaters */
+               this.values = values;
+       }
+
+       /**
+        * produce the PDF representation for the object
+        *
+        * @return the PDF
+        */
+       public String toPDF() {
+               StringBuffer p = new StringBuffer();
+               p.append(this.number + " " + this.generation + " obj\n[");
+               for (int i = 0; i < values.length; i++) {
+                       p.append(" ");
+                       p.append(values[i]);
+               }
+               p.append("]\nendobj\n");
+               return p.toString();
+       }
+}
index 44091602cbaaf15cba6e56d1edebd5647efc6597..d93367faafe865d2fab1b7fac3b835488493dda6 100644 (file)
@@ -1,4 +1,4 @@
-/*-- $Id$ -- 
+/*-- $Id$ --
 
  ============================================================================
                    The Apache Software License, Version 1.1
  ANY  THEORY OF LIABILITY,     WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  (INCLUDING  NEGLIGENCE OR     OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
  This software consists of voluntary contributions made  by many individuals
  on  behalf of the Apache Software     Foundation and was      originally created by
- James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
  Software Foundation, please see <http://www.apache.org/>.
+
  */
 
 /* image support modified from work of BoBoGi */
+/* font support based on work by Takayuki Takeuchi */
 
 package org.apache.fop.pdf;
 
@@ -62,6 +63,8 @@ import org.apache.fop.datatypes.ColorSpace;
 
 import org.apache.fop.datatypes.IDReferences;
 import org.apache.fop.layout.Page;
+import org.apache.fop.layout.FontMetric;
+import org.apache.fop.layout.FontDescriptor;
 // Java
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -71,7 +74,7 @@ import java.util.Enumeration;
 import java.awt.Rectangle;
 
 /**
- * class representing a PDF document. 
+ * class representing a PDF document.
  *
  * The document is built up by calling various methods and then finally
  * output to given filehandle using output method.
@@ -716,25 +719,84 @@ public class PDFDocument {
     }
 
 
+       /**
+        * make a /Encoding object
+        *
+        * @param encodingName character encoding scheme name
+        * @return the created /Encoding object
+        */
+       public PDFEncoding makeEncoding(String encodingName) {
+
+           /* create a PDFEncoding with the next object number and add to the
+          list of objects */
+        PDFEncoding encoding = new PDFEncoding(++this.objectcount, encodingName);
+       this.objects.addElement(encoding);
+       return encoding;
+       }
+
+
     /**
      * make a Type1 /Font object
-     * 
+     *
      * @param fontname internal name to use for this font (eg "F1")
      * @param basefont name of the base font (eg "Helvetica")
      * @param encoding character encoding scheme used by the font
+     * @param metrics additional information about the font
+     * @param descriptor additional information about the font
      * @return the created /Font object
      */
     public PDFFont makeFont(String fontname, String basefont,
-    String encoding) {
+    String encoding, FontMetric metrics, FontDescriptor descriptor) {
 
         /* create a PDFFont with the next object number and add to the
            list of objects */
-        PDFFont font = new PDFFont(++this.objectcount, fontname,
-        basefont, encoding);
-        this.objects.addElement(font);
-        return font;
+        if (descriptor == null) {
+            PDFFont font = new PDFFont(++this.objectcount, fontname, PDFFont.TYPE1,
+                    basefont, encoding);
+            this.objects.addElement(font);
+            return font;
+        } else {
+            PDFFontNonBase14 font = (PDFFontNonBase14)PDFFont.createFont(
+                    ++this.objectcount, fontname,
+                    PDFFont.TYPE1, basefont, encoding);
+            this.objects.addElement(font);
+            PDFFontDescriptor pdfdesc = makeFontDescriptor(descriptor);
+            font.setDescriptor(pdfdesc);
+            font.setWidthMetrics(metrics.getFirstChar(), metrics.getLastChar(),
+                    makeArray(metrics.getWidths()));
+            return font;
+        }
     }
 
+
+       /**
+        * make a /FontDescriptor object for a CID font
+        */
+       public PDFFontDescriptor makeFontDescriptor(FontDescriptor desc) {
+
+       /* create a PDFFontDescriptor with the next object number and add to
+           the list of objects */
+       PDFFontDescriptor font = new PDFFontDescriptor(++this.objectcount,
+                desc.fontName(), desc.getAscender(), desc.getDescender(),
+                desc.getCapHeight(), desc.getFlags(),
+                new PDFRectangle(desc.getFontBBox()), desc.getStemV(),
+                desc.getItalicAngle());
+           this.objects.addElement(font);
+       return font;
+       }
+
+
+       /**
+        * make an Array object (ex. Widths array for a font)
+        */
+       public PDFArray makeArray(int[] values) {
+
+        PDFArray array = new PDFArray(++this.objectcount, values);
+           this.objects.addElement(array);
+       return array;
+       }
+
+
     public int addImage(FopImage img) {
         // check if already created
         String url = img.getURL();
diff --git a/src/org/apache/fop/pdf/PDFEncoding.java b/src/org/apache/fop/pdf/PDFEncoding.java
new file mode 100644 (file)
index 0000000..f5ed80a
--- /dev/null
@@ -0,0 +1,152 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.pdf;
+
+// Java
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * class representing an /Encoding object.
+ *
+ * A small object expressing the base encoding name and
+ * the differences from the base encoding.
+ *
+ * The three base encodings are given by their name.
+ *
+ * Encodings are specified on page 213 and onwards of the PDF 1.3 spec.
+ */
+public class PDFEncoding extends PDFObject {
+
+       /** the name for the standard encoding scheme */
+       public static final String MacRomanEncoding = "MacRomanEncoding";
+       /** the name for the standard encoding scheme */
+       public static final String MacExpertEncoding = "MacExpertEncoding";
+       /** the name for the standard encoding scheme */
+       public static final String WinAnsiEncoding = "WinAnsiEncoding";
+
+    /**
+        * the name for the base encoding.
+        * One of the three base encoding scheme names or
+        * the default font's base encoding if null.
+        */
+    protected String basename;
+
+       /** the differences from the base encoding */
+       protected Hashtable differences;
+
+    /**
+     * create the /Encoding object
+     *
+     * @param number the object's number
+     * @param basename the name of the character encoding schema
+     */
+    public PDFEncoding(int number, String basename) {
+
+               /* generic creation of PDF object */
+               super(number);
+
+               /* set fields using paramaters */
+               this.basename = basename;
+               this.differences = new Hashtable();
+       }
+
+       /**
+        * add differences to the encoding
+        *
+        * @param code the first index of the sequence to be changed
+        * @param sequence the sequence of glyph names (as String)
+        */
+       public void addDifferences(int code, Vector sequence) {
+               differences.put(new Integer(code), sequence);
+       }
+
+       /**
+        * produce the PDF representation for the object
+        *
+        * @return the PDF
+        */
+       public String toPDF() {
+               StringBuffer p = new StringBuffer();
+               p.append(this.number + " " + this.generation
+                               + " obj\n<< /Type /Encoding");
+               if ((basename != null) && (!basename.equals(""))) {
+                       p.append("\n/BaseEncoding /" + this.basename);
+               }
+               if (!differences.isEmpty()) {
+                       p.append("\n/Differences [ ");
+                       Object code;
+                       Enumeration codes = differences.keys();
+                       while (codes.hasMoreElements()) {
+                               code = codes.nextElement();
+                               p.append(" "); p.append(code);
+                               Vector sequence = (Vector)differences.get(code);
+                               for (int i = 0; i < sequence.size(); i++) {
+                                       p.append(" /"); p.append((String)sequence.elementAt(i));
+                               }
+                       }
+                       p.append(" ]");
+               }
+               p.append(" >>\nendobj\n");
+               return p.toString();
+       }
+       /* example (p. 214)
+               25 0 obj
+               <<
+               /Type /Encoding
+               /Differences [39 /quotesingle 96 /grave 128
+               /Adieresis /Aring /Ccedilla /Eacute /Ntilde
+               /Odieresis /Udieresis /aacute /agrave]
+               >>
+               endobj
+       */
+}
index 49a6c4791f5821f3a216feb7591d611c30925540..a1226bb1948489327f0c95611676a72696a8c46e 100644 (file)
@@ -1,36 +1,36 @@
-/*-- $Id$ -- 
+/*-- $Id$ --
 
  ============================================================================
                    The Apache Software License, Version 1.1
  ============================================================================
+
     Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
  Redistribution and use in source and binary forms, with or without modifica-
  tion, are permitted provided that the following conditions are met:
+
  1. Redistributions of  source code must  retain the above copyright  notice,
     this list of conditions and the following disclaimer.
+
  2. Redistributions in binary form must reproduce the above copyright notice,
     this list of conditions and the following disclaimer in the documentation
     and/or other materials provided with the distribution.
+
  3. The end-user documentation included with the redistribution, if any, must
     include  the following  acknowledgment:  "This product includes  software
     developed  by the  Apache Software Foundation  (http://www.apache.org/)."
     Alternately, this  acknowledgment may  appear in the software itself,  if
     and wherever such third-party acknowledgments normally appear.
+
  4. The names "Fop" and  "Apache Software Foundation"  must not be used to
     endorse  or promote  products derived  from this  software without  prior
     written permission. For written permission, please contact
     apache@apache.org.
+
  5. Products  derived from this software may not  be called "Apache", nor may
     "Apache" appear  in their name,  without prior written permission  of the
     Apache Software Foundation.
+
  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
  This software  consists of voluntary contributions made  by many individuals
  on  behalf of the Apache Software  Foundation and was  originally created by
- James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
  Software Foundation, please see <http://www.apache.org/>.
+
  */
 package org.apache.fop.pdf;
 
-// Java
-import java.io.IOException;
-import java.io.PrintWriter;
-
 /**
  * class representing a /Font object.
  *
- * A small object expressing the base font name and encoding of a
- * Type 1 font along with an internal name for the font used within
- * streams of content
+ * A more complete object expressing the base font name and encoding of a
+ * font along with an internal name for the font used within
+ * streams of content.
+ *
+ * Fonts are specified on page 198 and onwards of the PDF 1.3 spec.
  */
 public class PDFFont extends PDFObject {
 
+    /** font subtype to be used as parameter to createFont() */
+    public static final byte TYPE0 = 0;
+    /** font subtype to be used as parameter to createFont() */
+    public static final byte TYPE1 = 1;
+    /** font subtype to be used as parameter to createFont() */
+    public static final byte MMTYPE1 = 2;
+    /** font subtype to be used as parameter to createFont() */
+    public static final byte TYPE3 = 3;
+    /** font subtype to be used as parameter to createFont() */
+    public static final byte TRUETYPE = 4;
+
+    /** font subtype names as output in the PDF */
+    protected static final String[] TYPE_NAMES = new String[] // take care of the order
+            {"Type0", "Type1", "MMType1", "Type3", "TrueType"};
+
     /** the internal name for the font (eg "F1") */
     protected String fontname;
 
+    /**
+     * the font's subtype
+     * (as defined by the constants TYPE0, TYPE1, MMTYPE1, TYPE3, TRUETYPE)
+     */
+    protected byte subtype;
+
     /** the base font name (eg "Helvetica") */
     protected String basefont;
 
-    /** the character encoding scheme used by the font (eg
-       "WinAnsiEncoding") */
-    protected String encoding;
+    /**
+     * the character encoding scheme used by the font.
+     * It can be a String for standard encodings, or
+     * a PDFEncoding for a more complex scheme, or
+     * a PDFStream containing a CMap in a Type0 font.
+     * If <code>null</code> then not written out in the PDF.
+     */
+    protected Object encoding;
+
+    /** the Unicode mapping mechanism */
+    //protected PDFToUnicode mapping;
 
     /**
      * create the /Font object
      *
-     * @param the object's number
+     * @param number the object's number
      * @param fontname the internal name for the font
+     * @param subtype the font's subtype
      * @param basefont the base font name
      * @param encoding the character encoding schema used by the font
+     * @param mapping the Unicode mapping mechanism
      */
-    public PDFFont(int number, String fontname, String basefont,
-                  String encoding) {
+    public PDFFont(int number, String fontname, byte subtype, String basefont,
+            Object encoding/*, PDFToUnicode mapping*/) {
 
-       /* generic creation of PDF object */
-       super(number);
+        /* generic creation of PDF object */
+        super(number);
 
-       /* set fields using paramaters */
-       this.fontname = fontname;
-       this.basefont = basefont;
-       this.encoding = encoding;
+        /* set fields using paramaters */
+        this.fontname = fontname;
+        this.subtype = subtype;
+        this.basefont = basefont;
+        this.encoding = encoding;
+        //this.mapping = mapping;
+    }
+
+    /**
+     * factory method with the basic parameters
+     *
+     * @param number the object's number
+     * @param fontname the internal name for the font
+     * @param subtype the font's subtype
+     * @param basefont the base font name
+     * @param encoding the character encoding schema used by the font
+     */
+    public static PDFFont createFont(int number, String fontname,
+            byte subtype, String basefont, Object encoding) {
+        switch (subtype) {
+            /*
+            case TYPE0 :
+                return new PDFFontType0(number, fontname, subtype, basefont, encoding);
+            */
+            case TYPE1 :
+            case MMTYPE1 :
+                return new PDFFontType1(number, fontname, subtype, basefont, encoding);
+            /*
+            case TYPE3 :
+                return new PDFFontType3(number, fontname, subtype, basefont, encoding);
+            case TRUETYPE :
+                return new PDFFontTrueType(number, fontname, subtype, basefont, encoding);
+            */
+        }
+        return null;    // should not happend
+    }
+
+    /**
+     * factory method with the extended parameters
+     * for Type1, MMType1 and TrueType
+     *
+     * @param number the object's number
+     * @param fontname the internal name for the font
+     * @param subtype the font's subtype
+     * @param basefont the base font name
+     * @param encoding the character encoding schema used by the font
+     * @param firstChar the first character code in the font
+     * @param lastChar the last character code in the font
+     * @param widths an array of size (lastChar - firstChar +1)
+     * @param descriptor the descriptor for other font's metrics
+     */
+    public static PDFFont createFont(int number, String fontname,
+            byte subtype, String basefont, Object encoding,
+            int firstChar, int lastChar, PDFArray widths,
+            PDFFontDescriptor descriptor) {
+
+        PDFFontNonBase14 font;
+        switch (subtype) {
+            case TYPE0 :
+                return null;    // should not happend
+            case TYPE1 :
+            case MMTYPE1 :
+                font = new PDFFontType1(number, fontname, subtype, basefont, encoding);
+                font.setWidthMetrics(firstChar, lastChar, widths);
+                font.setDescriptor(descriptor);
+                return font;
+            case TYPE3 :
+                return null;    // should not happend
+            /*
+            case TRUETYPE :
+                font = new PDFFontTrueType(number, fontname, subtype, basefont, encoding);
+                font.setWidthMetrics(firstChar, lastChar, widths);
+                font.setDescriptor(descriptor);
+                return font;
+            */
+        }
+        return null;    // should not happend
     }
 
     /**
@@ -99,7 +201,7 @@ public class PDFFont extends PDFObject {
      * @return the internal name
      */
     public String getName() {
-       return this.fontname;
+        return this.fontname;
     }
 
     /**
@@ -108,10 +210,32 @@ public class PDFFont extends PDFObject {
      * @return the PDF
      */
     public String toPDF() {
-       String p = this.number + " " + this.generation
-           + " obj\n<< /Type /Font\n/Subtype /Type1\n/Name /"
-           + this.fontname + "\n/BaseFont /" + this.basefont
-           + "\n/Encoding /"+ this.encoding + " >>\nendobj\n";
-       return p;
+        StringBuffer p = new StringBuffer();
+        p.append(this.number + " " + this.generation
+                + " obj\n<< /Type /Font\n/Subtype /" + TYPE_NAMES[this.subtype]
+                + "\n/Name /" + this.fontname + "\n/BaseFont /" + this.basefont);
+        if (encoding != null) {
+            p.append("\n/Encoding ");
+            if (encoding instanceof PDFEncoding) {
+                p.append(((PDFEncoding)this.encoding).referencePDF());
+            } else if (encoding instanceof PDFStream) {
+                p.append(((PDFStream)this.encoding).referencePDF());
+            } else {
+                p.append("/").append((String)encoding);
+            }
+        }
+        fillInPDF(p);
+        p.append(" >>\nendobj\n");
+        return p.toString();
+    }
+
+    /**
+     * fill in the specifics for the font's subtype.
+     *
+     * the given buffer already contains the fields common to all font types.
+     *
+     * @param begin the buffer to be completed with the type specific fields
+     */
+    protected void fillInPDF(StringBuffer begin) {
     }
 }
diff --git a/src/org/apache/fop/pdf/PDFFontDescriptor.java b/src/org/apache/fop/pdf/PDFFontDescriptor.java
new file mode 100644 (file)
index 0000000..3f9f38d
--- /dev/null
@@ -0,0 +1,203 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.pdf;
+
+/**
+ * class representing a font descriptor.
+ *
+ * Font descriptors are specified on page 222 and onwards of the PDF 1.3 spec.
+ */
+public class PDFFontDescriptor extends PDFObject {
+
+       // Required fields
+       protected int ascent;
+    protected int capHeight;
+       protected int descent;
+    protected int flags;
+    protected PDFRectangle fontBBox;
+    protected String basefont; //PDF-spec: FontName
+    protected int italicAngle;
+    protected int stemV;
+       // Optional fields
+       protected int stemH = 0;
+       protected int xHeight = 0;
+       protected int leading = 0;
+       protected int avgWidth = 0;
+       protected int maxWidth = 0;
+       protected int missingWidth = 0;
+       protected PDFStream fontfile;
+       //protected String charSet = null;
+
+       protected byte subtype;
+
+       /**
+        * create the /FontDescriptor object
+        *
+        * @param number the object's number
+        * @param ascent the maximum height above the baseline
+        * @param descent the maximum depth below the baseline
+        * @param capHeight height of the capital letters
+        * @param flags various characteristics of the font
+        * @param fontBBox the bounding box for the described font
+        * @param basefont the base font name
+        * @param italicAngle the angle of the vertical dominant strokes
+        * @param stemV the width of the dominant vertical stems of glyphs
+        */
+       public PDFFontDescriptor(int number, String basefont, int ascent,
+            int descent, int capHeight, int flags, PDFRectangle fontBBox,
+                       int italicAngle, int stemV) {
+
+               /* generic creation of PDF object */
+               super(number);
+
+               /* set fields using paramaters */
+           this.basefont = basefont;
+               this.ascent = ascent;
+               this.descent = descent;
+           this.capHeight = capHeight;
+           this.flags = flags;
+           this.fontBBox = fontBBox;
+           this.italicAngle = italicAngle;
+           this.stemV = stemV;
+       }
+
+       /**
+        * set the optional metrics
+        */
+       public void setMetrics(int avgWidth, int maxWidth, int missingWidth, int leading, int stemH, int xHeight) {
+               this.avgWidth = avgWidth;
+               this.maxWidth = maxWidth;
+               this.missingWidth = missingWidth;
+               this.leading = leading;
+               this.stemH = stemH;
+               this.xHeight = xHeight;
+       }
+
+       /**
+        * set the optional font file stream
+        *
+        * @param subtype the font type defined in the font stream
+        * @param fontfile the stream containing an embedded font
+        */
+       public void setFontFile(byte subtype, PDFStream fontfile) {
+               this.subtype = subtype;
+               this.fontfile = fontfile;
+       }
+
+       //public void setCharSet(){}//for subset fonts
+
+       /**
+        * produce the PDF representation for the object
+        *
+        * @return the PDF
+        */
+    public String toPDF() {
+               StringBuffer p = new StringBuffer(
+                               this.number + " " + this.generation
+                               + " obj\n<< /Type /FontDescriptor"
+                               + "\n/FontName /" + this.basefont);
+
+               p.append("\n/FontBBox ");    p.append(fontBBox.toPDF());
+               p.append("\n/Flags ");       p.append(flags);
+               p.append("\n/CapHeight ");   p.append(capHeight);
+               p.append("\n/Ascent ");      p.append(ascent);
+               p.append("\n/Descent ");     p.append(descent);
+               p.append("\n/ItalicAngle "); p.append(italicAngle);
+               p.append("\n/StemV ");       p.append(stemV);
+               // optional fields
+               if (stemH != 0) {
+                       p.append("\n/StemH ");  p.append(stemH);
+               }
+               if (xHeight != 0) {
+                       p.append("\n/XHeight ");  p.append(xHeight);
+               }
+               if (avgWidth != 0) {
+                       p.append("\n/AvgWidth ");  p.append(avgWidth);
+               }
+               if (maxWidth != 0) {
+                       p.append("\n/MaxWidth ");  p.append(maxWidth);
+               }
+               if (missingWidth != 0) {
+                       p.append("\n/MissingWidth ");  p.append(missingWidth);
+               }
+               if (leading != 0) {
+                       p.append("\n/Leading ");  p.append(leading);
+               }
+               if (fontfile != null) {
+                       switch (subtype) {
+                               case PDFFont.TYPE1:
+                                       p.append("\n/FontFile ");
+                               break;
+                               case PDFFont.TRUETYPE:
+                                       p.append("\n/FontFile2 ");
+                               break;
+                               default:
+                                       p.append("\n/FontFile3 ");
+                       }
+                       p.append(fontfile.referencePDF());
+               }
+               // charSet for subset fonts // not yet implemented
+               // CID optional field
+               fillInPDF(p);
+               p.append("\n >>\nendobj\n");
+               return p.toString();
+    }
+
+       /**
+        * fill in the specifics for the font's descriptor.
+        *
+        * the given buffer already contains the fields common to all descriptors.
+        *
+        * @param begin the buffer to be completed with the specific fields
+        */
+       protected void fillInPDF(StringBuffer begin) {
+       }
+}
diff --git a/src/org/apache/fop/pdf/PDFFontNonBase14.java b/src/org/apache/fop/pdf/PDFFontNonBase14.java
new file mode 100644 (file)
index 0000000..583af81
--- /dev/null
@@ -0,0 +1,124 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.pdf;
+
+// Java
+
+/**
+ * A common ancestor for Type1, TrueType, MMType1 and Type3 fonts
+ * (all except base 14 fonts).
+ */
+public abstract class PDFFontNonBase14 extends PDFFont {
+
+       /** first character code in the font */
+       protected int firstChar;
+       /** last character code in the font */
+       protected int lastChar;
+       /** widths of characters from firstChar to lastChar */
+       protected PDFArray widths;
+       /** descriptor of font metrics */
+       protected PDFFontDescriptor descriptor;
+
+       /**
+        * create the /Font object
+        *
+        * @param number the object's number
+        * @param fontname the internal name for the font
+        * @param subtype the font's subtype
+        * @param basefont the base font name
+        * @param encoding the character encoding schema used by the font
+        * @param mapping the Unicode mapping mechanism
+        */
+       public PDFFontNonBase14(int number, String fontname, byte subtype,
+                       String basefont, Object encoding/*, PDFToUnicode mapping*/) {
+
+               /* generic creation of PDF object */
+               super(number, fontname, subtype, basefont, encoding);
+
+               this.descriptor = null;
+       }
+
+       /**
+        * set the width metrics for the font
+        *
+        * @param firstChar the first character code in the font
+        * @param lastChar the last character code in the font
+        * @param widths an array of size (lastChar - firstChar +1)
+        */
+       public void setWidthMetrics(int firstChar, int lastChar, PDFArray widths) {
+               /* set fields using paramaters */
+               this.firstChar = firstChar;
+               this.lastChar = lastChar;
+               this.widths = widths;
+       }
+
+       /**
+        * set the font descriptor (unused for the Type3 fonts)
+        *
+        * @param descriptor the descriptor for other font's metrics
+        */
+       public void setDescriptor(PDFFontDescriptor descriptor) {
+               this.descriptor = descriptor;
+       }
+
+       /**
+        * fill in the specifics for the font's subtype
+        */
+       protected void fillInPDF(StringBuffer p) {
+               p.append("\n/FirstChar "); p.append(firstChar);
+               p.append("\n/LastChar "); p.append(lastChar);
+               p.append("\n/Widths "); p.append(this.widths.referencePDF());
+               if (descriptor != null) {
+                       p.append("\n/FontDescriptor ");
+                       p.append(this.descriptor.referencePDF());
+               }
+       }
+}
diff --git a/src/org/apache/fop/pdf/PDFFontType1.java b/src/org/apache/fop/pdf/PDFFontType1.java
new file mode 100644 (file)
index 0000000..3516b67
--- /dev/null
@@ -0,0 +1,81 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.pdf;
+
+/**
+ * class representing a Type1 or MMType1 font (not necessary for the base 14).
+ *
+ * Type1 fonts are specified on page 201 and onwards of the PDF 1.3 spec.
+ * MMType1 fonts are specified on page 205 and onwards of the PDF 1.3 spec.
+ *
+ * In fact everything already done in the superclass.
+ * Must only define the not default constructor.
+ */
+public class PDFFontType1 extends PDFFontNonBase14 {
+
+       /**
+        * create the /Font object
+        *
+        * @param number the object's number
+        * @param fontname the internal name for the font
+        * @param subtype the font's subtype (PDFFont.TYPE1 or PDFFont.MMTYPE1)
+        * @param basefont the base font name
+        * @param encoding the character encoding schema used by the font
+        * @param mapping the Unicode mapping mechanism
+        */
+       public PDFFontType1(int number, String fontname, byte subtype,
+                       String basefont, Object encoding/*, PDFToUnicode mapping*/) {
+
+               /* generic creation of PDF object */
+               super(number, fontname, subtype, basefont, encoding);
+       }
+
+}
diff --git a/src/org/apache/fop/pdf/PDFRectangle.java b/src/org/apache/fop/pdf/PDFRectangle.java
new file mode 100644 (file)
index 0000000..5c5a563
--- /dev/null
@@ -0,0 +1,103 @@
+/*-- $Id$ --
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+package org.apache.fop.pdf;
+
+/**
+ * class representing a rectangle
+ *
+ * Rectangles are specified on page 183 of the PDF 1.3 spec.
+ */
+public class PDFRectangle {
+       /** lower left x coordinate */
+       protected int llx;
+       /** lower left y coordinate */
+       protected int lly;
+       /** upper right x coordinate */
+       protected int urx;
+       /** upper right y coordinate */
+       protected int ury;
+
+       /**
+        * create a rectangle giving the four separate values
+        *
+        * @param llx  lower left x coordinate
+        * @param lly  lower left y coordinate
+        * @param urx  upper right x coordinate
+        * @param ury  upper right y coordinate
+        */
+       public PDFRectangle(int llx, int lly, int urx, int ury) {
+               this.llx = llx;
+               this.lly = lly;
+               this.urx = urx;
+               this.ury = ury;
+       }
+
+       /**
+        * create a rectangle giving an array of four values
+        *
+        * @param array values in the order llx, lly, urx, ury
+        */
+       public PDFRectangle(int[] array) {
+               this.llx = array[0];
+               this.lly = array[1];
+               this.urx = array[2];
+               this.ury = array[3];
+       }
+
+       /**
+        * produce the PDF representation for the object
+        *
+        * @return the PDF
+        */
+    public String toPDF() {
+               return " [" + llx + " " + lly + " " + urx + " " + ury + "] ";
+       }
+}
index 68841f8b317fdf45d3e139abf92c27824cf19281..368a67af8c603607b3a082bbc4d57139d621203c 100644 (file)
@@ -54,6 +54,7 @@ package org.apache.fop.render.pdf;
 import org.apache.fop.render.pdf.fonts.*;
 import org.apache.fop.messaging.MessageHandler;
 import org.apache.fop.layout.FontInfo;
+import org.apache.fop.layout.FontDescriptor;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFResources;
 
@@ -78,126 +79,136 @@ public class FontSetup {
      * @param fontInfo the font info object to set up
      */
     public static void setup(FontInfo fontInfo) {
-       MessageHandler.logln("setting up fonts");
-               
-       fontInfo.addMetrics("F1", new Helvetica());
-       fontInfo.addMetrics("F2", new HelveticaOblique());
-       fontInfo.addMetrics("F3", new HelveticaBold());
-       fontInfo.addMetrics("F4", new HelveticaBoldOblique());
-       fontInfo.addMetrics("F5", new TimesRoman());
-       fontInfo.addMetrics("F6", new TimesItalic());
-       fontInfo.addMetrics("F7", new TimesBold());
-       fontInfo.addMetrics("F8", new TimesBoldItalic());
-       fontInfo.addMetrics("F9", new Courier());
-       fontInfo.addMetrics("F10", new CourierOblique());
-       fontInfo.addMetrics("F11", new CourierBold());
-       fontInfo.addMetrics("F12", new CourierBoldOblique());
-       fontInfo.addMetrics("F13", new Symbol());
-       fontInfo.addMetrics("F14", new ZapfDingbats());
-               
-       /* any is treated as serif */
-       fontInfo.addFontProperties("F5", "any", "normal", "normal");
-       fontInfo.addFontProperties("F6", "any", "italic", "normal");
-       fontInfo.addFontProperties("F6", "any", "oblique", "normal");
-       fontInfo.addFontProperties("F7", "any", "normal", "bold");
-       fontInfo.addFontProperties("F8", "any", "italic", "bold");
-       fontInfo.addFontProperties("F8", "any", "oblique", "bold");
-               
-       fontInfo.addFontProperties("F1", "sans-serif", "normal",
-                                  "normal");
-       fontInfo.addFontProperties("F2", "sans-serif", "oblique",
-                                  "normal");
-       fontInfo.addFontProperties("F2", "sans-serif", "italic",
-                                  "normal");
-       fontInfo.addFontProperties("F3", "sans-serif", "normal",
-                                  "bold");
-       fontInfo.addFontProperties("F4", "sans-serif", "oblique",
-                                  "bold");
-       fontInfo.addFontProperties("F4", "sans-serif", "italic",
-                                  "bold");
-       fontInfo.addFontProperties("F5", "serif", "normal", "normal");
-       fontInfo.addFontProperties("F6", "serif", "oblique",
-                                  "normal");
-       fontInfo.addFontProperties("F6", "serif", "italic", "normal");
-       fontInfo.addFontProperties("F7", "serif", "normal", "bold");
-       fontInfo.addFontProperties("F8", "serif", "oblique", "bold");
-       fontInfo.addFontProperties("F8", "serif", "italic", "bold");
-       fontInfo.addFontProperties("F9", "monospace", "normal",
-                                  "normal");
-       fontInfo.addFontProperties("F10", "monospace", "oblique",
-                                  "normal");
-       fontInfo.addFontProperties("F10", "monospace", "italic",
-                                  "normal");
-       fontInfo.addFontProperties("F11", "monospace", "normal",
-                                  "bold");
-       fontInfo.addFontProperties("F12", "monospace", "oblique",
-                                  "bold");
-       fontInfo.addFontProperties("F12", "monospace", "italic",
-                                  "bold");
-       
-       fontInfo.addFontProperties("F1", "Helvetica", "normal",
-                                  "normal"); 
-       fontInfo.addFontProperties("F2", "Helvetica", "oblique",
-                                  "normal"); 
-       fontInfo.addFontProperties("F2", "Helvetica", "italic",
-                                  "normal"); 
-       fontInfo.addFontProperties("F3", "Helvetica", "normal",
-                                  "bold"); 
-       fontInfo.addFontProperties("F4", "Helvetica", "oblique",
-                                  "bold"); 
-       fontInfo.addFontProperties("F4", "Helvetica", "italic",
-                                  "bold"); 
-       fontInfo.addFontProperties("F5", "Times", "normal", "normal");
-       fontInfo.addFontProperties("F6", "Times", "oblique",
-                                  "normal"); 
-       fontInfo.addFontProperties("F6", "Times", "italic", "normal");
-       fontInfo.addFontProperties("F7", "Times", "normal", "bold");
-       fontInfo.addFontProperties("F8", "Times", "oblique", "bold"); 
-       fontInfo.addFontProperties("F8", "Times", "italic", "bold");
-       fontInfo.addFontProperties("F9", "Courier", "normal",
-                                  "normal"); 
-       fontInfo.addFontProperties("F10", "Courier", "oblique",
-                                  "normal"); 
-       fontInfo.addFontProperties("F10", "Courier", "italic",
-                                  "normal"); 
-       fontInfo.addFontProperties("F11", "Courier", "normal",
-                                  "bold"); 
-       fontInfo.addFontProperties("F12", "Courier", "oblique",
-                                  "bold"); 
-       fontInfo.addFontProperties("F12", "Courier", "italic",
-                                  "bold"); 
-       fontInfo.addFontProperties("F13", "Symbol", "normal",
-                                  "normal"); 
-       fontInfo.addFontProperties("F14", "ZapfDingbats", "normal",
-                                  "normal"); 
+    MessageHandler.logln("setting up fonts");
+        
+    fontInfo.addMetrics("F1", new Helvetica());
+    fontInfo.addMetrics("F2", new HelveticaOblique());
+    fontInfo.addMetrics("F3", new HelveticaBold());
+    fontInfo.addMetrics("F4", new HelveticaBoldOblique());
+    fontInfo.addMetrics("F5", new TimesRoman());
+    fontInfo.addMetrics("F6", new TimesItalic());
+    fontInfo.addMetrics("F7", new TimesBold());
+    fontInfo.addMetrics("F8", new TimesBoldItalic());
+    fontInfo.addMetrics("F9", new Courier());
+    fontInfo.addMetrics("F10", new CourierOblique());
+    fontInfo.addMetrics("F11", new CourierBold());
+    fontInfo.addMetrics("F12", new CourierBoldOblique());
+    fontInfo.addMetrics("F13", new Symbol());
+    fontInfo.addMetrics("F14", new ZapfDingbats());
+    fontInfo.addMetrics("F15", new URWPalladioLRoma());
+//    fontInfo.addMetrics("F15", new OMEP());
+//    fontInfo.addMetrics("F16", new GaramondLightCondensed());
+//    fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
 
-       /* for compatibility with PassiveTex */
-       fontInfo.addFontProperties("F5", "Times-Roman", "normal",
-                                  "normal"); 
-       fontInfo.addFontProperties("F6", "Times-Roman", "oblique",
-                                  "normal"); 
-       fontInfo.addFontProperties("F6", "Times-Roman", "italic",
-                                  "normal"); 
-       fontInfo.addFontProperties("F7", "Times-Roman", "normal",
-                                  "bold"); 
-       fontInfo.addFontProperties("F8", "Times-Roman", "oblique",
-                                  "bold"); 
-       fontInfo.addFontProperties("F8", "Times-Roman", "italic",
-                                  "bold"); 
-       fontInfo.addFontProperties("F5", "Times Roman", "normal",
-                                  "normal"); 
-       fontInfo.addFontProperties("F6", "Times Roman", "oblique",
-                                  "normal"); 
-       fontInfo.addFontProperties("F6", "Times Roman", "italic",
-                                  "normal"); 
-       fontInfo.addFontProperties("F7", "Times Roman", "normal",
-                                  "bold"); 
-       fontInfo.addFontProperties("F8", "Times Roman", "oblique",
-                                  "bold"); 
-       fontInfo.addFontProperties("F8", "Times Roman", "italic",
-                                  "bold"); 
-       fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
-                                  "normal", "normal");
+    /* any is treated as serif */
+    fontInfo.addFontProperties("F5", "any", "normal", "normal");
+    fontInfo.addFontProperties("F6", "any", "italic", "normal");
+    fontInfo.addFontProperties("F6", "any", "oblique", "normal");
+    fontInfo.addFontProperties("F7", "any", "normal", "bold");
+    fontInfo.addFontProperties("F8", "any", "italic", "bold");
+    fontInfo.addFontProperties("F8", "any", "oblique", "bold");
+
+    fontInfo.addFontProperties("F1", "sans-serif", "normal",
+                   "normal");
+    fontInfo.addFontProperties("F2", "sans-serif", "oblique",
+                   "normal");
+    fontInfo.addFontProperties("F2", "sans-serif", "italic",
+                   "normal");
+    fontInfo.addFontProperties("F3", "sans-serif", "normal",
+                   "bold");
+    fontInfo.addFontProperties("F4", "sans-serif", "oblique",
+                   "bold");
+    fontInfo.addFontProperties("F4", "sans-serif", "italic",
+                   "bold");
+    fontInfo.addFontProperties("F5", "serif", "normal", "normal");
+    fontInfo.addFontProperties("F6", "serif", "oblique",
+                   "normal");
+    fontInfo.addFontProperties("F6", "serif", "italic", "normal");
+    fontInfo.addFontProperties("F7", "serif", "normal", "bold");
+    fontInfo.addFontProperties("F8", "serif", "oblique", "bold");
+    fontInfo.addFontProperties("F8", "serif", "italic", "bold");
+    fontInfo.addFontProperties("F9", "monospace", "normal",
+                   "normal");
+    fontInfo.addFontProperties("F10", "monospace", "oblique",
+                   "normal");
+    fontInfo.addFontProperties("F10", "monospace", "italic",
+                   "normal");
+    fontInfo.addFontProperties("F11", "monospace", "normal",
+                   "bold");
+    fontInfo.addFontProperties("F12", "monospace", "oblique",
+                   "bold");
+    fontInfo.addFontProperties("F12", "monospace", "italic",
+                   "bold");
+
+    fontInfo.addFontProperties("F1", "Helvetica", "normal",
+                   "normal");
+    fontInfo.addFontProperties("F2", "Helvetica", "oblique",
+                   "normal");
+    fontInfo.addFontProperties("F2", "Helvetica", "italic",
+                   "normal");
+    fontInfo.addFontProperties("F3", "Helvetica", "normal",
+                   "bold");
+    fontInfo.addFontProperties("F4", "Helvetica", "oblique",
+                   "bold");
+    fontInfo.addFontProperties("F4", "Helvetica", "italic",
+                   "bold");
+    fontInfo.addFontProperties("F5", "Times", "normal", "normal");
+    fontInfo.addFontProperties("F6", "Times", "oblique",
+                   "normal");
+    fontInfo.addFontProperties("F6", "Times", "italic", "normal");
+    fontInfo.addFontProperties("F7", "Times", "normal", "bold");
+    fontInfo.addFontProperties("F8", "Times", "oblique", "bold");
+    fontInfo.addFontProperties("F8", "Times", "italic", "bold");
+    fontInfo.addFontProperties("F9", "Courier", "normal",
+                   "normal");
+    fontInfo.addFontProperties("F10", "Courier", "oblique",
+                   "normal");
+    fontInfo.addFontProperties("F10", "Courier", "italic",
+                   "normal");
+    fontInfo.addFontProperties("F11", "Courier", "normal",
+                   "bold");
+    fontInfo.addFontProperties("F12", "Courier", "oblique",
+                   "bold");
+    fontInfo.addFontProperties("F12", "Courier", "italic",
+                   "bold");
+    fontInfo.addFontProperties("F13", "Symbol", "normal",
+                   "normal");
+    fontInfo.addFontProperties("F14", "ZapfDingbats", "normal",
+                   "normal");
+
+    fontInfo.addFontProperties("F15", "URWPalladioLRoma", "normal", "normal");
+    //Custom type 1 fonts
+//    fontInfo.addFontProperties("F15", "OMEP", "normal", "normal");
+//    fontInfo.addFontProperties("F16", "Garamond-LightCondensed", "normal", "normal");
+//    fontInfo.addFontProperties("F17", "BauerBodoni", "italic", "bold");
+
+    /* for compatibility with PassiveTex */
+    fontInfo.addFontProperties("F5", "Times-Roman", "normal",
+                   "normal");
+    fontInfo.addFontProperties("F6", "Times-Roman", "oblique",
+                   "normal");
+    fontInfo.addFontProperties("F6", "Times-Roman", "italic",
+                   "normal");
+    fontInfo.addFontProperties("F7", "Times-Roman", "normal",
+                   "bold");
+    fontInfo.addFontProperties("F8", "Times-Roman", "oblique",
+                   "bold"); 
+    fontInfo.addFontProperties("F8", "Times-Roman", "italic",
+                   "bold"); 
+    fontInfo.addFontProperties("F5", "Times Roman", "normal",
+                   "normal"); 
+    fontInfo.addFontProperties("F6", "Times Roman", "oblique",
+                   "normal"); 
+    fontInfo.addFontProperties("F6", "Times Roman", "italic",
+                   "normal"); 
+    fontInfo.addFontProperties("F7", "Times Roman", "normal",
+                   "bold"); 
+    fontInfo.addFontProperties("F8", "Times Roman", "oblique",
+                   "bold"); 
+    fontInfo.addFontProperties("F8", "Times Roman", "italic",
+                   "bold"); 
+    fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
+                   "normal", "normal");
     }
 
     /**
@@ -207,18 +218,23 @@ public class FontSetup {
      * @param fontInfo font info object to get font information from
      */
     public static void addToResources(PDFDocument doc, FontInfo fontInfo) {
-       Hashtable fonts = fontInfo.getFonts();
-       Enumeration e = fonts.keys();
-       PDFResources resources = doc.getResources();
-       while (e.hasMoreElements()) {
-           String f = (String) e.nextElement();
-           resources.addFont(doc.makeFont(f,
-                                          ((Font)
-                                           fonts.get(f)).fontName(),
-                                          ((Font)
-                                           fonts.get(f)).encoding()
-                                          )
-                             );
-       }
+    Hashtable fonts = fontInfo.getFonts();
+    Enumeration e = fonts.keys();
+    PDFResources resources = doc.getResources();
+    while (e.hasMoreElements()) {
+        String f = (String) e.nextElement();
+        Font font = (Font)fonts.get(f);
+        FontDescriptor desc = null;
+        if (font instanceof FontDescriptor) {
+            desc = (FontDescriptor)font;
+        }
+        resources.addFont(doc.makeFont(f,
+                       font.fontName(),
+                       font.encoding(),
+                       font,
+                       desc
+                       )
+                  );
+    }
     }
 }