- Timestamp:
- 03/20/08 03:55:24 (4 years ago)
- Location:
- trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages
- Files:
-
- 2 edited
-
WordprocessingMLPackage.java (modified) (4 diffs)
-
wordml2html-2007.xslt (modified) (1 diff)
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(); -
trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/wordml2html-2007.xslt
r204 r205 2650 2650 <xsl:choose> 2651 2651 <xsl:when test="count(../w:b)=1 and count(../w:i)=1"> 2652 <!-- 'BoldItalic' is iText magic string --> 2652 2653 <xsl:variable name="targetFont" 2653 2654 select="java:org.docx4j.fonts.Substituter.getSubstituteFontXsltExtension($substituterInstance, 2654 string($documentFont), ' bolditalic', boolean($fontFamilyStack))" />2655 string($documentFont), 'BoldItalic', boolean($fontFamilyStack))" /> 2655 2656 font-family:'<xsl:value-of select="$targetFont"/>'; 2656 2657 </xsl:when> 2657 2658 <xsl:when test="count(../w:b)=1"> 2659 <!-- 'Bold' is iText magic string --> 2658 2660 <xsl:variable name="targetFont" 2659 2661 select="java:org.docx4j.fonts.Substituter.getSubstituteFontXsltExtension($substituterInstance, 2660 string($documentFont), ' bold', boolean($fontFamilyStack))" />2662 string($documentFont), 'Bold', boolean($fontFamilyStack))" /> 2661 2663 font-family:'<xsl:value-of select="$targetFont"/>'; 2662 2664 </xsl:when> 2663 2665 <xsl:when test="count(../w:i)=1"> 2666 <!-- 'Italic' is iText magic string --> 2664 2667 <xsl:variable name="targetFont" 2665 2668 select="java:org.docx4j.fonts.Substituter.getSubstituteFontXsltExtension($substituterInstance, 2666 string($documentFont), ' italic', boolean($fontFamilyStack))" />2669 string($documentFont), 'Italic', boolean($fontFamilyStack))" /> 2667 2670 font-family:'<xsl:value-of select="$targetFont"/>'; 2668 2671 </xsl:when>
Note: See TracChangeset
for help on using the changeset viewer.
