001: /*
002: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
003: *
004: * The program is provided "as is" without any warranty express or
005: * implied, including the warranty of non-infringement and the implied
006: * warranties of merchantibility and fitness for a particular purpose.
007: * IBM will not be liable for any damages suffered by you as a result
008: * of using the Program. In no event will IBM be liable for any
009: * special, indirect or consequential damages or lost profits even if
010: * IBM has been advised of the possibility of their occurrence. IBM
011: * will not be liable for any third party claims against you.
012: */
013: /*
014: *
015: * (C) Copyright IBM Corp. 1998, All Rights Reserved
016: */
017:
018: package com.ibm.richtext.textpanel;
019:
020: /*
021: For any incoming character C
022: if you can map C using the following FakeArabicTable, return
023: FakeArabicTable(C)
024: else if C is from A through Z, return FakeArabicTable(lowercase(C))
025: else just return C
026:
027:
028: FakeArabicTable is defined by the following mapping
029:
030: 0 0660;ARABIC-INDIC DIGIT ZERO;Nd;0;AN;;0;0;0;N;;;;;
031: 1 0661;ARABIC-INDIC DIGIT ONE;Nd;0;AN;;1;1;1;N;;;;;
032: 2 0662;ARABIC-INDIC DIGIT TWO;Nd;0;AN;;2;2;2;N;;;;;
033: 3 0663;ARABIC-INDIC DIGIT THREE;Nd;0;AN;;3;3;3;N;;;;;
034: 4 0664;ARABIC-INDIC DIGIT FOUR;Nd;0;AN;;4;4;4;N;;;;;
035: 5 0665;ARABIC-INDIC DIGIT FIVE;Nd;0;AN;;5;5;5;N;;;;;
036: 6 0666;ARABIC-INDIC DIGIT SIX;Nd;0;AN;;6;6;6;N;;;;;
037: 7 0667;ARABIC-INDIC DIGIT SEVEN;Nd;0;AN;;7;7;7;N;;;;;
038: 8 0668;ARABIC-INDIC DIGIT EIGHT;Nd;0;AN;;8;8;8;N;;;;;
039: 9 0669;ARABIC-INDIC DIGIT NINE;Nd;0;AN;;9;9;9;N;;;;;
040:
041: % 066A;ARABIC PERCENT SIGN;Po;0;ET;;;;;N;;;;;
042: . 066B;ARABIC DECIMAL SEPARATOR;Po;0;AN;;;;;N;;;;;
043: , 060C;ARABIC COMMA;Po;0;R;;;;;N;;;;;
044: - 0640;ARABIC TATWEEL;Lm;0;R;;;;;N;;;;;
045: ' 0652;ARABIC SUKUN;Mn;34;R;;;;;N;;;;;
046: " 0651;ARABIC SHADDA;Mn;33;R;;;;;N;ARABIC SHADDAH;;;;
047: ; 061B;ARABIC SEMICOLON;Po;0;R;;;;;N;;;;;
048: ? 061F;ARABIC QUESTION MARK;Po;0;R;;;;;N;;;;;
049:
050: a 0627;ARABIC LETTER ALEF;Lo;0;R;;;;;N;;;;;
051: A 0639;ARABIC LETTER AIN;Lo;0;R;;;;;N;;;;;
052: b 0628;ARABIC LETTER BEH;Lo;0;R;;;;;N;ARABIC LETTER BAA;;;;
053: c 0635;ARABIC LETTER SAD;Lo;0;R;;;;;N;;;;;
054: d 062F;ARABIC LETTER DAL;Lo;0;R;;;;;N;;;;;
055: D 0630;ARABIC LETTER THAL;Lo;0;R;;;;;N;;;;;
056: E 064B;ARABIC FATHATAN;Mn;27;R;;;;;N;;;;;
057: e 064E;ARABIC FATHA;Mn;30;R;;;;;N;ARABIC FATHAH;;;;
058: f 0641;ARABIC LETTER FEH;Lo;0;R;;;;;N;ARABIC LETTER FA;;;;
059: g 063A;ARABIC LETTER GHAIN;Lo;0;R;;;;;N;;;;;
060: h 062D;ARABIC LETTER HAH;Lo;0;R;;;;;N;ARABIC LETTER HAA;;;;
061: H 0647;ARABIC LETTER HEH;Lo;0;R;;;;;N;ARABIC LETTER HA;;;;
062: I 064D;ARABIC KASRATAN;Mn;29;R;;;;;N;;;;;
063: i 0650;ARABIC KASRA;Mn;32;R;;;;;N;ARABIC KASRAH;;;;
064: j 062C;ARABIC LETTER JEEM;Lo;0;R;;;;;N;;;;;
065: K 062E;ARABIC LETTER KHAH;Lo;0;R;;;;;N;ARABIC LETTER KHAA;;;;
066: k 0643;ARABIC LETTER KAF;Lo;0;R;;;;;N;ARABIC LETTER CAF;;;;
067: l 0644;ARABIC LETTER LAM;Lo;0;R;;;;;N;;;;;
068: m 0645;ARABIC LETTER MEEM;Lo;0;R;;;;;N;;;;;
069: n 0646;ARABIC LETTER NOON;Lo;0;R;;;;;N;;;;;
070: o 064F;ARABIC DAMMA;Mn;31;R;;;;;N;ARABIC DAMMAH;;;;
071: p 0628;ARABIC LETTER BEH;Lo;0;R;;;;;N;ARABIC LETTER BAA;;;;
072: q 0642;ARABIC LETTER QAF;Lo;0;R;;;;;N;;;;;
073: r 0631;ARABIC LETTER REH;Lo;0;R;;;;;N;ARABIC LETTER RA;;;;
074: s 0633;ARABIC LETTER SEEN;Lo;0;R;;;;;N;;;;;
075: S 0634;ARABIC LETTER SHEEN;Lo;0;R;;;;;N;;;;;
076: t 062A;ARABIC LETTER TEH;Lo;0;R;;;;;N;ARABIC LETTER TAA;;;;
077: T 062B;ARABIC LETTER THEH;Lo;0;R;;;;;N;ARABIC LETTER THAA;;;;
078: U 064C;ARABIC DAMMATAN;Mn;28;R;;;;;N;;;;;
079: u 064F;ARABIC DAMMA;Mn;31;R;;;;;N;ARABIC DAMMAH;;;;
080: v 0641;ARABIC LETTER FEH;Lo;0;R;;;;;N;ARABIC LETTER FA;;;;
081: w 0648;ARABIC LETTER WAW;Lo;0;R;;;;;N;;;;;
082: x 0633;ARABIC LETTER SEEN;Lo;0;R;;;;;N;;;;;
083: y 064A;ARABIC LETTER YEH;Lo;0;R;;;;;N;ARABIC LETTER YA;;;;
084: z 0632;ARABIC LETTER ZAIN;Lo;0;R;;;;;N;;;;;
085: Z 0638;ARABIC LETTER ZAH;Lo;0;R;;;;;N;ARABIC LETTER DHAH;;;;
086:
087: */
088:
089: /**
090: * This class implements KeyRemap to produce transliterated Arabic
091: * characters from Latin-1 characters.
092: */
093:
094: // NOTE: this class eliminates Arabic vowels which look ugly
095: // in the font in which we happen to be demo'ing. It's totally
096: // bogus otherwise.
097: final class HackArabicTransliteration extends KeyRemap {
098:
099: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
100:
101: public char remap(char c) {
102:
103: switch (c) {
104: case '0':
105: return '\u0660'; // ARABIC-INDIC DIGIT ZERO
106: case '1':
107: return '\u0661'; // ARABIC-INDIC DIGIT ONE
108: case '2':
109: return '\u0662'; // ARABIC-INDIC DIGIT TWO
110: case '3':
111: return '\u0663'; // ARABIC-INDIC DIGIT THREE
112: case '4':
113: return '\u0664'; // ARABIC-INDIC DIGIT FOUR
114: case '5':
115: return '\u0665'; // ARABIC-INDIC DIGIT FIVE
116: case '6':
117: return '\u0666'; // ARABIC-INDIC DIGIT SIX
118: case '7':
119: return '\u0667'; // ARABIC-INDIC DIGIT SEVEN
120: case '8':
121: return '\u0668'; // ARABIC-INDIC DIGIT EIGHT
122: case '9':
123: return '\u0669'; // ARABIC-INDIC DIGIT NINE
124:
125: case '%':
126: return '\u066A'; // ARABIC PERCENT SIGN
127: // the Traditional Arabic font does not contain this character
128: // case '.': return '\u066B'; // ARABIC DECIMAL SEPARATOR
129: case ',':
130: return '\u060C'; // ARABIC COMMA
131: case '-':
132: return '\u0640'; // ARABIC TATWEEL
133: case '\'':
134: return '\u0652'; // ARABIC SUKUN
135: case '"':
136: return '\u0651'; // ARABIC SHADDA
137: case ';':
138: return '\u061B'; // ARABIC SEMICOLON
139: case '?':
140: return '\u061F'; // ARABIC QUESTION MARK
141:
142: case 'a':
143: return '\u0627'; // ARABIC LETTER ALEF
144: case 'A':
145: return '\u0639'; // ARABIC LETTER AIN
146: case 'b':
147: return '\u0628'; // ARABIC LETTER BEH
148: case 'B':
149: return '\u0628'; // ARABIC LETTER BEH
150: case 'c':
151: return '\u0635'; // ARABIC LETTER SAD
152: case 'C':
153: return '\u0635'; // ARABIC LETTER SAD
154: case 'd':
155: return '\u062F'; // ARABIC LETTER DAL
156: case 'D':
157: return '\u0630'; // ARABIC LETTER THAL
158: case 'e': //return '\u064E'; // ARABIC FATHA
159: case 'E': //return '\u064B'; // ARABIC FATHATAN
160: case 'f':
161: return '\u0641'; // ARABIC LETTER FEH
162: case 'F':
163: return '\u0641'; // ARABIC LETTER FEH
164: case 'g':
165: return '\u063A'; // ARABIC LETTER GHAIN
166: case 'G':
167: return '\u063A'; // ARABIC LETTER GHAIN
168: case 'h':
169: return '\u062D'; // ARABIC LETTER HAH
170: case 'H':
171: return '\u0647'; // ARABIC LETTER HEH
172: case 'i': //return '\u0650'; // ARABIC KASRA
173: case 'I': //return '\u064D'; // ARABIC KASRATAN
174: case 'j':
175: return '\u062C'; // ARABIC LETTER JEEM
176: case 'J':
177: return '\u062C'; // ARABIC LETTER JEEM
178: case 'k':
179: return '\u0643'; // ARABIC LETTER KAF
180: case 'K':
181: return '\u062E'; // ARABIC LETTER KHAH
182: case 'l':
183: return '\u0644'; // ARABIC LETTER LAM
184: case 'L':
185: return '\u0644'; // ARABIC LETTER LAM
186: case 'm':
187: return '\u0645'; // ARABIC LETTER MEEM
188: case 'M':
189: return '\u0645'; // ARABIC LETTER MEEM
190: case 'n':
191: return '\u0646'; // ARABIC LETTER NOON
192: case 'N':
193: return '\u0646'; // ARABIC LETTER NOON
194: case 'o': //return '\u064F'; // ARABIC DAMMA
195: case 'O': //return '\u064F'; // ARABIC DAMMA
196: case 'p':
197: return '\u0628'; // ARABIC LETTER BEH
198: case 'P':
199: return '\u0628'; // ARABIC LETTER BEH
200: case 'q':
201: return '\u0642'; // ARABIC LETTER QAF
202: case 'Q':
203: return '\u0642'; // ARABIC LETTER QAF
204: case 'r':
205: return '\u0631'; // ARABIC LETTER REH
206: case 'R':
207: return '\u0631'; // ARABIC LETTER REH
208: case 's':
209: return '\u0633'; // ARABIC LETTER SEEN
210: case 'S':
211: return '\u0634'; // ARABIC LETTER SHEEN
212: case 't':
213: return '\u062A'; // ARABIC LETTER TEH
214: case 'T':
215: return '\u062B'; // ARABIC LETTER THEH
216: case 'U': //return '\u064C'; // ARABIC DAMMATAN
217: case 'u': //return '\u064F'; // ARABIC DAMMA
218: case 'v':
219: return '\u0641'; // ARABIC LETTER FEH
220: case 'V':
221: return '\u0641'; // ARABIC LETTER FEH
222: case 'w':
223: return '\u0648'; // ARABIC LETTER WAW
224: case 'W':
225: return '\u0648'; // ARABIC LETTER WAW
226: case 'x':
227: return '\u0633'; // ARABIC LETTER SEEN
228: case 'X':
229: return '\u0633'; // ARABIC LETTER SEEN
230: case 'y':
231: return '\u064A'; // ARABIC LETTER YEH
232: case 'Y':
233: return '\u064A'; // ARABIC LETTER YEH
234: case 'z':
235: return '\u0632'; // ARABIC LETTER ZAIN
236: case 'Z':
237: return '\u0638'; // ARABIC LETTER ZAH
238: }
239:
240: return c;
241: }
242: }
|