Lines 18-26
Link Here
|
18 |
|
18 |
|
19 |
package org.apache.fop.fonts; |
19 |
package org.apache.fop.fonts; |
20 |
|
20 |
|
21 |
// Java |
21 |
import java.util.ArrayList; |
|
|
22 |
import java.util.Collections; |
23 |
import java.util.Iterator; |
24 |
import java.util.List; |
22 |
import java.util.Map; |
25 |
import java.util.Map; |
23 |
|
26 |
|
|
|
27 |
|
24 |
/** |
28 |
/** |
25 |
* The FontInfo for the layout and rendering of a fo document. |
29 |
* The FontInfo for the layout and rendering of a fo document. |
26 |
* This stores the list of available fonts that are setup by |
30 |
* This stores the list of available fonts that are setup by |
Lines 226-231
Link Here
|
226 |
usedFonts.put(fontName, fonts.get(fontName)); |
230 |
usedFonts.put(fontName, fonts.get(fontName)); |
227 |
return (FontMetrics)fonts.get(fontName); |
231 |
return (FontMetrics)fonts.get(fontName); |
228 |
} |
232 |
} |
|
|
233 |
|
234 |
/** |
235 |
* Returns the first triplet matching the given font name. |
236 |
* As there may be multiple triplets matching the font name |
237 |
* the result set is sorted first to guarantee consistent results. |
238 |
* @param fontName The font name we are looking for |
239 |
* @return The first triplet for the given font name |
240 |
*/ |
241 |
private String getTripletFor(String fontName) { |
242 |
List foundTriplets = new ArrayList(); |
243 |
for (Iterator iter = triplets.entrySet().iterator(); iter.hasNext(); ) { |
244 |
Map.Entry tripletEntry = (Map.Entry) iter.next(); |
245 |
if (fontName.equals(((String)tripletEntry.getValue()))) { |
246 |
foundTriplets.add(tripletEntry.getKey()); |
247 |
} |
248 |
} |
249 |
if (foundTriplets.size() > 0) { |
250 |
Collections.sort(foundTriplets); |
251 |
return (String)foundTriplets.get(0); |
252 |
} |
253 |
return null; |
254 |
} |
255 |
|
256 |
/** |
257 |
* Returns the font style for a particular font. |
258 |
* There may be multiple font styles matching this font. Only the first |
259 |
* found is returned. Searching is done on a sorted list to guarantee consistent |
260 |
* results. |
261 |
* @param fontName internal key |
262 |
* @return font style |
263 |
*/ |
264 |
public String getFontStyleFor(String fontName) { |
265 |
String triplet = getTripletFor(fontName); |
266 |
if (triplet != null) { |
267 |
return triplet.substring(triplet.indexOf(',') + 1, triplet.lastIndexOf(',')); |
268 |
} |
269 |
return ""; |
270 |
} |
271 |
|
272 |
/** |
273 |
* Returns the font weight for a particular font. |
274 |
* There may be multiple font weights matching this font. Only the first |
275 |
* found is returned. Searching is done on a sorted list to guarantee consistent |
276 |
* results. |
277 |
* @param fontName internal key |
278 |
* @return font weight |
279 |
*/ |
280 |
public String getFontWeightFor(String fontName) { |
281 |
String triplet = getTripletFor(fontName); |
282 |
if (triplet != null) { |
283 |
return triplet.substring(triplet.lastIndexOf(',') + 1); |
284 |
} |
285 |
return ""; |
286 |
} |
287 |
|
229 |
} |
288 |
} |
230 |
|
289 |
|
231 |
|
290 |
|