You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Luca Furini <lf...@cs.unibo.it> on 2004/03/16 15:16:54 UTC

Hyphenation

    Hi all!

I am an italian student of the University of Bologna.

I have tried to solve a few problems concerning hyphenation, in
particular:
- show the '-' at the end of the hyphenated lines
- use the fo:hyphenate property to enable hyphenation, instead of the
  alignment
- specify the hyphenation character using the fo:hyphenation-character
  property

So, here are the modifications I suggest; I have done some (simple) tests
and they seem to work.


*** layoutmgr/LineLayoutManager.java ***
I changed the condition tested to decide whether try hyphenate, now it
only looks at the appropriate fo property

24a25
> import org.apache.fop.fo.Constants;
212c213,214
<                     if (bTextAlignment == TextAlign.JUSTIFY || prevBP == null) {
---
> //                    if (bTextAlignment == TextAlign.JUSTIFY || prevBP == null) {
>                     if (hyphProps.hyphenate == Constants.TRUE) {


*** fo/TextInfo.java ***
I added the hyphenation character, and removed the bCanHyphenate boolean,
which is no longer necessary, because of the previous change

54c54,56
<     public boolean bCanHyphenate = true;
---
> //    public boolean bCanHyphenate = true;
>     /** the hyphenation character to be used */
>     public char hyphChar = '-';


*** fo/PropertyManager.java ***
Sets the hyphenation character in the TextInfo object


496a497,498
> 	    textInfo.hyphChar = this.propertyList.get(
>                                   PR_HYPHENATION_CHARACTER).getCharacter();


*** layoutmgr/TextLayoutManager.java ***
I added a iHyphenated boolean in the AreaInfo class; it is set to true
according to the flags of the break possibility chosen, and is value is
looked at before creating the areas, to decide whether to add the
hyphenation character

49a50,52
> 	private boolean iHyphenated;
> //        public AreaInfo(short iSIndex, short iBIndex, short iWS,
> //                 MinOptMax ipd) {
51c54,55
<                  MinOptMax ipd) {
---
>                  MinOptMax ipd, boolean iHyp) {
>             iHyphenated = iHyp;
114c118,119
<         hyphIPD = textInfo.fs.getCharWidth('-');
---
> //        hyphIPD = textInfo.fs.getCharWidth('-');
> 	hyphIPD = textInfo.fs.getCharWidth(textInfo.hyphChar);
208c213,214
<         if (textArrayLength < iStopIndex || textInfo.bCanHyphenate == false) {
---
> //        if (textArrayLength < iStopIndex || textInfo.bCanHyphenate == false) {
>         if (textArrayLength < iStopIndex) {
401a408,409
> //        vecAreaInfo.add(
> //          new AreaInfo(iWordStart, iNextStart, iWScount, ipd));
403c411
<           new AreaInfo(iWordStart, iNextStart, iWScount, ipd));
---
>           new AreaInfo(iWordStart, iNextStart, iWScount, ipd, ((flags & BreakPoss.HYPHENATED) != 0)));
499a508,512
>
> 	// add hyphenation character if the last word is hyphenated
>         if (ai.iHyphenated) {
>             str += textInfo.hyphChar;
>         }


Ok, that's all, I hope this can be useful.

Bye
	Luca


Re: Hyphenation

Posted by Chris Bowditch <bo...@hotmail.com>.
Luca Furini wrote:

>     Hi all!
> 
> I am an italian student of the University of Bologna.
> 
> I have tried to solve a few problems concerning hyphenation, in
> particular:
> - show the '-' at the end of the hyphenated lines
> - use the fo:hyphenate property to enable hyphenation, instead of the
>   alignment
> - specify the hyphenation character using the fo:hyphenation-character
>   property

Thanks for trying. Unfortunately we need a bit more information for your 
suggested change to make it to the code base.

Most importantly, which version of the code are you trying to fix? 
Maintenance or HEAD?

Secondly, could you please follow the procedure for submitting patches, 
described here:

http://xml.apache.org/fop/dev/index.html#patches

Please include sample FO files that demonstrate before and after effects 
of your changes.

Thanks very much,

Chris