- java.lang.Object
-
- com.itextpdf.text.pdf.HyphenationAuto
-
- All Implemented Interfaces:
HyphenationEvent
public class HyphenationAuto extends java.lang.Object implements HyphenationEvent
Hyphenates words automatically accordingly to the language and country. The hyphenator engine was taken from FOP and uses the TEX patterns. If a language is not provided and a TEX pattern for it exists, it can be easily adapted.- Author:
- Paulo Soares (psoares@consiste.pt)
-
-
Field Summary
Fields Modifier and Type Field Description protected HyphenatorhyphenatorThe hyphenator engine.protected java.lang.StringpostThe second part of the hyphenated word.
-
Constructor Summary
Constructors Constructor Description HyphenationAuto(java.lang.String lang, java.lang.String country, int leftMin, int rightMin)Creates a new hyphenation instance usable inChunk.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetHyphenatedWordPost()Gets the second part of the hyphenated word.java.lang.StringgetHyphenatedWordPre(java.lang.String word, BaseFont font, float fontSize, float remainingWidth)Hyphenates a word and returns the first part of it.java.lang.StringgetHyphenSymbol()Gets the hyphen symbol.
-
-
-
Field Detail
-
hyphenator
protected Hyphenator hyphenator
The hyphenator engine.
-
post
protected java.lang.String post
The second part of the hyphenated word.
-
-
Constructor Detail
-
HyphenationAuto
public HyphenationAuto(java.lang.String lang, java.lang.String country, int leftMin, int rightMin)Creates a new hyphenation instance usable inChunk.- Parameters:
lang- the language ("en" for English, for example)country- the country ("GB" for Great-Britain or "none" for no country, for example)leftMin- the minimum number of letters before the hyphenrightMin- the minimum number of letters after the hyphen
-
-
Method Detail
-
getHyphenSymbol
public java.lang.String getHyphenSymbol()
Gets the hyphen symbol.- Specified by:
getHyphenSymbolin interfaceHyphenationEvent- Returns:
- the hyphen symbol
-
getHyphenatedWordPre
public java.lang.String getHyphenatedWordPre(java.lang.String word, BaseFont font, float fontSize, float remainingWidth)Hyphenates a word and returns the first part of it. To get the second part of the hyphenated word callgetHyphenatedWordPost().- Specified by:
getHyphenatedWordPrein interfaceHyphenationEvent- Parameters:
word- the word to hyphenatefont- the font used by this wordfontSize- the font size used by this wordremainingWidth- the width available to fit this word in- Returns:
- the first part of the hyphenated word including the hyphen symbol, if any
-
getHyphenatedWordPost
public java.lang.String getHyphenatedWordPost()
Gets the second part of the hyphenated word. Must be called aftergetHyphenatedWordPre().- Specified by:
getHyphenatedWordPostin interfaceHyphenationEvent- Returns:
- the second part of the hyphenated word
-
-