xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lberna...@apache.org
Subject svn commit: r1514076 [1/5] - in /xmlgraphics/fop/trunk: ./ lib/ src/java/org/apache/fop/complexscripts/fonts/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/apps/ src/java/org/apache/fop/fonts/autodetect/ src/java/org/apache/fop/fonts/cff...
Date Wed, 14 Aug 2013 22:35:38 GMT
Author: lbernardo
Date: Wed Aug 14 22:35:37 2013
New Revision: 1514076

URL: http://svn.apache.org/r1514076
Log:
FOP-2252: OpenType CFF support for FOP; patch submitted by Robert Meyer

Added:
    xmlgraphics/fop/trunk/lib/fontbox-1.8.0-SNAPSHOT.jar   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/cff/
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFTableName.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OTFFile.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OpenFont.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFCFFStreamType0C.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/cff/
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/resources/fonts/otf/
    xmlgraphics/fop/trunk/test/resources/fonts/otf/AlexBrushRegular.otf   (with props)
    xmlgraphics/fop/trunk/test/resources/fonts/otf/SourceSansProBold.otf   (with props)
Removed:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFMtxEntry.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFTableName.java
Modified:
    xmlgraphics/fop/trunk/findbugs-exclude.xml
    xmlgraphics/fop/trunk/lib/xmlgraphics-commons-svn-trunk.jar
    xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/GlyfTable.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFile.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFactory.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFontDescriptor.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSPainter.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFTableNameTestCase.java

Modified: xmlgraphics/fop/trunk/findbugs-exclude.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/findbugs-exclude.xml?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/findbugs-exclude.xml (original)
+++ xmlgraphics/fop/trunk/findbugs-exclude.xml Wed Aug 14 22:35:37 2013
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <FindBugsFilter>
   <Match>
-    <Class name="org.apache.fop.fonts.truetype.TTFFile$1"/>
+    <Class name="org.apache.fop.fonts.truetype.OpenFont$1"/>
     <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
   </Match>
   <Match>
@@ -409,6 +409,11 @@
       <Bug pattern="OS_OPEN_STREAM"/>
    </Match>
    <Match>
+      <Class name="org.apache.fop.pdf.PDFFactory"/>
+      <Method name="makeFont"/>
+      <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/>
+   </Match>
+   <Match>
       <Class name="org.apache.fop.pdf.PDFOutputIntent"/>
       <Method name="toPDF"/>
       <Bug pattern="OS_OPEN_STREAM"/>
@@ -834,7 +839,7 @@
       <Bug pattern="BIT_IOR_OF_SIGNED_BYTE"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFDirTabEntry"/>
+      <Class name="org.apache.fop.fonts.truetype.OFDirTabEntry"/>
       <Method name="toString"/>
       <Bug pattern="DMI_INVOKING_TOSTRING_ON_ARRAY"/>
    </Match>
@@ -989,7 +994,7 @@
       <Bug pattern="UWF_UNWRITTEN_FIELD"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFDirTabEntry"/>
+      <Class name="org.apache.fop.fonts.truetype.OFDirTabEntry"/>
       <Field name="checksum"/>
       <Bug pattern="UWF_UNWRITTEN_FIELD"/>
    </Match>
@@ -2143,37 +2148,37 @@
       <Bug pattern="DM_NUMBER_CTOR"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="glyphToUnicode"/>
       <Bug pattern="DM_NUMBER_CTOR"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="initAnsiWidths"/>
       <Bug pattern="DM_NUMBER_CTOR"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="readKerning"/>
       <Bug pattern="DM_NUMBER_CTOR"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="readUnicodeCmap"/>
       <Bug pattern="DM_NUMBER_CTOR"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="unicodeToGlyph"/>
       <Bug pattern="DM_NUMBER_CTOR"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="unicodeToWinAnsi"/>
       <Bug pattern="DM_NUMBER_CTOR"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile$UnicodeMapping"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont$UnicodeMapping"/>
       <Method name="&lt;init&gt;"/>
       <Bug pattern="DM_NUMBER_CTOR"/>
    </Match>
@@ -2623,7 +2628,7 @@
       <Bug pattern="ITA_INEFFICIENT_TO_ARRAY"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="unicodeToWinAnsi"/>
       <Bug pattern="ITA_INEFFICIENT_TO_ARRAY"/>
    </Match>
@@ -2852,7 +2857,7 @@
       <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile$UnicodeMapping"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont$UnicodeMapping"/>
       <!--Neither method nor field-->
       <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS"/>
    </Match>
@@ -2902,7 +2907,7 @@
       <Bug pattern="UPM_UNCALLED_PRIVATE_METHOD"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="printMaxMin"/>
       <Bug pattern="UPM_UNCALLED_PRIVATE_METHOD"/>
    </Match>
@@ -3082,7 +3087,7 @@
       <Bug pattern="WMI_WRONG_MAP_ITERATOR"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="readKerning"/>
       <Bug pattern="WMI_WRONG_MAP_ITERATOR"/>
    </Match>
@@ -3747,7 +3752,7 @@
       <Bug pattern="DLS_DEAD_LOCAL_STORE"/>
    </Match>
    <Match>
-      <Class name="org.apache.fop.fonts.truetype.TTFFile"/>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
       <Method name="readFont"/>
       <Bug pattern="DLS_DEAD_LOCAL_STORE"/>
    </Match>
@@ -5021,7 +5026,7 @@
      <Bug pattern="EI_EXPOSE_REP"/>
    </Match>
    <Match>
-     <Class name="org.apache.fop.fonts.truetype.TTFDirTabEntry"/>
+     <Class name="org.apache.fop.fonts.truetype.OFDirTabEntry"/>
      <Method name="getTag"/>
      <Bug pattern="EI_EXPOSE_REP"/>
    </Match>
@@ -5226,4 +5231,186 @@
      </Or>
      <Bug pattern="BC_UNCONFIRMED_CAST"/>
    </Match>
