Changeset 876
- Timestamp:
- 08/23/09 23:26:07 (2 years ago)
- Location:
- trunk/docx4j
- Files:
-
- 4 added
- 5 edited
-
pom.xml (modified) (2 diffs)
-
src/main/java/org/docx4j/fonts/BestMatchingMapper.java (modified) (9 diffs)
-
src/main/java/org/docx4j/fonts/IdentityPlusMapper.java (modified) (1 diff)
-
src/main/java/org/docx4j/fonts/PhysicalFont.java (modified) (4 diffs)
-
src/main/java/org/docx4j/fonts/PhysicalFonts.java (modified) (5 diffs)
-
src/main/java/org/foray (added)
-
src/main/java/org/foray/font (added)
-
src/main/java/org/foray/font/format (added)
-
src/main/java/org/foray/font/format/Panose.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/pom.xml
r834 r876 208 208 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 209 209 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 211 211 --> 212 212 … … 286 286 <groupId>docx4j</groupId> 287 287 <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 290 296 291 297 <!-- -
trunk/docx4j/src/main/java/org/docx4j/fonts/BestMatchingMapper.java
r871 r876 20 20 package org.docx4j.fonts; 21 21 22 import java.io.File;23 import java.net.URL;24 import java.util.Collections;25 22 import java.util.HashMap; 26 23 import java.util.Iterator; … … 29 26 30 27 import javax.xml.bind.JAXBContext; 31 import javax.xml.bind.JAXBException;32 28 import javax.xml.bind.Unmarshaller; 33 29 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;41 30 import org.apache.log4j.Logger; 42 31 import org.docx4j.fonts.microsoft.MicrosoftFonts; 43 32 import org.docx4j.fonts.substitutions.FontSubstitutions; 44 import org.docx4j.openpackaging.exceptions.InvalidFormatException;45 33 import org.docx4j.openpackaging.packages.WordprocessingMLPackage; 46 34 import org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart; 47 import org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart;48 35 import org.docx4j.wml.Fonts; 49 50 import com.lowagie.text.pdf.BaseFont;51 36 52 37 /** … … 267 252 wmlFontPanoseForDocumentFont = font.getPanose1(); 268 253 } 269 org. apache.fop.fonts.Panose documentFontPanose = null;254 org.foray.font.format.Panose documentFontPanose = null; 270 255 if (wmlFontPanoseForDocumentFont!=null && wmlFontPanoseForDocumentFont.getVal()!=null ) { 271 256 try { 272 documentFontPanose = org. apache.fop.fonts.Panose.makeInstance(wmlFontPanoseForDocumentFont.getVal() );257 documentFontPanose = org.foray.font.format.Panose.makeInstance(wmlFontPanoseForDocumentFont.getVal() ); 273 258 } catch (IllegalArgumentException e) { 274 259 log.error(e.getMessage()); … … 302 287 303 288 // 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) { 305 290 // 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())); 307 292 //This is the case for 'Impact' which has 308 293 //Invalid value 9 > 8 in position 5 of 2 11 8 6 3 9 2 5 2 4 … … 427 412 log.debug(".. as expected, lacking Panose"); 428 413 } else if (documentFontPanose!=null ) { 429 org. apache.fop.fonts.Panose physicalFontPanose = null;414 org.foray.font.format.Panose physicalFontPanose = null; 430 415 try { 431 physicalFontPanose = org. apache.fop.fonts.Panose.makeInstance(fontMatched416 physicalFontPanose = org.foray.font.format.Panose.makeInstance(fontMatched 432 417 .getPanose() 433 418 .getPanoseArray()); … … 493 478 * @param soughtPanose 494 479 */ 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) { 496 481 497 482 log.debug("Looking for " + soughtPanose); … … 538 523 539 524 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, 541 526 Map<String, PhysicalFont> physicalFontSpace, int matchThreshold) { 542 527 … … 564 549 continue; 565 550 } 566 org. apache.fop.fonts.Panose physicalFontPanose = null;551 org.foray.font.format.Panose physicalFontPanose = null; 567 552 long panoseMatchValue = MATCH_THRESHOLD + 1; // inititaliase to a non-match 568 553 try { 569 physicalFontPanose = org. apache.fop.fonts.Panose.makeInstance(physicalFont.getPanose().getPanoseArray() );554 physicalFontPanose = org.foray.font.format.Panose.makeInstance(physicalFont.getPanose().getPanoseArray() ); 570 555 panoseMatchValue = documentFontPanose.difference(physicalFontPanose, null); 571 556 } catch (IllegalArgumentException e) { … … 711 696 PhysicalFont pf = (PhysicalFont)pairs.getValue(); 712 697 713 org. apache.fop.fonts.Panose fopPanose = pf.getPanose();698 org.foray.font.format.Panose fopPanose = pf.getPanose(); 714 699 715 700 if (fopPanose == null ) { -
trunk/docx4j/src/main/java/org/docx4j/fonts/IdentityPlusMapper.java
r712 r876 20 20 package org.docx4j.fonts; 21 21 22 import java.io.File;23 import java.net.URL;24 import java.util.Collections;25 import java.util.HashMap;26 22 import java.util.Iterator; 27 import java.util.List;28 23 import java.util.Map; 29 24 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;41 25 import 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;45 26 import org.docx4j.openpackaging.packages.WordprocessingMLPackage; 46 27 import 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;51 28 52 29 /** -
trunk/docx4j/src/main/java/org/docx4j/fonts/PhysicalFont.java
r712 r876 6 6 import org.apache.fop.fonts.EmbedFontInfo; 7 7 import org.apache.log4j.Logger; 8 import org.docx4j.convert.out.pdf.viaXSLFO.Conversion;9 8 10 9 /** … … 31 30 PhysicalFont(String name, EmbedFontInfo embedFontInfo) { 32 31 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 } 37 44 } 38 45 … … 44 51 45 52 // 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 } 48 64 } 65 66 private static boolean loggedWarningAlready = false; 49 67 50 68 // postscript name eg … … 81 99 } 82 100 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() { 85 103 return panose; 86 104 } 87 public void setPanose(org. apache.fop.fonts.Panose panose) {105 public void setPanose(org.foray.font.format.Panose panose) { 88 106 this.panose = panose; 89 107 } -
trunk/docx4j/src/main/java/org/docx4j/fonts/PhysicalFonts.java
r731 r876 9 9 10 10 import org.apache.fop.fonts.EmbedFontInfo; 11 import org.apache.fop.fonts.EncodingMode;12 11 import org.apache.fop.fonts.FontCache; 13 12 import org.apache.fop.fonts.FontResolver; … … 19 18 import org.docx4j.fonts.microsoft.MicrosoftFonts; 20 19 import org.docx4j.fonts.microsoft.MicrosoftFontsRegistry; 21 import org.docx4j.openpackaging.packages.WordprocessingMLPackage;22 import org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart;23 20 import org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart; 24 21 25 import com.lowagie.text.DocumentException;26 22 import com.lowagie.text.pdf.BaseFont; 27 23 … … 146 142 } 147 143 144 private static boolean loggedWarningAlready = false; 145 148 146 /** 149 147 * Add a physical font's EmbedFontInfo object. … … 155 153 //List<EmbedFontInfo> embedFontInfoList = fontInfoFinder.find(fontUrl, fontResolver, fontCache); 156 154 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?!) */ 157 158 158 159 if (embedFontInfoList==null) { … … 206 207 207 208 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 } 234 241 235 242 PhysicalFont pf;
Note: See TracChangeset
for help on using the changeset viewer.
