DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25997>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25997

[PATCH] Basic OpenType CFF Support for maintenance branch: 3 Patches

           Summary: [PATCH] Basic OpenType CFF Support for maintenance
                    branch: 3 Patches
           Product: Fop
           Version: 0.20.5
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: general
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Index: TTFFile.java
===================================================================
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/fonts/Attic/TTFFile.java,v
retrieving revision 1.6.2.10
diff -w -u -r1.6.2.10 TTFFile.java
--- TTFFile.java        20 Sep 2003 21:48:18 -0000      1.6.2.10
+++ TTFFile.java        8 Jan 2004 19:32:42 -0000
@@ -51,10 +51,14 @@
 package org.apache.fop.fonts;
 
 import java.io.IOException;

+
 import java.util.ArrayList;

+
 import java.util.HashMap;

+
 import java.util.Iterator;

 
+
 /**
  * Reads a TrueType file or a TrueType Collection.
  * The TrueType spec can be found at the Microsoft
@@ -112,6 +116,7 @@
     HashMap ansiIndex;
 
     private TTFDirTabEntry currentDirTab;
+    private boolean isCFF = false;
 
     /**
      * Position inputstream to position indicated
@@ -431,16 +436,22 @@
         initAnsiWidths();
         readPostscript(in);
         readOS2(in);
+        if (!isCFF) {
         readIndexToLocation(in);
         readGlyf(in);
+        }
         readName(in);
         readPCLT(in);
         readCMAP(in);     // Read cmap table and fill in ansiwidths
         createCMaps();    // Create cmaps for bfentries
         // print_max_min();
 
+               if (isCFF) {
+                       // readGPOS(in); // GPOS is OpenType CFF analog of 
TrueType kerning table.                 
+               } else {
         readKerning(in);
     }
+    }
 
     private void createCMaps() {
         cmaps = new ArrayList();
@@ -626,6 +637,10 @@
         return is_embeddable;
     }
 
+    public boolean isCFF() {
+       return isCFF;
+    }
+
 
     /**
      * Read Table Directory from the current position in the
@@ -634,7 +649,22 @@
      * as value.
      */
     protected void readDirTabs(FontFileReader in) throws IOException {
-        in.skip(4);    // TTF_FIXED_SIZE
+               byte[]  verBytes = new byte[4];
+               verBytes[0] = in.readTTFByte();
+               verBytes[1] = in.readTTFByte();
+               verBytes[2] = in.readTTFByte();
+               verBytes[3] = in.readTTFByte();
+               String version = new String(verBytes, "ISO-8859-1");
+               if (verBytes[1] == 0x01) {
+                       System.out.println("Font is TrueType TTF format");      
                
+               } else if (version.equals("OTTO")) {
+                       System.out.println("Font is OpenType CFF format");
+                       isCFF = true;
+               } else {
+                       String msg = "Font does not appear to be either 
TrueType or OpenType";
+                       throw new IOException(msg);
+               }
+
         int ntabs = in.readTTFUShort();
         in.skip(6);    // 3xTTF_USHORT_SIZE
 
Index: TTFDirTabEntry.java
===================================================================
RCS file: /home/cvspublic/xml-
fop/src/org/apache/fop/fonts/Attic/TTFDirTabEntry.java,v
retrieving revision 1.4.2.2
diff -w -u -r1.4.2.2 TTFDirTabEntry.java
--- TTFDirTabEntry.java 20 Sep 2003 21:48:18 -0000      1.4.2.2
+++ TTFDirTabEntry.java 8 Jan 2004 19:32:01 -0000
@@ -50,7 +50,8 @@
  */
 package org.apache.fop.fonts;
 
-import java.io.IOException;

+import java.io.IOException;
import java.io.UnsupportedEncodingException;
+
 
 class TTFDirTabEntry {
     byte[] tag;
@@ -85,7 +86,18 @@
          * " length: " + length +
          * " name: " + new String(tag));
          */
-        return new String(tag, "ISO-8859-1");
+               String tagStr = new String(tag, "ISO-8859-1");
+        // System.err.println("tag='" + tagStr + "'");
+
+        //System.out.println(this.toString());
+        return tagStr;
     }
 
+       public String getTagString() {
+               try {
+                       return new String(tag, "ISO-8859-1");
+               } catch (UnsupportedEncodingException e) {
+                       return this.toString(); // Should never happen.
+               }
+       }
 }

Index: TTFReader.java
===================================================================
RCS file: /home/cvspublic/xml-
fop/src/org/apache/fop/fonts/apps/Attic/TTFReader.java,v
retrieving revision 1.4.2.5
diff -w -u -r1.4.2.5 TTFReader.java
--- TTFReader.java      20 Sep 2003 21:48:18 -0000      1.4.2.5
+++ TTFReader.java      8 Jan 2004 19:33:25 -0000
@@ -425,6 +425,9 @@
             }
         }
 
+               // TODO: Need to get equivalent info from GPOS table for
+               // CFF fonts.           
+               if (!ttf.isCFF()) {
         // Get kerning
         Iterator enum;
         if (isCid)
@@ -457,6 +460,7 @@
                 }
             }
         }
+               }
 
         return doc;
     }

Reply via email to