+   <Match>
+     <Or>
+       <Class name="org.apache.fop.fo.properties.CommonAural"/>
+       <Class name="org.apache.fop.fo.properties.CommonMarginInline"/>
+       <Class name="org.apache.fop.render.pdf.PDFSVGHandler$PDFInfo"/>
+       <Class name="org.apache.fop.fo.properties.CommonRelativePosition"/>
+     </Or>
+     <Or>
+       <Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
+       <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+     </Or>
+   </Match>
+   <Match>
+     <Or>
+        <Class name="org.apache.fop.forms.FormLayoutManagerMakerProvider$CheckBoxLayoutManagerMaker"/>
+        <Class name="org.apache.fop.forms.FormLayoutManagerMakerProvider$ComboBoxLayoutManagerMaker"/>
+        <Class name="org.apache.fop.forms.FormLayoutManagerMakerProvider$InputLayoutManagerMaker"/>
+        <Class name="org.apache.fop.forms.FormLayoutManagerMakerProvider$MultilineInputLayoutManagerMaker"/>
+        <Class name="org.apache.fop.forms.FormLayoutManagerMakerProvider$RadioButtonLayoutManagerMaker"/>
+        <Class name="org.apache.fop.forms.FormLayoutManagerMakerProvider$TriggerLayoutManagerMaker"/>
+        <Class name="org.apache.fop.render.intermediate.IFRenderer$1"/>
+        <Class name="org.apache.fop.render.intermediate.IFRenderer$3"/>
+        <Class name="org.apache.fop.render.intermediate.IFRenderer$4"/>
+        <Class name="org.apache.fop.render.intermediate.IFRenderer$5"/>
+        <Class name="org.apache.fop.render.intermediate.IFRenderer$6"/>
+        <Class name="org.apache.fop.render.pdf.PDFPainter$InputPainter"/>
+        <Class name="org.apache.fop.render.pdf.PDFPainter$MultilineInputPainter"/>
+        <Class name="org.apache.fop.render.pdf.PDFPainter$RadioButtonPainter"/>
+        <Class name="org.apache.fop.render.pdf.PDFPainter$TriggerPainter"/>
+        <Class name="org.apache.fop.render.pdf.PDFPainter$ComboBoxPainter"/>
+        <Class name="org.apache.fop.render.pdf.PDFPainter$CheckboxPainter"/>
+     </Or>
+     <Or>
+        <Bug pattern="BC_UNCONFIRMED_CAST"/>
+        <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/>
+     </Or>
+   </Match>
+   <Match>
+     <Or>
+        <Class name="org.apache.fop.fo.flow.Float"/>
+        <Class name="org.apache.fop.fo.flow.MultiCase"/>
+        <Class name="org.apache.fop.fo.flow.MultiProperties"/>
+        <Class name="org.apache.fop.fo.flow.MultiPropertySet"/>
+        <Class name="org.apache.fop.fo.flow.MultiSwitch"/>
+        <Class name="org.apache.fop.fo.flow.MultiToggle"/>
+        <Class name="org.apache.fop.fo.flow.table.TableAndCaption"/>
+        <Class name="org.apache.fop.fo.flow.table.TableCaption"/>
+        <Class name="org.apache.fop.fonts.apps.AbstractFontReader"/>
+        <Class name="org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement"/>
+     </Or>
+     <Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
+   </Match>
+   <Match>
+     <Or>
+        <Class name="org.apache.fop.pdf.PDFFunction"/>
+        <Class name="org.apache.fop.pdf.PDFGoTo"/>
+        <Class name="org.apache.fop.pdf.PDFLink"/>
+        <Class name="org.apache.fop.pdf.PDFPattern"/>
+        <Class name="org.apache.fop.svg.ACIUtils"/>
+        <Class name="org.apache.fop.svg.PDFTextPainter"/>        
+     </Or>
+     <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+   </Match>
+   <Match>
+     <Or>
+        <Class name="org.apache.fop.area.BodyRegion"/>
+        <Class name="org.apache.fop.area.Page"/>
+        <Class name="org.apache.fop.area.PageViewport"/>
+        <Class name="org.apache.fop.area.RegionReference"/>
+        <Class name="org.apache.fop.area.RegionViewport"/>
+        <Class name="org.apache.fop.hyphenation.CharVector"/>
+        <Class name="org.apache.fop.hyphenation.TernaryTree"/>
+        <Class name="org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes"/>
+     </Or>
+     <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
+   </Match>   
+   <Match>
+     <Or>
+        <Class name="org.apache.fop.forms.CheckBoxArea"/>
+        <Class name="org.apache.fop.forms.ComboBox"/>
+        <Class name="org.apache.fop.forms.RadioButtonArea"/>
+     </Or>
+     <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+   </Match> 
+   <Match>
+     <Or>
+        <Class name="org.apache.fop.layoutmgr.PageBreaker"/>
+        <Class name="org.apache.fop.layoutmgr.BlockContainerLayoutManager"/>
+     </Or>
+     <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
+   </Match>    
+   <Match>
+     <Class name="org.apache.fop.layoutmgr.BlockContainerLayoutManager"/>
+     <Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
+     <Bug pattern="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.apps.io.ResourceResolverFactory$FileDeletingInputStream"/>
+     <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fo.properties.FontFamilyProperty"/>
+     <Bug pattern="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.render.ps.PSImageObject"/>
+     <Or>
+        <Bug pattern="EI_EXPOSE_REP"/>
+        <Bug pattern="EI_EXPOSE_REP2"/>
+     </Or>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.cff.CFFDataReader"/>
+     <Bug pattern="DM_DEFAULT_ENCODING"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.cff.CFFDataReader$CFFIndexData"/>
+     <Or>
+        <Bug pattern="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH"/>
+        <Bug pattern="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW"/>
+     </Or>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.cff.CFFDataReader$CFFSubTable"/>
+     <Or>
+        <Bug pattern="EI_EXPOSE_REP"/>
+        <Bug pattern="EI_EXPOSE_REP2"/>
+     </Or>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.cff.CFFDataReader$DICTEntry"/>
+     <Or>
+        <Bug pattern="EI_EXPOSE_REP"/>
+        <Bug pattern="EI_EXPOSE_REP2"/>
+     </Or>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.truetype.OTFFile"/>
+     <Or>
+        <Bug pattern="ITA_INEFFICIENT_TO_ARRAY"/>
+        <Bug pattern="DM_DEFAULT_ENCODING"/>
+     </Or>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.truetype.OTFSubSetFile"/>
+     <Or>
+        <Bug pattern="ITA_INEFFICIENT_TO_ARRAY"/>
+        <Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/>
+        <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
+        <Bug pattern="DM_DEFAULT_ENCODING"/>
+     </Or>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.truetype.OTFSubSetFile$1"/>
+     <Or>
+         <Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/>
+         <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
+     </Or>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.fonts.truetype.OTFSubSetFile$FDIndexReference"/>
+     <Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.render.ps.PSFontUtils"/>
+     <Bug pattern="DM_DEFAULT_ENCODING"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.forms.IField$Field"/>
+     <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+   </Match>
+   <Match>
+     <Or>
+        <Class name="org.apache.fop.forms.IField$Field"/>
+        <Class name="org.apache.fop.forms.TriggerArea"/>
+        <Class name="org.apache.fop.forms.traits.AdditionalActionTrait"/>
+     </Or>
+     <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+   </Match>
 </FindBugsFilter>

Added: xmlgraphics/fop/trunk/lib/fontbox-1.8.0-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/lib/fontbox-1.8.0-SNAPSHOT.jar?rev=1514076&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/lib/fontbox-1.8.0-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: xmlgraphics/fop/trunk/lib/xmlgraphics-commons-svn-trunk.jar
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/lib/xmlgraphics-commons-svn-trunk.jar?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java Wed Aug 14 22:35:37 2013
@@ -29,9 +29,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.fop.fonts.truetype.FontFileReader;
-import org.apache.fop.fonts.truetype.TTFDirTabEntry;
-import org.apache.fop.fonts.truetype.TTFFile;
-import org.apache.fop.fonts.truetype.TTFTableName;
+import org.apache.fop.fonts.truetype.OFDirTabEntry;
+import org.apache.fop.fonts.truetype.OFTableName;
+import org.apache.fop.fonts.truetype.OpenFont;
 
 // CSOFF: AvoidNestedBlocksCheck
 // CSOFF: NoWhitespaceAfterCheck
