]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Merged changes from trunk
authorSimon Pepping <spepping@apache.org>
Sun, 28 Nov 2010 18:55:54 +0000 (18:55 +0000)
committerSimon Pepping <spepping@apache.org>
Sun, 28 Nov 2010 18:55:54 +0000 (18:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ComplexScripts@1039922 13f79535-47bb-0310-9956-ffa450edef68

18 files changed:
1  2 
src/java/org/apache/fop/fonts/CustomFont.java
src/java/org/apache/fop/fonts/EmbedFontInfo.java
src/java/org/apache/fop/fonts/Font.java
src/java/org/apache/fop/fonts/FontInfoConfigurator.java
src/java/org/apache/fop/fonts/FontManagerConfigurator.java
src/java/org/apache/fop/fonts/FontReader.java
src/java/org/apache/fop/fonts/LazyFont.java
src/java/org/apache/fop/fonts/MultiByteFont.java
src/java/org/apache/fop/fonts/MutableFont.java
src/java/org/apache/fop/fonts/Typeface.java
src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
src/java/org/apache/fop/fonts/truetype/TTFFile.java
src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
src/java/org/apache/fop/render/afp/AFPPainter.java
src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
test/layoutengine/disabled-testcases.xml

index a018bcbbbdba41c8d3b9734b7dd9b5268d586678,4432fccefeb1919708d2552d895a82a64f122985..c6b43fe9845e938f6ffe559b10709794752f6076
@@@ -55,10 -57,9 +57,10 @@@ public abstract class CustomFont extend
      private int firstChar = 0;
      private int lastChar = 255;
  
-     private Map kerning;
+     private Map<Integer, Map<Integer, Integer>> kerning;
  
      private boolean useKerning = true;
 +    private boolean useAdvanced = true;
  
      /** {@inheritDoc} */
      public String getFontName() {
index 37b348e880aa3a09898d48dac8b03d1242115c0d,b53cdfdd687e6708069edf47a7e89b9a37a283c5..7cc0eb265069f4cd4daba2875c2a3ec837aa07c2
@@@ -54,15 -52,14 +54,15 @@@ public class EmbedFontInfo implements S
  
      /**
       * Main constructor
 -     * @param metricsFile Path to the xml file containing font metrics
 -     * @param kerning True if kerning should be enabled
 -     * @param fontTriplets List of font triplets to associate with this font
 -     * @param embedFile Path to the embeddable font file (may be null)
 +     * @param metricsFile path to the xml file containing font metrics
 +     * @param kerning true if kerning should be enabled
 +     * @param advanced true if advanced typography features should be enabled
 +     * @param fontTriplets list of font triplets to associate with this font
 +     * @param embedFile path to the embeddable font file (may be null)
       * @param subFontName the sub-fontname used for TrueType Collections (null otherwise)
       */
 -    public EmbedFontInfo(String metricsFile, boolean kerning,
 +    public EmbedFontInfo(String metricsFile, boolean kerning, boolean advanced,
-                     List/*<FontTriplet>*/ fontTriplets, String embedFile, String subFontName) {
+                     List<FontTriplet> fontTriplets, String embedFile, String subFontName) {
          this.metricsFile = metricsFile;
          this.embedFile = embedFile;
          this.kerning = kerning;
index 1f0eff1467f099d280d9f41b033457702022905e,7d6004fa0022459dcaa1ea7036c1fb16fb636215..5d1a0dbf90e4066ad5b6313c3627a635c53358f6
@@@ -23,10 -24,7 +24,9 @@@ import java.util.Map
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
- import org.apache.fop.fonts.CodePointMapping;
  
 +// CSOFF: LineLengthCheck
 +
  /**
   * This class holds font state information and provides access to the font
   * metrics.
@@@ -241,9 -239,10 +241,10 @@@ public class Font implements Substituta
      /**
       * {@inheritDoc}
       */
+     @Override
      public String toString() {
 -        StringBuffer sbuf = new StringBuffer();
 -        sbuf.append('(');
 +        StringBuffer sbuf = new StringBuffer(super.toString());
 +        sbuf.append('{');
          /*
          sbuf.append(fontFamily);
          sbuf.append(',');*/
index bde5135a2f8b74fe93d0e2a0d1af857d3b23a168,67bb2e295632785994b8e239fc34d682a402598b..995df9be2125b350fccd4a98663f9fdb0174170f
@@@ -272,11 -264,10 +269,11 @@@ public class FontInfoConfigurator 
  
          if (log.isDebugEnabled()) {
              String embedFile = embedFontInfo.getEmbedFile();
 -            log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "")
 +            log.debug( ( skipCachedFont ? "Skipping (cached) font " : "Adding font " )
 +                    + (embedFile != null ? embedFile + ", " : "")
                      + "metric file " + embedFontInfo.getMetricsFile());
              for (int j = 0; j < tripletList.size(); ++j) {
-                 FontTriplet triplet = (FontTriplet) tripletList.get(j);
+                 FontTriplet triplet = tripletList.get(j);
                  log.debug("  Font triplet "
                          + triplet.getName() + ", "
                          + triplet.getStyle() + ", "
index 90f3880435bfd4528a3a007264e153d354f80867,714af0e57e75821ade5022183efb6f35d29a4dc4..1d3a10219fb9fa0d2dd924f24a3bb0a0436d0726
@@@ -226,7 -218,7 +218,7 @@@ public class FontInfoFinder 
                  }
                  try {
                      TTFFontLoader ttfLoader = new TTFFontLoader(
-                             fontFileURI, fontName, true, EncodingMode.AUTO, true, true, resolver);
 -                            fontFileURL, fontName, true, EncodingMode.AUTO, true, resolver);
++                            fontFileURL, fontName, true, EncodingMode.AUTO, true, true, resolver);
                      customFont = ttfLoader.getFont();
                      if (this.eventListener != null) {
                          customFont.setEventListener(this.eventListener);
index 01c2924e608aee16fa13b33df1a72bf391a03fc6,f4806d95eff93c95ae4665d211e245ff945ae4e1..21505b7749cc6056fb292b37069c7ed722e9ba6e
@@@ -29,31 -28,9 +29,29 @@@ import java.util.Set
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
 -import org.apache.fop.fonts.FontUtil;
  import org.apache.xmlgraphics.fonts.Glyphs;
  
 +import org.apache.fop.fonts.FontUtil;
 +import org.apache.fop.fonts.GlyphClassTable;
 +import org.apache.fop.fonts.GlyphCoverageTable;
 +import org.apache.fop.fonts.GlyphDefinitionSubtable;
 +import org.apache.fop.fonts.GlyphDefinitionTable;
 +import org.apache.fop.fonts.GlyphMappingTable;
 +import org.apache.fop.fonts.GlyphPositioningSubtable;
 +import org.apache.fop.fonts.GlyphPositioningTable;
 +import org.apache.fop.fonts.GlyphSubstitutionSubtable;
 +import org.apache.fop.fonts.GlyphSubstitutionTable;
 +import org.apache.fop.fonts.GlyphSubtable;
 +import org.apache.fop.fonts.GlyphTable;
 +
 +import org.apache.fop.util.CharUtilities;
 +
 +// CSOFF: AvoidNestedBlocksCheck
 +// CSOFF: NoWhitespaceAfterCheck
 +// CSOFF: InnerAssignmentCheck
 +// CSOFF: SimplifyBooleanReturnCheck
 +// CSOFF: LineLengthCheck
 +
  /**
   * Reads a TrueType file or a TrueType Collection.
   * The TrueType spec can be found at the Microsoft.
@@@ -66,19 -43,22 +64,19 @@@ public class TTFFile 
      static final int MAX_CHAR_CODE = 255;
      static final int ENC_BUF_SIZE = 1024;
  
-     private String encoding = "WinAnsiEncoding";    // Default encoding
 -    /** Set to true to get even more debug output than with level DEBUG */
 -    public static final boolean TRACE_ENABLED = false;
 -
+     private final String encoding = "WinAnsiEncoding";    // Default encoding
  
-     private short firstChar = 0;
+     private final short firstChar = 0;
      private boolean isEmbeddable = true;
      private boolean hasSerifs = true;
      /**
       * Table directory
       */
      protected Map dirTabs;
-     private Map kerningTab;                          // for CIDs
-     private Map ansiKerningTab;                      // For winAnsiEncoding
+     private Map<Integer, Map<Integer, Integer>> kerningTab;     // for CIDs
+     private Map<Integer, Map<Integer, Integer>> ansiKerningTab; // For winAnsiEncoding
      private List cmaps;
 -    private List unicodeMapping;
 +    private Set unicodeMappings;
  
      private int upem;                                // unitsPerEm from "head" table
      private int nhmtx;                               // Number of horizontal metrics
      /**
       * Key-value helper class
       */
 -    class UnicodeMapping {
 +    class UnicodeMapping implements Comparable {
  
-         private int unicodeIndex;
-         private int glyphIndex;
+         private final int unicodeIndex;
+         private final int glyphIndex;
  
          UnicodeMapping(int glyphIndex, int unicodeIndex) {
              this.unicodeIndex = unicodeIndex;
index c55df8ae84c0c627a024a7c045504e729993a289,43276b630363afd8e3efa38760429547ab2d134a..11bca2212a3b74c43f2dd5c55fc7018fa3d918fa
@@@ -539,8 -541,8 +543,9 @@@ public class LineLayoutManager extends 
      }
  
      /** {@inheritDoc} */
+     @Override
      public void initialize() {
 +        bidiLevel = fobj.getBidiLevel();
          textAlignment = fobj.getTextAlign();
          textAlignmentLast = fobj.getTextAlignLast();
          textIndent = fobj.getTextIndent();
index b9e43cfa29e7dd6eabd82129e8f133a0a8ddde3d,05cf979ded70cd2456f297e9c768903dc4be4c5d..4b25522e5a58456c74512625af07c76e08b44a3a
@@@ -1017,46 -812,23 +1018,46 @@@ public class TextLayoutManager extends 
                  //TODO: add kern to wordIPD?
              }
          }
-         int iLetterSpaces = wordLength - 1;
+         int letterSpaces = wordLength - 1;
 -        // if there is a break opportunity and the next one
 +        // if there is a break opportunity and the next one (break character)
          // is not a space, it could be used as a line end;
          // add one more letter space, in case other text follows
 -        if (breakOpportunity && !TextLayoutManager.isSpace(ch)) {
 +        if (( breakOpportunityChar != 0 ) && !TextLayoutManager.isSpace(breakOpportunityChar)) {
-             iLetterSpaces++;
+             letterSpaces++;
          }
-         assert iLetterSpaces >= 0;
-         wordIPD = wordIPD.plus(letterSpaceIPD.mult(iLetterSpaces));
+         assert letterSpaces >= 0;
+         wordIPD = wordIPD.plus(letterSpaceIPD.mult(letterSpaces));
  
 -        // create the AreaInfo object
 -        AreaInfo areaInfo = new AreaInfo(thisStart, lastIndex, 0,
 -                letterSpaces, wordIPD,
 -                endsWithHyphen,
 -                false, breakOpportunity, font);
 +        // create and return the AreaInfo object
 +        return new AreaInfo(thisStart, lastIndex, 0,
-                             iLetterSpaces, wordIPD,
++                            letterSpaces, wordIPD,
 +                            endsWithHyphen,
 +                            false, breakOpportunityChar != 0, font, level, null);
 +    }
 +
 +    private AreaInfo processWord(final int alignment, final KnuthSequence sequence,
 +            AreaInfo prevAreaInfo, final char ch, final boolean breakOpportunity,
 +            final boolean checkEndsWithHyphen, int level) {
 +
 +        //Word boundary found, process widths and kerning
 +        int lastIndex = nextStart;
 +        while (lastIndex > 0 && foText.charAt(lastIndex - 1) == CharUtilities.SOFT_HYPHEN) {
 +            lastIndex--;
 +        }
 +        final boolean endsWithHyphen = checkEndsWithHyphen
 +                && foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN;
 +        Font font = FontSelector.selectFontForCharactersInText
 +            ( foText, thisStart, lastIndex, foText, this );
 +        AreaInfo areaInfo;
 +        if ( font.performsSubstitution() ) {
 +            areaInfo = processWordMapping
 +                ( lastIndex, font, prevAreaInfo, breakOpportunity ? ch : 0, endsWithHyphen, level );
 +        } else {
 +            areaInfo = processWordNoMapping
 +                ( lastIndex, font, prevAreaInfo, breakOpportunity ? ch : 0, endsWithHyphen, level );
 +        }
          prevAreaInfo = areaInfo;
 -        areaInfos.add(areaInfo);
 +        addAreaInfo(areaInfo);
          tempStart = nextStart;
  
          //add the elements
  
              if (!(nothingChanged && stopIndex == areaInfo.breakIndex && !hyphenFollows)) {
                  // the new AreaInfo object is not equal to the old one
 -                changeList.add(new PendingChange(new AreaInfo(startIndex, stopIndex, 0,
 -                        letterSpaceCount, newIPD, hyphenFollows, false, false, font),
 +                changeList.add
 +                    ( new PendingChange
 +                      ( new AreaInfo(startIndex, stopIndex, 0,
 +                                     letterSpaceCount, newIPD, hyphenFollows,
 +                                     false, false, font, -1, null),
-                         ((LeafPosition) pos).getLeafPos()));
+                         ((LeafPosition) pos).getLeafPos() + changeOffset));
                  nothingChanged = false;
              }
              startIndex = stopIndex;