Forced Line Breaking

2020-06-12 Thread Moser,Nicholas
Hello all,

I have a question about line breaking. I'm working in an environment where text 
going off the page should be avoided at all costs. Even when using hyphenation 
in FOP, it seems like some strings (e.g. only numbers) cannot be broken and 
therefore can go off the page[1]. This seems especially prevalent when using 
table cells. One of the common recommendations seems to be introducing zero 
width spaces into the string. However, I'm more interested in seeing if it's 
possible for FOP to detect this issue automatically and force a line break.

My current understanding of the line breaking algorithm is that each "word" 
will be a single KnuthInlineBox. If hyphenation is enabled and hyphenation 
points are found, it will break this KnuthInlineBox into multiple 
KnuthInlineBoxes that are groups of characters; penalties and glues are then 
placed between each new KnuthInlineBox (representing each hyphenation point). 
I'm wondering how realistic it would be to further break these new 
KnuthInlineBoxes into KnuthInlineBoxes for each character. Then, add glue and 
even higher penalities between these character KnuthInlineBoxes. The goal would 
be to prefer the standard hyphenation points, but have even higher penalty 
places to break just in case. If there are no hyphenation points found, it will 
just break the original KnuthInlineBox into KnuthInlineBoxes for each character.

I have created a simple proof of concept and it "seems" to work.
My question is: how reasonable does this strategy sound? Is there a better way 
to accomplish this that someone could recommend? I suppose it's less efficient 
since multiple objects will be created for each character. Additionally, since 
hyphens could be added anywhere in a string, it could be added somewhere that 
changes the meaning of the string. I consider that a reasonable alternative to 
text going off the screen though.

Thanks!

[1] Here is an example where the string of characters will go off of the page 
since it is only numbers:
http://www.w3.org/1999/XSL/Format"; 
language="en">12


CONFIDENTIALITY NOTICE This message and any included attachments are from 
Cerner Corporation and are intended only for the addressee. The information 
contained in this message is confidential and may constitute inside or 
non-public information under international, federal, or state securities laws. 
Unauthorized forwarding, printing, copying, distribution, or use of such 
information is strictly prohibited and may be unlawful. If you are not the 
addressee, please promptly delete this message and notify the sender of the 
delivery error by e-mail or you may call Cerner's corporate offices in Kansas 
City, Missouri, U.S.A at (+1) (816)221-1024.


[jira] [Commented] (FOP-2569) Exception in thread "main" java.lang.StackOverflowError at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)

2020-06-12 Thread Chris Bowditch (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-2569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17134325#comment-17134325
 ] 

Chris Bowditch commented on FOP-2569:
-

I think I managed to get this working. I generated a .hyp file anyway :) which 
I attached, but I don't think you can use it as you will need the new code. The 
hyp file is a serialized version of the Java object and I amended this by 
changing char[] to int[]. I need to do a bit more testing before I commit my 
changes

> Exception in thread "main" java.lang.StackOverflowError at 
> org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> --
>
> Key: FOP-2569
> URL: https://issues.apache.org/jira/browse/FOP-2569
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Mathieu Malaterre
>Priority: Major
> Fix For: 1.1
>
> Attachments: hyph_de_DE.fop, hyph_de_DE.hyp
>
>
> fop + offo is broken since release 2.0 (and 2.1). It used to be possible to 
> build fop-hyph.jar using fop 1.1. Please resurrect a working hyph building 
> mechanism.
> Here is what it states:
> $ /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -Xss512k -classpath
> /home/mathieu/debian/fop/fop-2.1/build/classes
> org.apache.fop.hyphenation.SerializeHyphPattern
> /home/mathieu/debian/fop/fop-2.1/hyph
> /home/mathieu/debian/fop/fop-2.1/build/classes/hyph
> Processing /home/mathieu/debian/fop/fop-2.1/hyph/sa.xml
> Exception in thread "main" java.lang.StackOverflowError
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> [...]
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> See thread:
> http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/201602.mbox/%3CCA%2B7wUszWN2PdZY_t_Kgn0E4eatL7CUQswOWj9XC%3Dg9GDdgsyXw%40mail.gmail.com%3E



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (FOP-2569) Exception in thread "main" java.lang.StackOverflowError at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)