@@ -50,7 +50,7 @@ public final class OTFAdvancedTypographi
     // logging state
     private static Log log = LogFactory.getLog(OTFAdvancedTypographicTableReader.class);
     // instance state
-    private TTFFile ttf;                                        // parent font file reader
+    private OpenFont otf;                                        // parent font file reader
     private FontFileReader in;                                  // input reader
     private GlyphDefinitionTable gdef;                          // glyph definition table
     private GlyphSubstitutionTable gsub;                        // glyph substitution table
@@ -68,10 +68,10 @@ public final class OTFAdvancedTypographi
      * @param ttf parent font file reader (must be non-null)
      * @param in font file reader (must be non-null)
      */
-    public OTFAdvancedTypographicTableReader(TTFFile ttf, FontFileReader in) {
-        assert ttf != null;
+    public OTFAdvancedTypographicTableReader(OpenFont otf, FontFileReader in) {
+        assert otf != null;
         assert in != null;
-        this.ttf = ttf;
+        this.otf = otf;
         this.in = in;
     }
 
@@ -127,7 +127,8 @@ public final class OTFAdvancedTypographi
         return gpos;
     }
 
-    private void readLangSysTable(TTFTableName tableTag, long langSysTable, String langSysTag) throws IOException {
+    private void readLangSysTable(OFTableName tableTag, long langSysTable, String langSysTag)
+            throws IOException {
         in.seekSet(langSysTable);
         if (log.isDebugEnabled()) {
             log.debug(tableTag + " lang sys table: " + langSysTag);
@@ -169,7 +170,7 @@ public final class OTFAdvancedTypographi
 
     private static String defaultTag = "dflt";
 
-    private void readScriptTable(TTFTableName tableTag, long scriptTable, String scriptTag) throws IOException {
+    private void readScriptTable(OFTableName tableTag, long scriptTable, String scriptTag) throws IOException {
         in.seekSet(scriptTable);
         if (log.isDebugEnabled()) {
             log.debug(tableTag + " script table: " + scriptTag);
@@ -222,7 +223,7 @@ public final class OTFAdvancedTypographi
         seLanguages = null;
     }
 
-    private void readScriptList(TTFTableName tableTag, long scriptList) throws IOException {
+    private void readScriptList(OFTableName tableTag, long scriptList) throws IOException {
         in.seekSet(scriptList);
         // read script record count
         int ns = in.readTTFUShort();
@@ -251,7 +252,7 @@ public final class OTFAdvancedTypographi
         }
     }
 
-    private void readFeatureTable(TTFTableName tableTag, long featureTable, String featureTag, int featureIndex) throws IOException {
+    private void readFeatureTable(OFTableName tableTag, long featureTable, String featureTag, int featureIndex) throws IOException {
         in.seekSet(featureTable);
         if (log.isDebugEnabled()) {
             log.debug(tableTag + " feature table: " + featureTag);
@@ -279,7 +280,7 @@ public final class OTFAdvancedTypographi
         seFeatures.put("f" + featureIndex, new Object[] { featureTag, lul });
     }
 
-    private void readFeatureList(TTFTableName tableTag, long featureList) throws IOException {
+    private void readFeatureList(OFTableName tableTag, long featureList) throws IOException {
         in.seekSet(featureList);
         // read feature record count
         int nf = in.readTTFUShort();
@@ -1736,28 +1737,28 @@ public final class OTFAdvancedTypographi
         // XPlacement
         int xp;
         if ((valueFormat & GlyphPositioningTable.Value.X_PLACEMENT) != 0) {
-            xp = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            xp = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
         } else {
             xp = 0;
         }
         // YPlacement
         int yp;
         if ((valueFormat & GlyphPositioningTable.Value.Y_PLACEMENT) != 0) {
-            yp = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            yp = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
         } else {
             yp = 0;
         }
         // XAdvance
         int xa;
         if ((valueFormat & GlyphPositioningTable.Value.X_ADVANCE) != 0) {
-            xa = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            xa = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
         } else {
             xa = 0;
         }
         // YAdvance
         int ya;
         if ((valueFormat & GlyphPositioningTable.Value.Y_ADVANCE) != 0) {
-            ya = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            ya = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
         } else {
             ya = 0;
         }
@@ -2029,23 +2030,23 @@ public final class OTFAdvancedTypographi
         int af = in.readTTFUShort();
         if (af == 1) {
             // read x coordinate
-            int x = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            int x = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
             // read y coordinate
-            int y = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            int y = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
             a = new GlyphPositioningTable.Anchor(x, y);
         } else if (af == 2) {
             // read x coordinate
-            int x = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            int x = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
             // read y coordinate
-            int y = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            int y = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
             // read anchor point index
             int ap = in.readTTFUShort();
             a = new GlyphPositioningTable.Anchor(x, y, ap);
         } else if (af == 3) {
             // read x coordinate
-            int x = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            int x = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
             // read y coordinate
-            int y = ttf.convertTTFUnit2PDFUnit(in.readTTFShort());
+            int y = otf.convertTTFUnit2PDFUnit(in.readTTFShort());
             // read x device table offset
             int xdo = in.readTTFUShort();
             // read y device table offset
@@ -3145,9 +3146,9 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readLookupTable(TTFTableName tableTag, int lookupSequence, long lookupTable) throws IOException {
-        boolean isGSUB = tableTag.equals(TTFTableName.GSUB);
-        boolean isGPOS = tableTag.equals(TTFTableName.GPOS);
+    private void readLookupTable(OFTableName tableTag, int lookupSequence, long lookupTable) throws IOException {
+        boolean isGSUB = tableTag.equals(OFTableName.GSUB);
+        boolean isGPOS = tableTag.equals(OFTableName.GPOS);
         in.seekSet(lookupTable);
         // read lookup type
         int lt = in.readTTFUShort();
@@ -3198,7 +3199,7 @@ public final class OTFAdvancedTypographi
         }
     }
 
-    private void readLookupList(TTFTableName tableTag, long lookupList) throws IOException {
+    private void readLookupList(OFTableName tableTag, long lookupList) throws IOException {
         in.seekSet(lookupList);
         // read lookup record count
         int nl = in.readTTFUShort();
@@ -3233,7 +3234,7 @@ public final class OTFAdvancedTypographi
      * @param lookupList offset to lookup list from beginning of font file
      * @throws IOException In case of a I/O problem
      */
-    private void readCommonLayoutTables(TTFTableName tableTag, long scriptList, long featureList, long lookupList) throws IOException {
+    private void readCommonLayoutTables(OFTableName tableTag, long scriptList, long featureList, long lookupList) throws IOException {
         if (scriptList > 0) {
             readScriptList(tableTag, scriptList);
         }
@@ -3245,7 +3246,7 @@ public final class OTFAdvancedTypographi
         }
     }
 
-    private void readGDEFClassDefTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFClassDefTable(OFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // subtable is a bare class definition table
@@ -3257,7 +3258,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFAttachmentTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFAttachmentTable(OFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // read coverage offset
@@ -3275,7 +3276,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFLigatureCaretTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFLigatureCaretTable(OFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // read coverage offset
@@ -3305,7 +3306,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFMarkAttachmentTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFMarkAttachmentTable(OFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // subtable is a bare class definition table
@@ -3317,7 +3318,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFMarkGlyphsTableFormat1(TTFTableName tableTag, int lookupSequence, long subtableOffset, int subtableFormat) throws IOException {
+    private void readGDEFMarkGlyphsTableFormat1(OFTableName tableTag, int lookupSequence, long subtableOffset, int subtableFormat) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // skip over format (already known)
@@ -3351,7 +3352,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFMarkGlyphsTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFMarkGlyphsTable(OFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         in.seekSet(subtableOffset);
         // read mark set subtable format
         int sf = in.readTTFUShort();
@@ -3367,17 +3368,17 @@ public final class OTFAdvancedTypographi
      * @throws IOException In case of a I/O problem
      */
     private void readGDEF() throws IOException {
-        TTFTableName tableTag = TTFTableName.GDEF;
+        OFTableName tableTag = OFTableName.GDEF;
         // Initialize temporary state
         initATState();
         // Read glyph definition (GDEF) table
-        TTFDirTabEntry dirTab = ttf.getDirectoryEntry(tableTag);
+        OFDirTabEntry dirTab = otf.getDirectoryEntry(tableTag);
         if (gdef != null) {
             if (log.isDebugEnabled()) {
                 log.debug(tableTag + ": ignoring duplicate table");
             }
         } else if (dirTab != null) {
-            ttf.seekTab(in, tableTag, 0);
+            otf.seekTab(in, tableTag, 0);
             long version = in.readTTFULong();
             if (log.isDebugEnabled()) {
                 log.debug(tableTag + " version: " + (version / 65536) + "." + (version % 65536));
@@ -3440,17 +3441,17 @@ public final class OTFAdvancedTypographi
      * @throws IOException In case of a I/O problem
      */
     private void readGSUB() throws IOException {
-        TTFTableName tableTag = TTFTableName.GSUB;
+        OFTableName tableTag = OFTableName.GSUB;
         // Initialize temporary state
         initATState();
         // Read glyph substitution (GSUB) table
-        TTFDirTabEntry dirTab = ttf.getDirectoryEntry(tableTag);
+        OFDirTabEntry dirTab = otf.getDirectoryEntry(tableTag);
         if (gpos != null) {
             if (log.isDebugEnabled()) {
                 log.debug(tableTag + ": ignoring duplicate table");
             }
         } else if (dirTab != null) {
-            ttf.seekTab(in, tableTag, 0);
+            otf.seekTab(in, tableTag, 0);
             int version = in.readTTFLong();
             if (log.isDebugEnabled()) {
                 log.debug(tableTag + " version: " + (version / 65536) + "." + (version % 65536));
@@ -3477,17 +3478,17 @@ public final class OTFAdvancedTypographi
      * @throws IOException In case of a I/O problem
      */
     private void readGPOS() throws IOException {
-        TTFTableName tableTag = TTFTableName.GPOS;
+        OFTableName tableTag = OFTableName.GPOS;
         // Initialize temporary state
         initATState();
         // Read glyph positioning (GPOS) table
-        TTFDirTabEntry dirTab = ttf.getDirectoryEntry(tableTag);
+        OFDirTabEntry dirTab = otf.getDirectoryEntry(tableTag);
         if (gpos != null) {
             if (log.isDebugEnabled()) {
                 log.debug(tableTag + ": ignoring duplicate table");
             }
         } else if (dirTab != null) {
-            ttf.seekTab(in, tableTag, 0);
+            otf.seekTab(in, tableTag, 0);
             int version = in.readTTFLong();
             if (log.isDebugEnabled()) {
                 log.debug(tableTag + " version: " + (version / 65536) + "." + (version % 65536));

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java Wed Aug 14 22:35:37 2013
@@ -26,7 +26,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.fonts.truetype.TTFFontLoader;
+import org.apache.fop.fonts.truetype.OFFontLoader;
 import org.apache.fop.fonts.type1.Type1FontLoader;
 
 /**
@@ -105,7 +105,7 @@ public abstract class FontLoader {
             }
             loader = new Type1FontLoader(fontFileURI, embedded, useKerning, resourceResolver);
         } else {
-            loader = new TTFFontLoader(fontFileURI, subFontName, embedded, embeddingMode,
+            loader = new OFFontLoader(fontFileURI, subFontName, embedded, embeddingMode,
                     encodingMode, useKerning, useAdvanced, resourceResolver);
         }
         return loader.getFont();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java Wed Aug 14 22:35:37 2013
@@ -22,6 +22,7 @@ package org.apache.fop.fonts;
 import java.nio.CharBuffer;
 import java.nio.IntBuffer;
 import java.util.BitSet;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
@@ -67,6 +68,15 @@ public class MultiByteFont extends CIDFo
     private int firstUnmapped;
     private int lastUnmapped;
 
+    private boolean isOTFFile = false;
+
+    // since for most users the most likely glyphs are in the first cmap segments we store their mapping.
+    private static final int NUM_MOST_LIKELY_GLYPHS = 256;
+    private int[] mostLikelyGlyphs = new int[NUM_MOST_LIKELY_GLYPHS];
+
+    //A map to store each used glyph from the CID set against the glyph name.
+    private LinkedHashMap<Integer, String> usedGlyphNames = new LinkedHashMap<Integer, String>();
+
     /**
      * Default constructor
      */
@@ -111,6 +121,14 @@ public class MultiByteFont extends CIDFo
         return cidType;
     }
 
+    public void setIsOTFFile(boolean isOTFFile) {
+        this.isOTFFile = isOTFFile;
+    }
+
+    public boolean isOTFFile() {
+        return this.isOTFFile;
+    }
+
     /**
      * Sets the CIDType.
      * @param cidType The cidType to set
@@ -147,6 +165,14 @@ public class MultiByteFont extends CIDFo
         return this.cidSet;
     }
 
+    public void mapUsedGlyphName(int gid, String value) {
+        usedGlyphNames.put(gid, value);
+    }
+
+    public LinkedHashMap<Integer, String> getUsedGlyphNames() {
+        return usedGlyphNames;
+    }
+
     /** {@inheritDoc} */
     @Override
     public String getEncodingName() {
@@ -177,10 +203,15 @@ public class MultiByteFont extends CIDFo
      * @return the glyph index (or 0 if the glyph is not available)
      */
     // [TBD] - needs optimization, i.e., change from linear search to binary search
-    private int findGlyphIndex(int c) {
+    public int findGlyphIndex(int c) {
         int idx = c;
         int retIdx = SingleByteEncoding.NOT_FOUND_CODE_POINT;
 
+        // for most users the most likely glyphs are in the first cmap segments (meaning the one with
+        // the lowest unicode start values)
+        if (idx < NUM_MOST_LIKELY_GLYPHS && mostLikelyGlyphs[idx] != 0) {
+            return mostLikelyGlyphs[idx];
+        }
         for (int i = 0; (i < cmap.length) && retIdx == 0; i++) {
             if (cmap[i].getUnicodeStart() <= idx
                     && cmap[i].getUnicodeEnd() >= idx) {
@@ -188,6 +219,9 @@ public class MultiByteFont extends CIDFo
                 retIdx = cmap[i].getGlyphStartIndex()
                     + idx
                     - cmap[i].getUnicodeStart();
+                if (idx < NUM_MOST_LIKELY_GLYPHS) {
+                    mostLikelyGlyphs[idx] = retIdx;
+                }
             }
         }
         return retIdx;
@@ -281,22 +315,6 @@ public class MultiByteFont extends CIDFo
         return findCharacterFromGlyphIndex(gi, true);
     }
 
-
-    /** {@inheritDoc} */
-    @Override
-    public char mapChar(char c) {
-        notifyMapOperation();
-        int glyphIndex = findGlyphIndex(c);
-        if (glyphIndex == SingleByteEncoding.NOT_FOUND_CODE_POINT) {
-            warnMissingGlyph(c);
-            glyphIndex = findGlyphIndex(Typeface.NOT_FOUND);
-        }
-        if (isEmbeddable()) {
-            glyphIndex = cidSet.mapChar(glyphIndex, c);
-        }
-        return (char) glyphIndex;
-    }
-
     protected BitSet getGlyphIndices() {
         BitSet bitset = new BitSet();
         bitset.set(0);
@@ -329,6 +347,23 @@ public class MultiByteFont extends CIDFo
 
     /** {@inheritDoc} */
     @Override
+    public char mapChar(char c) {
+        notifyMapOperation();
+        int glyphIndex = findGlyphIndex(c);
+        if (glyphIndex == SingleByteEncoding.NOT_FOUND_CODE_POINT) {
+            warnMissingGlyph(c);
+            if (!isOTFFile) {
+                glyphIndex = findGlyphIndex(Typeface.NOT_FOUND);
+            }
+        }
+        if (isEmbeddable()) {
+            glyphIndex = cidSet.mapChar(glyphIndex, c);
+        }
+        return (char) glyphIndex;
+    }
+
+    /** {@inheritDoc} */
+    @Override
     public boolean hasChar(char c) {
         return (findGlyphIndex(c) != SingleByteEncoding.NOT_FOUND_CODE_POINT);
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java Wed Aug 14 22:35:37 2013
@@ -32,7 +32,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.xmlgraphics.fonts.Glyphs;
 
 import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.fonts.truetype.TTFFile.PostScriptVersion;
+import org.apache.fop.fonts.truetype.OpenFont.PostScriptVersion;
 
 /**
  * Generic SingleByte font

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java Wed Aug 14 22:35:37 2013
@@ -38,6 +38,7 @@ import org.apache.fop.Version;
 import org.apache.fop.fonts.CMapSegment;
 import org.apache.fop.fonts.FontUtil;
 import org.apache.fop.fonts.truetype.FontFileReader;
+import org.apache.fop.fonts.truetype.OFFontLoader;
 import org.apache.fop.fonts.truetype.TTFFile;
 
 // CSOFF: InnerAssignmentCheck
@@ -216,7 +217,8 @@ public class TTFReader extends AbstractF
         InputStream stream = new FileInputStream(fileName);
         try {
             FontFileReader reader = new FontFileReader(stream);
-            boolean supported = ttfFile.readFont(reader, fontName);
+            String header = OFFontLoader.readHeader(reader);
+            boolean supported = ttfFile.readFont(reader, header, fontName);
             if (!supported) {
                 return null;
             }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java Wed Aug 14 22:35:37 2013
@@ -43,8 +43,8 @@ import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.fonts.FontUtil;
 import org.apache.fop.fonts.MultiByteFont;
 import org.apache.fop.fonts.truetype.FontFileReader;
+import org.apache.fop.fonts.truetype.OFFontLoader;
 import org.apache.fop.fonts.truetype.TTFFile;
-import org.apache.fop.fonts.truetype.TTFFontLoader;
 
 /**
  * Attempts to determine correct FontInfo
@@ -220,7 +220,7 @@ public class FontInfoFinder {
                     log.debug("Loading " + fontName);
                 }
                 try {
-                    TTFFontLoader ttfLoader = new TTFFontLoader(fontURI, fontName, true,
+                    OFFontLoader ttfLoader = new OFFontLoader(fontURI, fontName, true,
                             EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, useAdvanced,
                             resourceResolver);
                     customFont = ttfLoader.getFont();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/GlyfTable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/GlyfTable.java?rev=1514076&r1=1514075&r2=1514076&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/GlyfTable.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/GlyfTable.java Wed Aug 14 22:35:37 2013
@@ -31,7 +31,7 @@ import java.util.TreeSet;
  */
 public class GlyfTable {
 
-    private final TTFMtxEntry[] mtxTab;
+    private final OFMtxEntry[] mtxTab;
 
     private final long tableOffset;
 
@@ -47,7 +47,7 @@ public class GlyfTable {
     /** All the glyphs that are composed, but do not appear in the subset. */
     private Set<Integer> composedGlyphs = new TreeSet<Integer>();
 
-    GlyfTable(FontFileReader in, TTFMtxEntry[] metrics, TTFDirTabEntry dirTableEntry,
+    GlyfTable(FontFileReader in, OFMtxEntry[] metrics, OFDirTabEntry dirTableEntry,
             Map<Integer, Integer> glyphs) throws IOException {
         mtxTab = metrics;
         tableOffset = dirTableEntry.getOffset();

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java?rev=1514076&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java Wed Aug 14 22:35:37 2013
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts.truetype;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+
+/**
+ * This class represents an entry to a TrueType font's Dir Tab.
+ */
+public class OFDirTabEntry {
+
+    private byte[] tag = new byte[4];
+    private int checksum;
+    private long offset;
+    private long length;
+
+    public OFDirTabEntry() {
+    }
+
+    public OFDirTabEntry(long offset, long length) {
+        this.offset = offset;
+        this.length = length;
+    }
+
+    /**
+     * Read Dir Tab.
+     * @param in font file reader
+     * @return tag name
+     * @throws IOException upon I/O exception
+     */
+    public String read(FontFileReader in) throws IOException {
+        tag[0] = in.readTTFByte();
+        tag[1] = in.readTTFByte();
+        tag[2] = in.readTTFByte();
+        tag[3] = in.readTTFByte();
+
+        in.skip(4);    // Skip checksum
+
+        offset = in.readTTFULong();
+        length = in.readTTFULong();
+        String tagStr = new String(tag, "ISO-8859-1");
+
+        return tagStr;
+    }
+
+
+    @Override
+    public String toString() {
+        return "Read dir tab ["
+            + tag[0] + " " + tag[1] + " " + tag[2] + " " + tag[3] + "]"
+            + " offset: " + offset
+            + " length: " + length
+            + " name: " + tag;
+    }
+
+    /**
+     * Returns the checksum.
+     * @return int
+     */
+    public int getChecksum() {
+        return checksum;
+    }
+
+    /**
+     * Returns the length.
+     * @return long
+     */
+    public long getLength() {
+        return length;
+    }
+
+    /**
+     * Returns the offset.
+     * @return long
+     */
+    public long getOffset() {
+        return offset;
+    }
+
+    /**
+     * Returns the tag bytes.
+     * @return byte[]
+     */
+    public byte[] getTag() {
+        return tag;
+    }
+
+    /**
+     * Returns the tag bytes.
+     * @return byte[]
+     */
+    public String getTagString() {
+        try {
+            return new String(tag, "ISO-8859-1");
+        } catch (UnsupportedEncodingException e) {
+            return this.toString(); // Should never happen.
+        }
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java?rev=1514076&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java Wed Aug 14 22:35:37 2013
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts.truetype;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.fonts.CIDFontType;
+import org.apache.fop.fonts.CMapSegment;
+import org.apache.fop.fonts.EmbeddingMode;
+import org.apache.fop.fonts.EncodingMode;
+import org.apache.fop.fonts.FontLoader;
+import org.apache.fop.fonts.FontType;
+import org.apache.fop.fonts.MultiByteFont;
+import org.apache.fop.fonts.NamedCharacter;
+import org.apache.fop.fonts.SingleByteFont;
+import org.apache.fop.fonts.truetype.OpenFont.PostScriptVersion;
+import org.apache.fop.util.HexEncoder;
+
+/**
+ * Loads a TrueType font into memory directly from the original font file.
+ */
+public class OFFontLoader extends FontLoader {
+
+    private MultiByteFont multiFont;
+    private SingleByteFont singleFont;
+    private final String subFontName;
+    private EncodingMode encodingMode;
+    private EmbeddingMode embeddingMode;
+
+    /**
+     * Default constructor
+     * @param fontFileURI the URI representing the font file
+     * @param resourceResolver the resource resolver for font URI resolution
+     */
+    public OFFontLoader(URI fontFileURI, InternalResourceResolver resourceResolver) {
+        this(fontFileURI, null, true, EmbeddingMode.AUTO, EncodingMode.AUTO, true, true, resourceResolver);
+    }
+
+    /**
+     * Additional constructor for TrueType Collections.
+     * @param fontFileURI the URI representing the font file
+     * @param subFontName the sub-fontname of a font in a TrueType Collection (or null for normal
+     *          TrueType fonts)
+     * @param embedded indicates whether the font is embedded or referenced
+     * @param embeddingMode the embedding mode of the font
+     * @param encodingMode the requested encoding mode
+     * @param useKerning true to enable loading kerning info if available, false to disable
+     * @param useAdvanced true to enable loading advanced info if available, false to disable
+     * @param resolver the FontResolver for font URI resolution
+     */
+    public OFFontLoader(URI fontFileURI, String subFontName, boolean embedded,
+            EmbeddingMode embeddingMode, EncodingMode encodingMode, boolean useKerning,
+            boolean useAdvanced, InternalResourceResolver resolver) {
+        super(fontFileURI, embedded, useKerning, useAdvanced, resolver);
+        this.subFontName = subFontName;
+        this.encodingMode = encodingMode;
+        this.embeddingMode = embeddingMode;
+        if (this.encodingMode == EncodingMode.AUTO) {
+            this.encodingMode = EncodingMode.CID; //Default to CID mode for TrueType
+        }
+        if (this.embeddingMode == EmbeddingMode.AUTO) {
+            this.embeddingMode = EmbeddingMode.SUBSET;
+        }
+    }
+
+    /** {@inheritDoc} */
+    protected void read() throws IOException {
+        read(this.subFontName);
+    }
+
+    /**
+     * Reads a TrueType font.
+     * @param ttcFontName the TrueType sub-font name of TrueType Collection (may be null for
+     *    normal TrueType fonts)
+     * @throws IOException if an I/O error occurs
+     */
+    private void read(String ttcFontName) throws IOException {
+        InputStream in = resourceResolver.getResource(this.fontFileURI);
+        try {
+            FontFileReader reader = new FontFileReader(in);
+            String header = readHeader(reader);
+            boolean isCFF = header.equals("OTTO");
+            OpenFont otf = (isCFF) ? new OTFFile() : new TTFFile(useKerning, useAdvanced);
+            boolean supported = otf.readFont(reader, header, ttcFontName);
+            if (!supported) {
+                throw new IOException("The font does not have a Unicode cmap table: " + fontFileURI);
+            }
+            buildFont(otf, ttcFontName);
+            loaded = true;
+        } finally {
+            IOUtils.closeQuietly(in);
+        }
+    }
+
+    public static String readHeader(FontFileReader fontFile) throws IOException {
+        if (fontFile != null) {
+            fontFile.seekSet(0);
+            return fontFile.readTTFString(4); // TTF_FIXED_SIZE (4 bytes)
+        }
+        return null;
+    }
+
+    private void buildFont(OpenFont otf, String ttcFontName) {
+        boolean isCid = this.embedded;
+        if (this.encodingMode == EncodingMode.SINGLE_BYTE) {
+            isCid = false;
+        }
+
+        if (isCid) {
+            multiFont = new MultiByteFont(resourceResolver, embeddingMode);
+            multiFont.setIsOTFFile(otf instanceof OTFFile);
+            returnFont = multiFont;
+            multiFont.setTTCName(ttcFontName);
+        } else {
+            singleFont = new SingleByteFont(resourceResolver);
+            returnFont = singleFont;
+        }
+
+        returnFont.setFontName(otf.getPostScriptName());
+        returnFont.setFullName(otf.getFullName());
+        returnFont.setFamilyNames(otf.getFamilyNames());
+        returnFont.setFontSubFamilyName(otf.getSubFamilyName());
+        returnFont.setCapHeight(otf.getCapHeight());
+        returnFont.setXHeight(otf.getXHeight());
+        returnFont.setAscender(otf.getLowerCaseAscent());
+        returnFont.setDescender(otf.getLowerCaseDescent());
+        returnFont.setFontBBox(otf.getFontBBox());
+        returnFont.setFlags(otf.getFlags());
+        returnFont.setStemV(Integer.parseInt(otf.getStemV())); //not used for TTF
+        returnFont.setItalicAngle(Integer.parseInt(otf.getItalicAngle()));
+        returnFont.setMissingWidth(0);
+        returnFont.setWeight(otf.getWeightClass());
+        returnFont.setEmbeddingMode(this.embeddingMode);
+        if (isCid) {
+            if (otf instanceof OTFFile) {
+                multiFont.setCIDType(CIDFontType.CIDTYPE0);
+            } else {
+                multiFont.setCIDType(CIDFontType.CIDTYPE2);
+            }
+            int[] wx = otf.getWidths();
+            multiFont.setWidthArray(wx);
+        } else {
+            singleFont.setFontType(FontType.TRUETYPE);
+            singleFont.setEncoding(otf.getCharSetName());
+            returnFont.setFirstChar(otf.getFirstChar());
+            returnFont.setLastChar(otf.getLastChar());
+            singleFont.setTrueTypePostScriptVersion(otf.getPostScriptVersion());
+            copyWidthsSingleByte(otf);
+        }
+        returnFont.setCMap(getCMap(otf));
+
+        if (otf.getKerning() != null && useKerning) {
+            copyKerning(otf, isCid);
+        }
+        if (useAdvanced) {
+            copyAdvanced(otf);
+        }
+        if (this.embedded) {
+            if (otf.isEmbeddable()) {
+                returnFont.setEmbedURI(this.fontFileURI);
+            } else {
+                String msg = "The font " + this.fontFileURI + " is not embeddable due to a"
+                        + " licensing restriction.";
+                throw new RuntimeException(msg);
+            }
+        }
+    }
+
+    private CMapSegment[] getCMap(OpenFont otf) {
+        CMapSegment[] array = new CMapSegment[otf.getCMaps().size()];
+        return otf.getCMaps().toArray(array);
+    }
+
+    private void copyWidthsSingleByte(OpenFont otf) {
+        int[] wx = otf.getWidths();
+        for (int i = singleFont.getFirstChar(); i <= singleFont.getLastChar(); i++) {
+            singleFont.setWidth(i, otf.getCharWidth(i));
+        }
+
+        for (CMapSegment segment : otf.getCMaps()) {
+            if (segment.getUnicodeStart() < 0xFFFE) {
+                for (char u = (char)segment.getUnicodeStart(); u <= segment.getUnicodeEnd(); u++) {
+                    int codePoint = singleFont.getEncoding().mapChar(u);
+                    if (codePoint <= 0) {
+                        int glyphIndex = segment.getGlyphStartIndex() + u - segment.getUnicodeStart();
+                        String glyphName = otf.getGlyphName(glyphIndex);
+                        if (glyphName.length() == 0 && otf.getPostScriptVersion() != PostScriptVersion.V2) {
+                            glyphName = "u" + HexEncoder.encode(u);
+                        }
+                        if (glyphName.length() > 0) {
+                            String unicode = Character.toString(u);
+                            NamedCharacter nc = new NamedCharacter(glyphName, unicode);
+                            singleFont.addUnencodedCharacter(nc, wx[glyphIndex]);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Copy kerning information.
+     */
+    private void copyKerning(OpenFont otf, boolean isCid) {
+
+        // Get kerning
+        Set<Integer> kerningSet;
+        if (isCid) {
+            kerningSet = otf.getKerning().keySet();
+        } else {
+            kerningSet = otf.getAnsiKerning().keySet();
+        }
+
+        for (Integer kpx1 : kerningSet) {
+            Map<Integer, Integer> h2;
+            if (isCid) {
+                h2 = otf.getKerning().get(kpx1);
+            } else {
+                h2 = otf.getAnsiKerning().get(kpx1);
+            }
+            returnFont.putKerningEntry(kpx1, h2);
+        }
+    }
+
+    /**
+     * Copy advanced typographic information.
+     */
+    private void copyAdvanced(OpenFont otf) {
+        if (returnFont instanceof MultiByteFont) {
+            MultiByteFont mbf = (MultiByteFont) returnFont;
+            mbf.setGDEF(otf.getGDEF());
+            mbf.setGSUB(otf.getGSUB());
+            mbf.setGPOS(otf.getGPOS());
+        }
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFFontLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java?rev=1514076&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java Wed Aug 14 22:35:37 2013
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts.truetype;
+
+import java.util.List;
+
+/**
+ * This class represents a TrueType Mtx Entry.
+ */
+class OFMtxEntry {
+
+    private int wx;
+    private int lsb;
+    private String name = "";
+    private int index;
+    private List unicodeIndex = new java.util.ArrayList();
+    private int[] boundingBox = new int[4];
+    private long offset;
+    private byte found = 0;
+
+    /**
+     * Returns a String representation of this object.
+     *
+     * @param t TTFFile to use for unit conversion
+     * @return String String representation
+     */
+    public String toString(TTFFile t) {
+        return "Glyph " + name + " index: " + getIndexAsString() + " bbox ["
+             + t.convertTTFUnit2PDFUnit(boundingBox[0]) + " "
+             + t.convertTTFUnit2PDFUnit(boundingBox[1]) + " "
+             + t.convertTTFUnit2PDFUnit(boundingBox[2]) + " "
+             + t.convertTTFUnit2PDFUnit(boundingBox[3]) + "] wx: "
+             + t.convertTTFUnit2PDFUnit(wx);
+    }
+
+    /**
+     * Returns the boundingBox.
+     * @return int[]
+     */
+    public int[] getBoundingBox() {
+        return boundingBox;
+    }
+
+    /**
+     * Sets the boundingBox.
+     * @param boundingBox The boundingBox to set
+     */
+    public void setBoundingBox(int[] boundingBox) {
+        this.boundingBox = boundingBox;
+    }
+
+    /**
+     * Returns the found.
+     * @return byte
+     */
+    public byte getFound() {
+        return found;
+    }
+
+    /**
+     * Returns the index.
+     * @return int
+     */
+    public int getIndex() {
+        return index;
+    }
+
+    /**
+     * Determines whether this index represents a reserved character.
+     * @return True if it is reserved
+     */
+    public boolean isIndexReserved() {
+        return (getIndex() >= 32768) && (getIndex() <= 65535);
+    }
+
+    /**
+     * Returns a String representation of the index taking into account if
+     * the index is in the reserved range.
+     * @return index as String
+     */
+    public String getIndexAsString() {
+        if (isIndexReserved()) {
+            return Integer.toString(getIndex()) + " (reserved)";
+        } else {
+            return Integer.toString(getIndex());
+        }
+    }
+
+    /**
+     * Returns the lsb.
+     * @return int
+     */
+    public int getLsb() {
+        return lsb;
+    }
+
+    /**
+     * Returns the name.
+     * @return String
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Returns the offset.
+     * @return long
+     */
+    public long getOffset() {
+        return offset;
+    }
+
+    /**
+     * Returns the unicodeIndex.
+     * @return List
+     */
+    public List getUnicodeIndex() {
+        return unicodeIndex;
+    }
+
+    /**
+     * Returns the wx.
+     * @return int
+     */
+    public int getWx() {
+        return wx;
+    }
+
+    /**
+     * Sets the found.
+     * @param found The found to set
+     */
+    public void setFound(byte found) {
+        this.found = found;
+    }
+
+    /**
+     * Sets the index.
+     * @param index The index to set
+     */
+    public void setIndex(int index) {
+        this.index = index;
+    }
+
+    /**
+     * Sets the lsb.
+     * @param lsb The lsb to set
+     */
+    public void setLsb(int lsb) {
+        this.lsb = lsb;
+    }
+
+    /**
+     * Sets the name.
+     * @param name The name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * Sets the offset.
+     * @param offset The offset to set
+     */
+    public void setOffset(long offset) {
+        this.offset = offset;
+    }
+
+    /**
+     * Sets the wx.
+     * @param wx The wx to set
+     */
+    public void setWx(int wx) {
+        this.wx = wx;
+    }
+
+
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFTableName.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFTableName.java?rev=1514076&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFTableName.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFTableName.java Wed Aug 14 22:35:37 2013
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts.truetype;
+
+
+/**
+ * Represents table names as found in a TrueType font's Table Directory.
+ * TrueType fonts may have custom tables so we cannot use an enum.
+ */
+public final class OFTableName {
+
+    /** The first table in a TrueType font file containing metadata about other tables. */
+    public static final OFTableName TABLE_DIRECTORY = new OFTableName("tableDirectory");
+
+    /** Baseline data */
+    public static final OFTableName BASE = new OFTableName("BASE");
+
+    /** CFF data/ */
+    public static final OFTableName CFF = new OFTableName("CFF ");
+
+    /** Embedded bitmap data. */
+    public static final OFTableName EBDT = new OFTableName("EBDT");
+
+    /** Embedded bitmap location data. */
+    public static final OFTableName EBLC = new OFTableName("EBLC");
+
+    /** Embedded bitmap scaling data. */
+    public static final OFTableName EBSC = new OFTableName("EBSC");
+
+    /** A FontForge specific table. */
+    public static final OFTableName FFTM = new OFTableName("FFTM");
+
+    /** Divides glyphs into various classes that make using the GPOS/GSUB tables easier. */
+    public static final OFTableName GDEF = new OFTableName("GDEF");
+
+    /** Provides kerning information, mark-to-base, etc. for opentype fonts. */
+    public static final OFTableName GPOS = new OFTableName("GPOS");
+
+    /** Provides ligature information, swash, etc. for opentype fonts. */
+    public static final OFTableName GSUB = new OFTableName("GSUB");
+
+    /** Linear threshold table. */
+    public static final OFTableName LTSH = new OFTableName("LTSH");
+
+    /** OS/2 and Windows specific metrics. */
+    public static final OFTableName OS2 = new OFTableName("OS/2");
+
+    /** PCL 5 data. */
+    public static final OFTableName PCLT = new OFTableName("PCLT");
+
+    /** Vertical Device Metrics table. */
+    public static final OFTableName VDMX = new OFTableName("VDMX");
+
+    /** Character to glyph mapping. */
+    public static final OFTableName CMAP = new OFTableName("cmap");
+
+    /** Control Value Table. */
+    public static final OFTableName CVT = new OFTableName("cvt ");
+
+    /** Font program. */
+    public static final OFTableName FPGM = new OFTableName("fpgm");
+
+    /** Grid-fitting and scan conversion procedure (grayscale). */
+    public static final OFTableName GASP = new OFTableName("gasp");
+
+    /** Glyph data. */
+    public static final OFTableName GLYF = new OFTableName("glyf");
+
+    /** Horizontal device metrics. */
+    public static final OFTableName HDMX = new OFTableName("hdmx");
+
+    /** Font header. */
+    public static final OFTableName HEAD = new OFTableName("head");
+
+    /** Horizontal header. */
+    public static final OFTableName HHEA = new OFTableName("hhea");
+
+    /** Horizontal metrics. */
+    public static final OFTableName HMTX = new OFTableName("hmtx");
+
+    /** Kerning. */
+    public static final OFTableName KERN = new OFTableName("kern");
+
+    /** Index to location. */
+    public static final OFTableName LOCA = new OFTableName("loca");
+
+    /** Maximum profile. */
+    public static final OFTableName MAXP = new OFTableName("maxp");
+
+    /** Naming table. */
+    public static final OFTableName NAME = new OFTableName("name");
+
+    /** PostScript information. */
+    public static final OFTableName POST = new OFTableName("post");
+
+    /** CVT Program. */
+    public static final OFTableName PREP = new OFTableName("prep");
+
+    /** Vertical Metrics header. */
+    public static final OFTableName VHEA = new OFTableName("vhea");
+
+    /** Vertical Metrics. */
+    public static final OFTableName VMTX = new OFTableName("vmtx");
+
+    private final String name;
+
+    private OFTableName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of the table as it should be in the Directory Table.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Returns an instance of this class corresponding to the given string representation.
+     * @param tableName table name as in the Table Directory
+     * @return TTFTableName
+     */
+    public static OFTableName getValue(String tableName) {
+        if (tableName != null) {
+            return new OFTableName(tableName);
+        }
+        throw new IllegalArgumentException("A TrueType font table name must not be null");
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == this) {
+            return true;
+        }
+        if (!(o instanceof OFTableName)) {
+            return false;
+        }
+        OFTableName to = (OFTableName) o;
+        return this.name.equals(to.getName());
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OFTableName.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OTFFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OTFFile.java?rev=1514076&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OTFFile.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OTFFile.java Wed Aug 14 22:35:37 2013
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts.truetype;
+
+import java.io.IOException;
+
+import org.apache.fontbox.cff.CFFDataInput;
+import org.apache.fontbox.cff.CFFFont;
+import org.apache.fontbox.cff.CFFFont.Mapping;
+import org.apache.fontbox.cff.CFFParser;
+
+public class OTFFile extends OpenFont {
+
+    protected CFFFont fileFont;
+
+    public OTFFile() throws IOException {
+        checkForFontbox();
+    }
+
+    private void checkForFontbox() throws IOException {
+        try {
+            Class.forName("org.apache.fontbox.cff.CFFFont");
+        } catch (ClassNotFoundException ex) {
+            throw new IOException("The Fontbox jar was not found in the classpath. This is "
+                                   + "required for OTF CFF ssupport.");
+        }
+    }
+
+    @Override
+    protected void updateBBoxAndOffset() throws IOException {
+        UnicodeMapping[] mappings = unicodeMappings.toArray(new UnicodeMapping[0]);
+        for (int i = 0; i < mappings.length; i++) {
+            int glyphIdx = mappings[i].getGlyphIndex();
+            Mapping m = fileFont.getGIDMappings().get(glyphIdx);
+            int[] bbox = fileFont.getBoundingBox(m.getSID());
+            String name = fileFont.getNameOfCharFromCode(m.getSID());
+            mtxTab[glyphIdx].setBoundingBox(bbox);
+            mtxTab[glyphIdx].setName(name);
+        }
+    }
+
+    @Override
+    protected void initializeFont(FontFileReader in) throws IOException {
+        fontFile = in;
+        fontFile.seekSet(0);
+        CFFParser parser = new CFFParser();
+        fileFont = parser.parse(in.getAllBytes()).get(0);
+    }
+
+    protected void readName() throws IOException {
+        Object familyName = fileFont.getProperty("FamilyName");
+        if (familyName != null && !familyName.equals("")) {
+            familyNames.add(familyName.toString());
+            fullName = familyName.toString();
+        } else {
+            fullName = fileFont.getName();
+            familyNames.add(fullName);
+        }
+    }
+
+    /**
+     * Reads the CFFData from a given font file
+     * @param fontFile The font file being read
+     * @return The byte data found in the CFF table
+     */
+    public static byte[] getCFFData(FontFileReader fontFile) throws IOException {
+        byte[] cff = new byte[0];
+        CFFDataInput input = new CFFDataInput(fontFile.getAllBytes());
+        input.readBytes(4); //OTTO
+        short numTables = input.readShort();
+        input.readShort(); //searchRange
+        input.readShort(); //entrySelector
+        input.readShort(); //rangeShift
+
+        for (int q = 0; q < numTables; q++) {
+            String tagName = new String(input.readBytes(4));
+            readLong(input); //Checksum
+            long offset = readLong(input);
+            long length = readLong(input);
+            if (tagName.equals("CFF ")) {
+                cff = new byte[(int)length];
+                System.arraycopy(fontFile.getAllBytes(), (int)offset, cff, 0, cff.length);
+                break;
+            }
+        }
+        return cff;
+    }
+
+    private static long readLong(CFFDataInput input) throws IOException {
+        return (input.readCard16() << 16) | input.readCard16();
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/OTFFile.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



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


Mime
View raw message