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

Make it easier to use non-patched fop.jar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.