Ignore:
Timestamp:
03/23/09 03:20:06 (3 years ago)
Author:
jharrop
Message:

Mainly, createPdf demo which creates a document containing all fonts discovered on the system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java

    r708 r715  
    3636import org.apache.log4j.Logger; 
    3737import org.docx4j.convert.out.xmlPackage.XmlPackage; 
     38import org.docx4j.fonts.BestMatchingMapper; 
    3839import org.docx4j.fonts.Mapper; 
    3940import org.docx4j.fonts.FontUtils; 
     
    257258                throw new IllegalArgumentException("Font Substituter cannot be null."); 
    258259        } 
     260                fontMapper = fm; 
     261                org.docx4j.wml.Fonts fonts = null; 
     262 
    259263                // 1.  Get a list of all the fonts in the document 
    260264                java.util.Map fontsInUse = this.getMainDocumentPart().fontsInUse(); 
    261265                 
    262                 // 2.  For each font, find the closest match on the system (use OO's VCL.xcu to do this) 
    263                 //     - do this in a general way, since docx4all needs this as well to display fonts            
    264                 fontMapper = fm; 
    265                 org.docx4j.wml.Fonts fonts = null; 
    266                 FontTablePart fontTablePart= this.getMainDocumentPart().getFontTablePart();      
    267                  
    268                 if (fontTablePart==null) { 
    269                         log.warn("FontTable missing; creating default part."); 
    270                         fontTablePart= new org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart(); 
    271                         fontTablePart.unmarshalDefaultFonts(); 
    272                         fontTablePart.processEmbeddings(); 
    273                 } 
    274                  
    275                 fonts = (org.docx4j.wml.Fonts)fontTablePart.getJaxbElement(); 
     266                if ( fm instanceof BestMatchingMapper ) { 
     267                         
     268                         
     269                        // 2.  For each font, find the closest match on the system (use OO's VCL.xcu to do this) 
     270                        //     - do this in a general way, since docx4all needs this as well to display fonts            
     271                        FontTablePart fontTablePart= this.getMainDocumentPart().getFontTablePart();      
     272                         
     273                        if (fontTablePart==null) { 
     274                                log.warn("FontTable missing; creating default part."); 
     275                                fontTablePart= new org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart(); 
     276                                fontTablePart.unmarshalDefaultFonts(); 
     277                                fontTablePart.processEmbeddings(); 
     278                        } 
     279                         
     280                        fonts = (org.docx4j.wml.Fonts)fontTablePart.getJaxbElement(); 
     281                } 
     282                 
    276283                fontMapper.populateFontMappings(fontsInUse, fonts);      
    277284         
Note: See TracChangeset for help on using the changeset viewer.