From: Simon Pepping Date: Sun, 28 Nov 2010 18:55:54 +0000 (+0000) Subject: Merged changes from trunk X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=822615fbaf72b52cb2565315510491cd605336b4;p=xmlgraphics-fop.git Merged changes from trunk git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ComplexScripts@1039922 13f79535-47bb-0310-9956-ffa450edef68 --- 822615fbaf72b52cb2565315510491cd605336b4 diff --cc src/java/org/apache/fop/fonts/CustomFont.java index a018bcbbb,4432fccef..c6b43fe98 --- a/src/java/org/apache/fop/fonts/CustomFont.java +++ b/src/java/org/apache/fop/fonts/CustomFont.java @@@ -55,10 -57,9 +57,10 @@@ public abstract class CustomFont extend private int firstChar = 0; private int lastChar = 255; - private Map kerning; + private Map> kerning; private boolean useKerning = true; + private boolean useAdvanced = true; /** {@inheritDoc} */ public String getFontName() { diff --cc src/java/org/apache/fop/fonts/EmbedFontInfo.java index 37b348e88,b53cdfdd6..7cc0eb265 --- a/src/java/org/apache/fop/fonts/EmbedFontInfo.java +++ b/src/java/org/apache/fop/fonts/EmbedFontInfo.java @@@ -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/**/ fontTriplets, String embedFile, String subFontName) { + List fontTriplets, String embedFile, String subFontName) { this.metricsFile = metricsFile; this.embedFile = embedFile; this.kerning = kerning; diff --cc src/java/org/apache/fop/fonts/Font.java index 1f0eff146,7d6004fa0..5d1a0dbf9 --- a/src/java/org/apache/fop/fonts/Font.java +++ b/src/java/org/apache/fop/fonts/Font.java @@@ -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(',');*/ diff --cc src/java/org/apache/fop/fonts/FontInfoConfigurator.java index bde5135a2,67bb2e295..995df9be2 --- a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java @@@ -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() + ", " diff --cc src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java index 90f388043,714af0e57..1d3a10219 --- a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java @@@ -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); diff --cc src/java/org/apache/fop/fonts/truetype/TTFFile.java index 01c2924e6,f4806d95e..21505b774 --- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java @@@ -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> kerningTab; // for CIDs + private Map> 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 @@@ -159,10 -128,10 +157,10 @@@ /** * 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; diff --cc src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index c55df8ae8,43276b630..11bca2212 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@@ -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(); diff --cc src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index b9e43cfa2,05cf979de..4b25522e5 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@@ -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 @@@ -1189,12 -959,9 +1188,12 @@@ 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;