Changeset 876


Ignore:
Timestamp:
08/23/09 23:26:07 (2 years ago)
Author:
jharrop
Message:

Make it easier to use non-patched fop.jar

Location:
trunk/docx4j
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/pom.xml

    r834 r876  
    208208                        mvn deploy:deploy-file -f wagon-svn-pom.xml -Dfile=lib/xalan-2.7.0-patched-6396599-stripped.jar -DgroupId=xalan -DartifactId=xalan-patched -Dversion=2.7.0 -Dpackaging=jar -DrepositoryId=docx4j -Durl=svn:http://dev.plutext.org/svn/docx4j/trunk/docx4j/m2 
    209209                         
    210                          
     210                         mvn deploy:deploy-file -f wagon-svn-pom.xml -Dfile=../fop/tmp/fop-patched.jar -DgroupId=docx4j -DartifactId=fop-patched -Dversion=0.95.756436 -Dpackaging=jar -DrepositoryId=docx4j -Durl=svn:http://dev.plutext.org/svn/docx4j/trunk/docx4j/m2 
    211211                --> 
    212212 
     
    286286                        <groupId>docx4j</groupId> 
    287287                        <artifactId>fop-patched</artifactId> 
    288                         <version>0.95.756434</version> 
    289                 </dependency> 
     288                        <version>0.95.756436</version> 
     289                </dependency> 
     290                        <!--  its really 95.756434, but i had to re-build it to remove 
     291                              Class-Path from the MANIFEST.MF, which was  
     292                              being used by Java Web Start to try to fetch certain 
     293                              jars. So the number is incremented (0.95.756435). 
     294                              And then, Panose.java moved to original foray package (0.95.756436) --> 
     295 
    290296 
    291297<!--  
  • trunk/docx4j/src/main/java/org/docx4j/fonts/BestMatchingMapper.java

    r871 r876  
    2020package org.docx4j.fonts; 
    2121 
    22 import java.io.File; 
    23 import java.net.URL; 
    24 import java.util.Collections; 
    2522import java.util.HashMap; 
    2623import java.util.Iterator; 
     
    2926 
    3027import javax.xml.bind.JAXBContext; 
    31 import javax.xml.bind.JAXBException; 
    3228import javax.xml.bind.Unmarshaller; 
    3329 
    34 import org.apache.fop.fonts.EmbedFontInfo; 
    35 import org.apache.fop.fonts.FontCache; 
    36 import org.apache.fop.fonts.FontResolver; 
    37 import org.apache.fop.fonts.FontSetup; 
    38 import org.apache.fop.fonts.FontTriplet; 
    39 import org.apache.fop.fonts.autodetect.FontFileFinder; 
    40 import org.apache.fop.fonts.autodetect.FontInfoFinder; 
    4130import org.apache.log4j.Logger; 
    4231import org.docx4j.fonts.microsoft.MicrosoftFonts; 
    4332import org.docx4j.fonts.substitutions.FontSubstitutions; 
    44 import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
    4533import org.docx4j.openpackaging.packages.WordprocessingMLPackage; 
    4634import org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart; 
    47 import org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart; 
    4835import org.docx4j.wml.Fonts; 
    49  
    50 import com.lowagie.text.pdf.BaseFont; 
    5136 
    5237/** 
     
    267252                                wmlFontPanoseForDocumentFont = font.getPanose1(); 
    268253                        } 
    269                         org.apache.fop.fonts.Panose documentFontPanose = null; 
     254                        org.foray.font.format.Panose documentFontPanose = null; 
    270255                        if (wmlFontPanoseForDocumentFont!=null && wmlFontPanoseForDocumentFont.getVal()!=null ) { 
    271256                                try { 
    272                                         documentFontPanose = org.apache.fop.fonts.Panose.makeInstance(wmlFontPanoseForDocumentFont.getVal() ); 
     257                                        documentFontPanose = org.foray.font.format.Panose.makeInstance(wmlFontPanoseForDocumentFont.getVal() ); 
    273258                                } catch (IllegalArgumentException e) {                                   
    274259                                        log.error(e.getMessage()); 
     
    302287                                                                 
    303288                                // Is the Panose value valid? 
    304                                 if (log.isDebugEnabled() &&  org.apache.fop.fonts.Panose.validPanose(documentFontPanose.getPanoseArray())!=null) {                                                                                                               
     289                                if (log.isDebugEnabled() &&  org.foray.font.format.Panose.validPanose(documentFontPanose.getPanoseArray())!=null) {                                                                                                              
    305290                                        // NB org.apache.fop.fonts.Panose only exists in our patched FOP 
    306                                         log.debug(documentFontName + " : " + org.apache.fop.fonts.Panose.validPanose(documentFontPanose.getPanoseArray()));                                      
     291                                        log.debug(documentFontName + " : " + org.foray.font.format.Panose.validPanose(documentFontPanose.getPanoseArray()));                                     
    307292                                        //This is the case for 'Impact' which has  
    308293                                        //Invalid value 9 > 8 in position 5 of 2 11 8 6 3 9 2 5 2 4  
     
    427412                                                        log.debug(".. as expected, lacking Panose");                                     
    428413                                                } else if (documentFontPanose!=null  ) { 
    429                                                         org.apache.fop.fonts.Panose physicalFontPanose = null; 
     414                                                        org.foray.font.format.Panose physicalFontPanose = null; 
    430415                                                        try { 
    431                                                                 physicalFontPanose = org.apache.fop.fonts.Panose.makeInstance(fontMatched 
     416                                                                physicalFontPanose = org.foray.font.format.Panose.makeInstance(fontMatched 
    432417                                                                                                .getPanose() 
    433418                                                                                                .getPanoseArray()); 
     
    493478         * @param soughtPanose 
    494479         */ 
    495         private PhysicalFont getAssociatedPhysicalFont(String documentFontName, String orignalKey, org.apache.fop.fonts.Panose soughtPanose) { 
     480        private PhysicalFont getAssociatedPhysicalFont(String documentFontName, String orignalKey, org.foray.font.format.Panose soughtPanose) { 
    496481 
    497482                log.debug("Looking for " + soughtPanose); 
     
    538523                 
    539524                Returns key of matching font in physicalFontMap. */ 
    540         private String findClosestPanoseMatch(String documentFontName, org.apache.fop.fonts.Panose documentFontPanose,  
     525        private String findClosestPanoseMatch(String documentFontName, org.foray.font.format.Panose documentFontPanose,  
    541526                        Map<String, PhysicalFont> physicalFontSpace, int matchThreshold) { 
    542527                 
     
    564549                        continue; 
    565550                } 
    566                         org.apache.fop.fonts.Panose physicalFontPanose = null; 
     551                        org.foray.font.format.Panose physicalFontPanose = null; 
    567552                long panoseMatchValue = MATCH_THRESHOLD + 1; // inititaliase to a non-match 
    568553                        try { 
    569                                 physicalFontPanose = org.apache.fop.fonts.Panose.makeInstance(physicalFont.getPanose().getPanoseArray() ); 
     554                                physicalFontPanose = org.foray.font.format.Panose.makeInstance(physicalFont.getPanose().getPanoseArray() ); 
    570555                        panoseMatchValue = documentFontPanose.difference(physicalFontPanose, null); 
    571556                        } catch (IllegalArgumentException e) {                                   
     
    711696                        PhysicalFont pf = (PhysicalFont)pairs.getValue(); 
    712697                         
    713                         org.apache.fop.fonts.Panose fopPanose = pf.getPanose(); 
     698                        org.foray.font.format.Panose fopPanose = pf.getPanose(); 
    714699                         
    715700                                if (fopPanose == null ) { 
  • trunk/docx4j/src/main/java/org/docx4j/fonts/IdentityPlusMapper.java

    r712 r876  
    2020package org.docx4j.fonts; 
    2121 
    22 import java.io.File; 
    23 import java.net.URL; 
    24 import java.util.Collections; 
    25 import java.util.HashMap; 
    2622import java.util.Iterator; 
    27 import java.util.List; 
    2823import java.util.Map; 
    2924 
    30 import javax.xml.bind.JAXBContext; 
    31 import javax.xml.bind.JAXBException; 
    32 import javax.xml.bind.Unmarshaller; 
    33  
    34 import org.apache.fop.fonts.EmbedFontInfo; 
    35 import org.apache.fop.fonts.FontCache; 
    36 import org.apache.fop.fonts.FontResolver; 
    37 import org.apache.fop.fonts.FontSetup; 
    38 import org.apache.fop.fonts.FontTriplet; 
    39 import org.apache.fop.fonts.autodetect.FontFileFinder; 
    40 import org.apache.fop.fonts.autodetect.FontInfoFinder; 
    4125import org.apache.log4j.Logger; 
    42 import org.docx4j.fonts.microsoft.MicrosoftFonts; 
    43 import org.docx4j.fonts.substitutions.FontSubstitutions; 
    44 import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
    4526import org.docx4j.openpackaging.packages.WordprocessingMLPackage; 
    4627import org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart; 
    47 import org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart; 
    48 import org.docx4j.wml.Fonts; 
    49  
    50 import com.lowagie.text.pdf.BaseFont; 
    5128 
    5229/** 
  • trunk/docx4j/src/main/java/org/docx4j/fonts/PhysicalFont.java

    r712 r876  
    66import org.apache.fop.fonts.EmbedFontInfo; 
    77import org.apache.log4j.Logger; 
    8 import org.docx4j.convert.out.pdf.viaXSLFO.Conversion; 
    98 
    109/** 
     
    3130        PhysicalFont(String name, EmbedFontInfo embedFontInfo) { 
    3231                 
    33                 // Sanity check 
    34                 if (embedFontInfo.getPostScriptName()==null) { 
    35                         log.error("Not set!"); 
    36                         //log.error(((org.apache.fop.fonts.FontTriplet)fontInfo.getFontTriplets().get(0)).getName()); 
     32                try { 
     33                        // Sanity check 
     34                        if (embedFontInfo.getPostScriptName()==null) { 
     35                                log.error("Not set!"); 
     36                                //log.error(((org.apache.fop.fonts.FontTriplet)fontInfo.getFontTriplets().get(0)).getName()); 
     37                        } 
     38                } catch (Exception e1) { 
     39                        // NB getPanose() only exists in our patched FOP 
     40                        if (!loggedWarningAlready) { 
     41                                log.warn("Not using patched FOP; getPostScriptName() method missing."); 
     42                                loggedWarningAlready = true; 
     43                        }                                                        
    3744                } 
    3845                 
     
    4451         
    4552//      setName(fontInfo.getPostScriptName()); 
    46         setEmbeddedFile(embedFontInfo.getEmbedFile()); 
    47         setPanose(embedFontInfo.getPanose());            
     53         
     54                setEmbeddedFile(embedFontInfo.getEmbedFile()); 
     55        try { 
     56                setPanose(embedFontInfo.getPanose());            
     57                } catch (Exception e) { 
     58                        // NB getPanose() only exists in our patched FOP 
     59                        if (!loggedWarningAlready) { 
     60                                log.warn("Not using patched FOP; getPanose() method missing."); 
     61                                loggedWarningAlready = true; 
     62                        }                                                        
     63                } 
    4864        } 
     65         
     66        private static boolean loggedWarningAlready = false; 
    4967         
    5068        // postscript name eg  
     
    8199        } 
    82100         
    83         org.apache.fop.fonts.Panose panose; 
    84         public org.apache.fop.fonts.Panose getPanose() { 
     101        org.foray.font.format.Panose panose; 
     102        public org.foray.font.format.Panose getPanose() { 
    85103                return panose; 
    86104        } 
    87         public void setPanose(org.apache.fop.fonts.Panose panose) { 
     105        public void setPanose(org.foray.font.format.Panose panose) { 
    88106                this.panose = panose; 
    89107        } 
  • trunk/docx4j/src/main/java/org/docx4j/fonts/PhysicalFonts.java

    r731 r876  
    99 
    1010import org.apache.fop.fonts.EmbedFontInfo; 
    11 import org.apache.fop.fonts.EncodingMode; 
    1211import org.apache.fop.fonts.FontCache; 
    1312import org.apache.fop.fonts.FontResolver; 
     
    1918import org.docx4j.fonts.microsoft.MicrosoftFonts; 
    2019import org.docx4j.fonts.microsoft.MicrosoftFontsRegistry; 
    21 import org.docx4j.openpackaging.packages.WordprocessingMLPackage; 
    22 import org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart; 
    2320import org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart; 
    2421 
    25 import com.lowagie.text.DocumentException; 
    2622import com.lowagie.text.pdf.BaseFont; 
    2723 
     
    146142        } 
    147143 
     144        private static boolean loggedWarningAlready = false; 
     145         
    148146        /** 
    149147         * Add a physical font's EmbedFontInfo object. 
     
    155153                //List<EmbedFontInfo> embedFontInfoList = fontInfoFinder.find(fontUrl, fontResolver, fontCache);                 
    156154                EmbedFontInfo[] embedFontInfoList = fontInfoFinder.find(fontUrl, fontResolver, fontCache); 
     155                /* FOP r644208 (Bugzilla #44737) 3/04/08 made this an array, 
     156                // so if you are using non-patched FOP, it needs to be at least this revision 
     157                // (but doesn't seem to be in FOP 0.95 binary?!) */  
    157158                 
    158159                if (embedFontInfoList==null) { 
     
    206207                         
    207208                        debug.append("------- \n"); 
    208                         debug.append(fontInfo.getPostScriptName() + "\n" ); 
    209                          
    210                          if (!fontInfo.isEmbeddable() ) {                                        
    211         //                      log.info(tokens[x] + " is not embeddable; skipping."); 
    212                                   
    213                                         // NB isEmbeddable() only exists in our patched FOP 
    214                                  
    215                                         /* 
    216                                          * No point looking at this font, since if we tried to use it, 
    217                                          * later, we'd get: 
    218                                          *   
    219                                          * com.lowagie.text.DocumentException: file:/usr/share/fonts/truetype/ttf-tamil-fonts/lohit_ta.ttf cannot be embedded due to licensing restrictions. 
    220                                                 at com.lowagie.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:364) 
    221                                                 at com.lowagie.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:335) 
    222                                                 at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:399) 
    223                                                 at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:345) 
    224                                                 at org.xhtmlrenderer.pdf.ITextFontResolver.addFont(ITextFontResolver.java:164) 
    225                                                  
    226                                                 will be thrown if os_2.fsType == 2 
    227                                                  
    228                                          */ 
    229                                 log.warn(fontInfo.getEmbedFile() + " is not embeddable; ignoring this font."); 
    230                                   
    231                                  //return; 
    232                         continue; 
    233                          } 
     209                         
     210                         try { 
     211                                debug.append(fontInfo.getPostScriptName() + "\n" ); 
     212                                if (!fontInfo.isEmbeddable() ) {                                         
     213//                      log.info(tokens[x] + " is not embeddable; skipping."); 
     214                                          
     215                                                /* 
     216                                                 * No point looking at this font, since if we tried to use it, 
     217                                                 * later, we'd get: 
     218                                                 *   
     219                                                 * com.lowagie.text.DocumentException: file:/usr/share/fonts/truetype/ttf-tamil-fonts/lohit_ta.ttf cannot be embedded due to licensing restrictions. 
     220                                                        at com.lowagie.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:364) 
     221                                                        at com.lowagie.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:335) 
     222                                                        at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:399) 
     223                                                        at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:345) 
     224                                                        at org.xhtmlrenderer.pdf.ITextFontResolver.addFont(ITextFontResolver.java:164) 
     225                                                         
     226                                                        will be thrown if os_2.fsType == 2 
     227                                                         
     228                                                 */ 
     229                                        log.warn(fontInfo.getEmbedFile() + " is not embeddable; ignoring this font."); 
     230                                          
     231                                         //return; 
     232                                    continue; 
     233                                 } 
     234                        } catch (Exception e1) { 
     235                                // NB isEmbeddable() only exists in our patched FOP 
     236                                if (!loggedWarningAlready) { 
     237                                        log.warn("Not using patched FOP; isEmbeddable() method missing."); 
     238                                        loggedWarningAlready = true; 
     239                                }                                
     240                        } 
    234241                                 
    235242                        PhysicalFont pf;  
Note: See TracChangeset for help on using the changeset viewer.