Forum How do I...?

How to enable hyphenation?

qrakis
I've tried to use hyphenation setting “prince-hyphenate: auto” and “prince-hyphenate-dictionary” with polish dic file (from OpenOffice) and there wasn't any hyphenation in pdf file.

Then I did it with PrinceXML p6demo2.html (I've downloaded hyph_da_DK.dic file too) and it failed as well.

So, my question is: is hyphenation really working? If so, then how can I use it? Any working examples?
kmmv
It is, and working wonderfully.

The property was renamed from prince- to just "hyphens: auto;":

http://www.princexml.com/doc/6.0/properties/hyphens/
qrakis
Thank You very much kmmv.

And shame on me ;-).
bytie
Ehm, how do I enable russian hyphenation?

I used russian hyphenation from OpenOffice.

Paragraph properties:
para { text-indent: 6.35mm; text-align: justify; line-stacking-strategy: inline-line-height; letter-spacing: -0.2pt; font-family: Cambria; prince-hyphenate-patterns: url('hyph_ru_RU.dic'); hyphens: auto; font-size: 10pt; }


All the files are UTF-8 (some without BOM, some with), including CSS file.

It seems there's some problem with .dic file, but I dunno how to fix it.
kmmv
If you're using the default hyph_ru_RU.dic file, the file is preceeded by a "KOI8-R" marker. It may work better if you can convert it to UTF8 and remove the "KOI8-R" marker at the beginning of the file.
bytie
Oh, thanks, you gave me an idea and it worked.

I've deleted KOI8 marker, saved KOI8 as normal UTF8 without BOM and it works. That's looking and feeling goooood :-)
JonThn
Hello,

Is there a way to check that the good dic for hyphen is used ?

Currently I've got a test html page and the hyphenation is done but it's not the good hyphenation (like the Wikipedia page explains the french page named : Césure).
In the wikipedia page there are 4 examples ( see Exemples de césures) and if the hyphenation is done on the slash character that's wrong :(

So I don't know if it's a bug or an error i did myself.

<xml>
<DOCTYPE>
<html>
	<head>
	<style>
		p.hyph {
			color: red;
		  text-align: justify;
		  hyphens: auto;
			hyphenate-patterns: url("hyph_fr_FR_UTF8.dic"); 
			
		}

		p.hyphsoft {
			color: green;
			text-align: justify;
			hyphens: manual;
		}
 	</style>
</head>
<body>
	<h1>Without hyphens</h1>
	<p>inconsistant aaa aaa inconsistant inconsistant bbbb inconsistant inconsistant inconsistant inconsistant 
	inconsistant inconsistant ee, inconsistant inconsistant cccc inconsistant inconsistant inconsistant inconsistant
	inconsistant inconsistant inconsistant inconsistant
	</p>
	<h1>With hyphens</h1>
	<p>inconsistant aaa aaa inconsistant inconsistant bbbb inconsistant inconsistant inconsistant inconsistant 
	inconsistant inconsistant ee, inconsistant inconsistant cccc inconsistant inconsistant inconsistant inconsistant
	inconsistant inconsistant inconsistant inconsistant
	</p>
	<p>aaairaa culture ab, successive tôt i suc&shy;ces&shy;sive successive culture aaa successive suc&shy;ces&shy;sive successive culture aa suc&shy;ces&shy;sive culture successive suc&shy;ces&shy;sive bbbb culture suc&shy;ces&shy;sive zzzzz
	culture suc&shy;ces&shy;sive successive successive eeee suc&shy;ces&shy;sive culture yyyy successive aa culture aaa culture aa 	</p>
</body>
</html>


In that code one word "inconsistant" is rendered "in-consistant" which is wrong like explained on Wikipedia.

Can someone point me to the right direction to solve this problem ?

Thanks in advance
mikeday
One way to check that Prince is loading your specified hyphenation patterns file is to change the filename, which should make Prince print an error message. If there is no error message and it's performing hyphenation then it should be using the hyphenation file that you have specified. If you want to be extra sure, you can comment out the rule in the installed hyph.css file which specifies English hyphenation by default.

Once you've established that the correct hyphenation patterns file is being used, the quality of the hyphenation performed depends upon the quality of the patterns file.
JonThn
Thanks for your answers that helped to progress.

And after a test the file is effectively used so it must be the file that doesn't do good hypenation.
But that's strange because if I understand correctly Prince can use the TeX format for the hypenation on which OOo dics are based

And for the dic I used based on the last Tex hyphenation file from 2002 and with a test file the hyphenation is correctly made on LaTex.

So I'm a little puzzled and unfortunately I can't get OOo to add an hyphen on that particular word it constantly keep the word entire.

But at last that's not a blocking issue for me to use prince but If you've got an idea on what's going on I would really be interested.
mikeday
Perhaps you could email me (mikeday@yeslogic.com) the hyphenation dictionary file that you are using together with your sample document, then I can replicate the problem here and see if there are any improvements we can make to the hyphenation in Prince.
JonThn
OOh my bad :oops:

After playing more and more with the latex file i was able to reproduce the hyphenation that Prince has done.

Sorry for bothering you.

Finally it's the hyphenation dictionary which is wrong.
Anton
Hi,

I'm having no luck getting Russian hyphenation working.

I currently have hyphenation working in several other languages.

Also I've tried to do what kmmv's suggests above
"It may work better if you can convert it to UTF8 and remove the "KOI8-R" marker at the beginning of the file"
but it's still not working. BTW, I hope I've understood kmmv's instructions ok - I opened the file in notepad, deleted the text "KOI8-R." and saved the file as UTF-8 encoding.

Thanks for any help!
leif
It must be an encoding converstion error, then. I don't know if one can achieve correct transcoidng with Notepad. I used iconv, myself. There is a Windows version of iconv here:

http://www.zlatkovic.com/pub/libxml

It might also work opening the hyphenatino file in Firefox, manually selecting the koi8-r encoding, and then to save it in the UTF-8 encoding. (You may then need to change the suffix to .txt first.)

leif

Anton
Thanks leif - I used iconv and now have hyphenation for Russian up and running. :D

Only remaining problem I have is, according to my Russian translator, the hyphenation is not grammatically correct due to some words 'breaking' after the first letter. (e.g. the word "употреблялись” hyphenates "у-потреблялись"). I'm thinking this may be an issue with the dictionary rather than anything else?
leif
Anton, thank you for the alert. I think everything works fine as long as the dictionary takes care of everything. However, when Prince is counting the minimum number of characters to go before a hyphenation can occur, then it appears to miscalcalculate the Russian letters – counting each of them for 2 instead of 1. (A classing UTF-8 issue, I think.)

Increasing the default hyphenate-before:2; property for :lang(ru) to
hyphenate-before:3;
(and ditto for hyphenate-after if you get trouble with «lone» characters there as well) will probably solve the issue for you – hopefully without negative effects – until the next release or so. (If you need to use both Russiand and e.g. English hyphenation in the same document, then you might need to increase hyphenate-before to 3 for :lang(en) as well.)

Hope this helps. And many thanks to your observant translator!

leif

mikeday
Today we have released Prince 6.0 rev 7, which fixes the hyphenation issue that was affecting Russian text.