Changeset 205 for trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java
- Timestamp:
- 03/20/08 03:55:24 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java
r197 r205 31 31 import org.apache.log4j.Logger; 32 32 import org.docx4j.fonts.Substituter; 33 import org.docx4j.fonts.FontUtils; 33 34 import org.docx4j.jaxb.Context; 34 35 import org.docx4j.openpackaging.contenttype.ContentType; … … 445 446 Substituter.FontMapping fm = (Substituter.FontMapping)pairs.getValue(); 446 447 447 log.info("Substituting " + fontName + " with " + fm.getP ostScriptName() + " from " + fm.getEmbeddedFile() );448 if (fm.get EmbeddedFile()!=null) {448 log.info("Substituting " + fontName + " with " + fm.getPhysicalFont().getFamilyName() + " from " + fm.getPhysicalFont().getEmbeddedFile() ); 449 if (fm.getPhysicalFont()!=null) { 449 450 try { 450 if (fm.get EmbeddedFile().endsWith(".pfb")) {451 if (fm.getPhysicalFont().getEmbeddedFile().endsWith(".pfb")) { 451 452 452 String afm = fm.getEmbeddedFile().substring(5, fm.getEmbeddedFile().length()-4 ) + ".afm"; // drop the 'file:' 453 // String afm = fm.getPhysicalFont().getEmbeddedFile().substring(5, fm.getPhysicalFont().getEmbeddedFile().length()-4 ) + ".afm"; // drop the 'file:' 454 String afm = FontUtils.pathFromURL(fm.getPhysicalFont().getEmbeddedFile()); 455 afm = afm.substring(0, afm.length()-4 ) + ".afm"; // drop the 'file:' 453 456 log.info("Looking for: " + afm); 454 457 … … 457 460 if (f.exists()) { 458 461 log.info("Got it"); 459 renderer.getFontResolver().addFont(afm, BaseFont.CP1252, true, fm.getEmbeddedFile().substring(5)); // drop the 'file:'462 renderer.getFontResolver().addFont(afm, BaseFont.CP1252, true, FontUtils.pathFromURL(fm.getPhysicalFont().getEmbeddedFile())); // drop the 'file:' 460 463 } else { 461 464 // Should we be doing afm first, or pfm? 462 String pfm = fm.getEmbeddedFile().substring(5, fm.getEmbeddedFile().length()-4 ) + ".pfm"; // drop the 'file:' 465 String pfm = FontUtils.pathFromURL(fm.getPhysicalFont().getEmbeddedFile()); 466 pfm = pfm.substring(0, pfm.length()-4 ) + ".pfm"; // drop the 'file:' 463 467 log.info("Looking for: " + pfm); 464 468 f = new File(pfm); 465 469 if (f.exists()) { 466 470 log.info("Got it"); 467 renderer.getFontResolver().addFont(pfm, BaseFont.CP1252, true, fm.getEmbeddedFile().substring(5)); // drop the 'file:'471 renderer.getFontResolver().addFont(pfm, BaseFont.CP1252, true, FontUtils.pathFromURL(fm.getPhysicalFont().getEmbeddedFile() )); // drop the 'file:' 468 472 } else { 469 473 // Shouldn't happen. 470 log.error("Couldn't find afm or pfm corresponding to " + fm.get EmbeddedFile());474 log.error("Couldn't find afm or pfm corresponding to " + fm.getPhysicalFont().getEmbeddedFile()); 471 475 } 472 476 } 473 } else { 474 renderer.getFontResolver().addFont(fm.getEmbeddedFile(), true); 477 } else { 478 479 renderer.getFontResolver().addFont(FontUtils.pathFromURL(fm.getPhysicalFont().getEmbeddedFile()), true); 475 480 } 476 481 } catch (java.io.IOException e) { … … 485 490 */ 486 491 e.printStackTrace(); 487 log.warn("Shouldn't happen - should have been detected upstream ... " + e.getMessage() + ": " + fm.get EmbeddedFile());492 log.warn("Shouldn't happen - should have been detected upstream ... " + e.getMessage() + ": " + fm.getPhysicalFont().getEmbeddedFile()); 488 493 } catch (Exception e) { 489 494 e.printStackTrace();
Note: See TracChangeset
for help on using the changeset viewer.
