Forum How do I...?

prince-hyphenate-patterns

somnath
Hi,

I've trouble using the prince-hyphenate-patterns property. I'm using OpenOfiice dictionary "en_US.dic" for hyphenation as follows.

div {
font-family: serif;
font-size: 11pt;
line-height: 14pt;
text-align: justify;
hyphens: auto;
prince-hyphenate-patterns: url('en_US.dic');
}
(where 'div' is my root element in xhtml and the dictionary is in the same location as the source CSS & xhtml file)

The output PDF does not have any effect on hyphenation. It comes out as an unhyphenated PDF with no hyphenation at all.

Am I using the correct method for hyphenation?

Please let me know.

Thanks,
Somnath
mikeday
Is en_US.dic in the same format as the en.hyp pattern file that ships with Prince?
somnath
Hi Mike,

I'm using this "en_US.dic" dictionary downloaded from "http://wiki.services.openoffice.org/wiki/Dictionaries#English_.28AU.2CCA.2CGB.2CNZ.2CUS.2CZA.29" available under the heading "Hyphenation".

It has patterns as below:
...
AB
aback
abacus/SM
abaft
Abagael/M
Abagail/M
abalone/SM
abandoner/M
abandon/LGDRS
abandonment/SM
....
and so on...



Somnath
mikeday
That pattern syntax looks different to what we are using, but I was unable to download the file to see as it keeps timing out. Are you sure that's a hyphenation dictionary and not a spelling dictionary of some kind? Or perhaps it's just a different format.
somnath
Hi Mike,

Looks like problem with the hyphenation dictionary.

I downloaded the dictionary again from the same path and it worked correctly.
Also it now had syntax similar to en.hyp as below.

.ab4i
.1ab
.ab3ol
.abo2
.ace4
.ace2t3
.a2ch4
.ac5t2iva
.a2ct
.ac2t1iv

Thanks for the clarification.


Cheers :-)
Somnath
somnath
Hi Mike,

I'm having trouble again with prince-hyphenate-patterns.

When I use "prince-hyphenate-patterns: url('en_US.dic');"; this works great and all fine but when I change the path to an absolute url like "prince-hyphenate-patterns: url('http://IP/folder/en_US.dic');" prince throws an error: can't open input file: No such file or directory

I checked though, the file is available on the mentioned path.

Can you help me on this or am I being stupid here :? ?


Somnath
mikeday
No, this is our stupidity :)

At the moment hyphenation dictionaries need to be local files, I think they are the only resource that Prince doesn't load over HTTP yet.
somnath
Thanks for the reply Mike, not an issue as long as we know the limitation.

Cheers
Somnath
conner_bw
Is this still a limitation?
mikeday
Yes, we still haven't implemented this yet, there has always been something more pressing. :(
conner_bw
Ok. No worries. Changed to fullpath then.
Cheers.
sakthikanth
I have tried my full path like

prince-hyphenate-patterns: url("http:// domain../.. /hyph-ta.pat");

but it does not work for me.

Can you please give the example of fullpath for hyphenation.
mikeday
This will not work, sorry, only file system paths are accepted for hyphenation patterns at this time.
sakthikanth
Ok, Thank you!
joelmeador
We are working on supporting this on DocRaptor to allow more automatic patterns. One thing that I have run into is if I define the pattern to use for a language in the hyph.css file, and then done use prince-hyphenate-patterns for that language, everything works as expected. As soon as I attempt to use prince-hyphenate-patterns, it does not. Perhaps I am using the wrong local file system path, but trying to match the stuff on https://www.princexml.com/doc-prince/#hyphenation and https://www.princexml.com/doc-refs/#prop-prince-hyphenate-patterns is not working ( url("hyph-ta.pat") ).

Making this take absolute HTTP URLs would be a nice enhancement, but ultimately I think the base function may have issues or need documentation updates since it doesn't seem to work in prince 12. When I say it doesn't work, I mean I go from having a line in my log about using hyph-ta.pat to nothing, not even a fallback which I would think it would use if the file I was requesting was not findable.
csant
Joel, it might be superfluous to ask - but did you make sure to turn on hyphenation with "hyphens: auto;" ? Maybe it needs to be better emphasized in the documentation...

I tried using a downloaded hyphenation pattern, and it worked as expected.
joelmeador
Yeah, I have tried hyphens in a couple places and it is required to pickup the automatic setting of the hyph file via hyph.css so I don't think it's that.

Edited by joelmeador

csant
It is needed to turn on (automatic) hyphenation (as opposed to manual hyphenation, which only hyphenates when there are characters such as e.g. "soft hyphens", represented either by the Unicode character U+00AD or the HTML entity ­ ). So just declaring prince-hyphenate-patterns is not enough, also hyphens needs to be set to auto. prince-hyphenate-patterns just tells Prince which hyphenation pattern dictionary to use for the automatic hyphenation.
joelmeador
Yes I know. I was using it in the file I was testing. I have a working automated test in DocRaptor that uses it. The problem is as soon as I add the prince-hyphenate-patterns for the language-in-question's hyphenation, or at least logging about the use thereof, stops working.

Edited by joelmeador

csant
Odd, I tried downloading the Dutch .pat file from the CTAN archive, then run the attached file - both files in the same directory. It works as expected for me.
  1. hyph-nl.html7.7 kB
    Extract from De kleine Johannes - Dutch.

Edited by csant

joelmeador
We're running in a hosted environment. It's not practical to put pat files into the same directory.

But, you have rubber ducked me to understanding why this isn't working. Our content files go into a DMZ which is not nearly the same structure as prince's, so my assumption was if I gave prince-hyphenate-patterns a file URL, it would check the DMZ and then the sudo-FS that is the prince directory structure. The latter is not true here. SO yeah, we can do automatic languages in our context but not support the css property without using absolute http URLs.

Thanks csant! :)
csant
Making this take absolute HTTP URLs would be a nice enhancement, but ultimately I think the base function may have issues


So, yeah, I guess that it would be a nice enhancement to have support for absolute HTTP URLs - since that seems to be the issue of the base functionality! :)
joelmeador
You're not wrong!
mikeday
The latest builds now support loading hyphenation dictionaries from HTTP URLs, sorry it took so long. :)
joelmeador
👏