2020-06-12 Thread Chris Bowditch (Jira)


 [ 
https://issues.apache.org/jira/browse/FOP-2569?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chris Bowditch updated FOP-2569:

Attachment: hyph_de_DE.hyp

> Exception in thread "main" java.lang.StackOverflowError at 
> org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> --
>
> Key: FOP-2569
> URL: https://issues.apache.org/jira/browse/FOP-2569
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Mathieu Malaterre
>Priority: Major
> Fix For: 1.1
>
> Attachments: hyph_de_DE.fop, hyph_de_DE.hyp
>
>
> fop + offo is broken since release 2.0 (and 2.1). It used to be possible to 
> build fop-hyph.jar using fop 1.1. Please resurrect a working hyph building 
> mechanism.
> Here is what it states:
> $ /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -Xss512k -classpath
> /home/mathieu/debian/fop/fop-2.1/build/classes
> org.apache.fop.hyphenation.SerializeHyphPattern
> /home/mathieu/debian/fop/fop-2.1/hyph
> /home/mathieu/debian/fop/fop-2.1/build/classes/hyph
> Processing /home/mathieu/debian/fop/fop-2.1/hyph/sa.xml
> Exception in thread "main" java.lang.StackOverflowError
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> [...]
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> See thread:
> http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/201602.mbox/%3CCA%2B7wUszWN2PdZY_t_Kgn0E4eatL7CUQswOWj9XC%3Dg9GDdgsyXw%40mail.gmail.com%3E



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (FOP-2569) Exception in thread "main" java.lang.StackOverflowError at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)

2020-06-12 Thread Chris Bowditch (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-2569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17134250#comment-17134250
 ] 

Chris Bowditch commented on FOP-2569:
-

Thanks for sharing the XML. Looking at the code I think its designed for a 
maximum number of hyphenation patterns of around 65535. This is backed up by 
the comments at the top of the class:

 

Using java's char type as pointer (yes, I know pointer
* it is a forbidden word in java) we can keep the size of the node
* to be just 8 bytes (3 pointers and the data char). This gives
* room for about 65000 nodes. In my tests the english patterns
* took 7694 nodes and the german patterns 10055 nodes,
* so I think we are safe.

 

I'll have a go at changing the char[] to int[] to see if that resolves the issue

> Exception in thread "main" java.lang.StackOverflowError at 
> org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> --
>
> Key: FOP-2569
> URL: https://issues.apache.org/jira/browse/FOP-2569
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Mathieu Malaterre
>Priority: Major
> Fix For: 1.1
>
> Attachments: hyph_de_DE.fop
>
>
> fop + offo is broken since release 2.0 (and 2.1). It used to be possible to 
> build fop-hyph.jar using fop 1.1. Please resurrect a working hyph building 
> mechanism.
> Here is what it states:
> $ /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -Xss512k -classpath
> /home/mathieu/debian/fop/fop-2.1/build/classes
> org.apache.fop.hyphenation.SerializeHyphPattern
> /home/mathieu/debian/fop/fop-2.1/hyph
> /home/mathieu/debian/fop/fop-2.1/build/classes/hyph
> Processing /home/mathieu/debian/fop/fop-2.1/hyph/sa.xml
> Exception in thread "main" java.lang.StackOverflowError
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> [...]
> at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:244)
> See thread:
> http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/201602.mbox/%3CCA%2B7wUszWN2PdZY_t_Kgn0E4eatL7CUQswOWj9XC%3Dg9GDdgsyXw%40mail.gmail.com%3E



--
This message was sent by Atlassian Jira
(v8.3.4#803005)