Lines 19-24
Link Here
|
19 |
|
19 |
|
20 |
package org.apache.fop.fonts; |
20 |
package org.apache.fop.fonts; |
21 |
|
21 |
|
|
|
22 |
import java.util.HashMap; |
22 |
import java.util.Iterator; |
23 |
import java.util.Iterator; |
23 |
import java.util.List; |
24 |
import java.util.List; |
24 |
import java.util.Map; |
25 |
import java.util.Map; |
Lines 26-31
Link Here
|
26 |
|
27 |
|
27 |
import org.apache.commons.logging.Log; |
28 |
import org.apache.commons.logging.Log; |
28 |
import org.apache.commons.logging.LogFactory; |
29 |
import org.apache.commons.logging.LogFactory; |
|
|
30 |
import org.apache.xmlgraphics.fonts.Glyphs; |
29 |
|
31 |
|
30 |
/** |
32 |
/** |
31 |
* Generic SingleByte font |
33 |
* Generic SingleByte font |
Lines 43-48
Link Here
|
43 |
private Map unencodedCharacters; |
45 |
private Map unencodedCharacters; |
44 |
//Map<Character, UnencodedCharacter> |
46 |
//Map<Character, UnencodedCharacter> |
45 |
private List additionalEncodings; |
47 |
private List additionalEncodings; |
|
|
48 |
private Map alternativeCodes; |
46 |
|
49 |
|
47 |
|
50 |
|
48 |
/** |
51 |
/** |
Lines 98-116
Link Here
|
98 |
return arr; |
101 |
return arr; |
99 |
} |
102 |
} |
100 |
|
103 |
|
|
|
104 |
/** |
105 |
* Lookup a charachter using its alternative names. |
106 |
* If found, cache it so we can speed up lookups. |
107 |
* |
108 |
* @param c |
109 |
* @return |
110 |
*/ |
111 |
private char findAltertnative(char c) { |
112 |
char d; |
113 |
if(alternativeCodes == null){ |
114 |
alternativeCodes = new HashMap(); |
115 |
} else{ |
116 |
if(alternativeCodes.containsKey(c)){ |
117 |
return (Character) alternativeCodes.get(c); |
118 |
} |
119 |
} |
120 |
String charName = Glyphs.charToGlyphName(c); |
121 |
String[] charNameAlternatives = Glyphs.getCharNameAlternativesFor(charName); |
122 |
if (charNameAlternatives != null && charNameAlternatives.length > 0) { |
123 |
for (int i = 0; i < charNameAlternatives.length; i++) { |
124 |
if(log.isDebugEnabled()){ |
125 |
log.debug("Replacing checking alternatives for char " + c + "( charname=" +charName+") :" + charNameAlternatives[i]); |
126 |
} |
127 |
String s = Glyphs.getUnicodeSequenceForGlyphName(charNameAlternatives[i]); |
128 |
if (s != null) { |
129 |
d = lookUpChar(s.charAt(0)); |
130 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
131 |
alternativeCodes.put(c,d); |
132 |
return d; |
133 |
} |
134 |
} |
135 |
} |
136 |
} |
137 |
|
138 |
return SingleByteEncoding.NOT_FOUND_CODE_POINT; |
139 |
} |
140 |
/** |
141 |
* Lookup for a charachter.. |
142 |
* @param c |
143 |
* @return |
144 |
*/ |
145 |
private char lookUpChar(char c) { |
146 |
char d = mapping.mapChar(c); |
147 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
148 |
return d; |
149 |
} |
150 |
|
151 |
// Check unencoded characters which are available in the font by |
152 |
// character name |
153 |
d = mapUnencodedChar(c); |
154 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
155 |
return d; |
156 |
} |
157 |
return SingleByteEncoding.NOT_FOUND_CODE_POINT; |
158 |
} |
159 |
|
101 |
/** {@inheritDoc} */ |
160 |
/** {@inheritDoc} */ |
102 |
public char mapChar(char c) { |
161 |
public char mapChar(char c) { |
103 |
notifyMapOperation(); |
162 |
notifyMapOperation(); |
104 |
char d = mapping.mapChar(c); |
163 |
char d = lookUpChar(c); |
105 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
164 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
106 |
return d; |
165 |
return d; |
107 |
} |
166 |
} else { |
108 |
|
167 |
// Check for alternative |
109 |
//Check unencoded characters which are available in the font by character name |
168 |
d = findAltertnative(c); |
110 |
d = mapUnencodedChar(c); |
169 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
111 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
170 |
return d; |
112 |
return d; |
171 |
} |
113 |
} |
172 |
} |
114 |
this.warnMissingGlyph(c); |
173 |
this.warnMissingGlyph(c); |
115 |
return Typeface.NOT_FOUND; |
174 |
return Typeface.NOT_FOUND; |
116 |
} |
175 |
} |
Lines 160-165
Link Here
|
160 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
219 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
161 |
return true; |
220 |
return true; |
162 |
} |
221 |
} |
|
|
222 |
// Check if an alternative exists |
223 |
d = findAltertnative(c); |
224 |
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
225 |
return true; |
226 |
} |
163 |
return false; |
227 |
return false; |
164 |
} |
228 |
} |
165 |
|
229 |
|