Description: Allow for words consisting of only soft hyphens
Bug: https://issues.apache.org/bugzilla/show_bug.cgi?id=49837
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=646141
Origin: http://svn.apache.org/viewvc?view=revision&revision=1042115
Index: fop-1.0.dfsg2/src/java/org/apache/fop/fo/FOTreeBuilder.java
===================================================================
--- fop-1.0.dfsg2.orig/src/java/org/apache/fop/fo/FOTreeBuilder.java	2012-01-03 15:29:44.000000000 +0100
+++ fop-1.0.dfsg2/src/java/org/apache/fop/fo/FOTreeBuilder.java	2012-01-03 15:29:46.000000000 +0100
@@ -398,7 +398,9 @@
                 FOValidationEventProducer eventProducer
                     = FOValidationEventProducer.Provider.get(
                         userAgent.getEventBroadcaster());
-                eventProducer.unknownFormattingObject(this, currentFObj.getName(),
+                String name = (currentFObj != null ? currentFObj.getName()
+                                                   : "{" + namespaceURI + "}" + localName);
+                eventProducer.unknownFormattingObject(this, name,
                         new QName(namespaceURI, localName),
                         getEffectiveLocator());
             }
Index: fop-1.0.dfsg2/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
===================================================================
--- fop-1.0.dfsg2.orig/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java	2012-01-03 15:29:44.000000000 +0100
+++ fop-1.0.dfsg2/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java	2012-01-03 15:32:00.000000000 +0100
@@ -774,10 +774,7 @@
         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);
-        int wordLength = lastIndex - thisStart;
         boolean kerning = font.hasKerning();
         MinOptMax wordIPD = MinOptMax.ZERO;
         for (int i = thisStart; i < lastIndex; i++) {
@@ -803,23 +800,31 @@
                 }
             }
         }
+        boolean endsWithHyphen = checkEndsWithHyphen
+                && foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN;
         if (kerning
                 && breakOpportunity
                 && !TextLayoutManager.isSpace(ch)
                 && lastIndex > 0
                 && endsWithHyphen) {
-            final int kern = font.getKernValue(foText.charAt(lastIndex - 1), ch);
+            int kern = font.getKernValue(foText.charAt(lastIndex - 1), ch);
             if (kern != 0) {
                 addToLetterAdjust(lastIndex, kern);
                 //TODO: add kern to wordIPD?
             }
         }
-        int iLetterSpaces = wordLength - 1;
-        // if there is a break opportunity and the next one
-        // 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)) {
-            iLetterSpaces++;
+        // shy+chars at start of word: wordLength == 0 && breakOpportunity
+        // shy only characters in word: wordLength == 0 && !breakOpportunity
+        int wordLength = lastIndex - thisStart;
+        int iLetterSpaces = 0;
+        if (wordLength != 0) {
+            iLetterSpaces = wordLength - 1;
+            // if there is a break opportunity and the next one
+            // 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)) {
+                iLetterSpaces++;
+            }
         }
         assert iLetterSpaces >= 0;
         wordIPD = wordIPD.plus(letterSpaceIPD.mult(iLetterSpaces));
