Package org.apache.batik.gvt.text
Class ArabicTextHandler
java.lang.Object
org.apache.batik.gvt.text.ArabicTextHandler
Handles the processing of arabic text. In particular it determines the
form each arabic char should take. It also contains methods for substituting
plain arabic glyphs with their shaped forms. This is needed when the arabic
text is rendered using an AWT font.
- Version:
- $Id: ArabicTextHandler.java 1808977 2017-09-20 09:06:07Z ssteiner $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AttributedCharacterIterator.Attribute
private static final Integer
private static final Integer
private static final Integer
private static final Integer
private static final Integer
private static final int
private static final int
(package private) static int
(package private) static int
(package private) static int[][][]
(package private) static int
(package private) static int
(package private) static int[][]
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
private ctor prevents unnecessary instantiation of this class. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
arabicChar
(char c) Returns true if the char is a standard arabic char.private static boolean
arabicCharShaped
(char c) Returns true if character is shaped.private static boolean
arabicCharShapesDuel
(char c) Returns true if character has duel shaping.private static boolean
arabicCharShapesLeft
(char c) Returns true if character shapes to the left.private static boolean
arabicCharShapesRight
(char c) Returns true if the character shapes to the right.static boolean
arabicCharTransparent
(char c) Returns true if the char is transparent.static AttributedString
If the AttributedString contains any arabic chars, assigns an arabic form attribute, i.e. initial|medial|terminal|isolated, to each arabic char.static boolean
charStartsLigature
(char c) Returns true if a ligature exists that starts with the specified character.static boolean
Returns true if the ACI contains any arabic characters.static boolean
Returns true if the string contains any arabic characters.static String
Where possible substitues plain arabic glyphs with their shaped forms.static int
getNumChars
(char c) Returns the number of characters the glyph for the specified character represents.static int
getSubstituteChar
(char ch1, char ch2, int form) Will try and find a substitute character of the specified form.static int
getSubstituteChar
(char ch, int form) static boolean
hasSubstitute
(char ch1, char ch2) static boolean
isLigature
(char c) Returns true if the glyph for the specified character respresents a ligature.
-
Field Details
-
arabicStart
private static final int arabicStart- See Also:
-
arabicEnd
private static final int arabicEnd- See Also:
-
ARABIC_FORM
-
ARABIC_NONE
-
ARABIC_ISOLATED
-
ARABIC_TERMINAL
-
ARABIC_INITIAL
-
ARABIC_MEDIAL
-
singleCharFirst
static int singleCharFirst -
singleCharLast
static int singleCharLast -
singleCharRemappings
static int[][] singleCharRemappings -
doubleCharFirst
static int doubleCharFirst -
doubleCharLast
static int doubleCharLast -
doubleCharRemappings
static int[][][] doubleCharRemappings
-
-
Constructor Details
-
ArabicTextHandler
private ArabicTextHandler()private ctor prevents unnecessary instantiation of this class.
-
-
Method Details
-
assignArabicForms
If the AttributedString contains any arabic chars, assigns an arabic form attribute, i.e. initial|medial|terminal|isolated, to each arabic char.- Parameters:
as
- The string to attach the arabic form attributes to.- Returns:
- An attributed string with arabic form attributes.
-
arabicChar
public static boolean arabicChar(char c) Returns true if the char is a standard arabic char. (ie. within the range U+0600 - U+6FF)- Parameters:
c
- The character to test.- Returns:
- True if the char is arabic, false otherwise.
-
containsArabic
Returns true if the string contains any arabic characters.- Parameters:
as
- The string to test.- Returns:
- True if at least one char is arabic, false otherwise.
-
containsArabic
Returns true if the ACI contains any arabic characters.- Parameters:
aci
- The AttributedCharacterIterator to test.- Returns:
- True if at least one char is arabic, false otherwise.
-
arabicCharTransparent
public static boolean arabicCharTransparent(char c) Returns true if the char is transparent.- Parameters:
c
- The character to test.- Returns:
- True if the character is transparent, false otherwise.
-
arabicCharShapesRight
private static boolean arabicCharShapesRight(char c) Returns true if the character shapes to the right. Note that duel shaping characters also shape to the right and so will return true.- Parameters:
c
- The character to test.- Returns:
- True if the character shapes to the right, false otherwise.
-
arabicCharShapesDuel
private static boolean arabicCharShapesDuel(char c) Returns true if character has duel shaping.- Parameters:
c
- The character to test.- Returns:
- True if the character is duel shaping, false otherwise.
-
arabicCharShapesLeft
private static boolean arabicCharShapesLeft(char c) Returns true if character shapes to the left. Note that duel shaping characters also shape to the left and so will return true.- Parameters:
c
- The character to test.- Returns:
- True if the character shapes to the left, false otherwise.
-
arabicCharShaped
private static boolean arabicCharShaped(char c) Returns true if character is shaped.- Parameters:
c
- The character to test.- Returns:
- True if the character is shaped, false otherwise.
-
hasSubstitute
public static boolean hasSubstitute(char ch1, char ch2) -
getSubstituteChar
public static int getSubstituteChar(char ch1, char ch2, int form) Will try and find a substitute character of the specified form.- Parameters:
ch1
- The first character of two to replace.ch2
- The second character of two to replace.form
- Indicates the required arabic form. (isolated = 1, final = 2, initial = 3, medial = 4)- Returns:
- The unicode value of the substutute char, or -1 if no substitute exists.
-
getSubstituteChar
public static int getSubstituteChar(char ch, int form) -
createSubstituteString
Where possible substitues plain arabic glyphs with their shaped forms. This is needed when the arabic text is rendered using an AWT font. Simple arabic ligatures will also be recognised and replaced by a single character so the length of the resulting string may be shorter than the number of characters in the aci.- Parameters:
aci
- Contains the text to process. Arabic form attributes should already be assigned to each arabic character.- Returns:
- A String containing the shaped versions of the arabic characters
-
charStartsLigature
public static boolean charStartsLigature(char c) Returns true if a ligature exists that starts with the specified character.- Parameters:
c
- The character to test.- Returns:
- True if there is a ligature that starts with c, false otherwise.
-
getNumChars
public static int getNumChars(char c) Returns the number of characters the glyph for the specified character represents. If the glyph represents a ligature this will be 2, otherwise 1.- Parameters:
c
- The character to test.- Returns:
- The number of characters the glyph for c represents.
-
isLigature
public static boolean isLigature(char c) Returns true if the glyph for the specified character respresents a ligature.- Parameters:
c
- The character to test.- Returns:
- True if c is a ligature, false otherwise.
-