1
2 package org.freehep.graphics2d.font;
3
4
5 public class FontEncoder {
6
7 private FontEncoder() {
8 }
9
10 public static String getEncodedString(String string, String tableName) {
11 CharTable charTable = Lookup.getInstance().getTable(tableName);
12 return getEncodedString(string, charTable);
13 }
14
15
16
17
18
19 public static String getEncodedString(String string, CharTable charTable) {
20 if (charTable == null)
21 return string;
22
23 StringBuffer s = new StringBuffer();
24 for (int i = 0; i < string.length(); i++) {
25 int enc = string.charAt(i);
26 String name = charTable.toName(enc);
27 s.append((name != null) ? charTable.toUnicode(name) : (char) enc);
28 }
29 return s.toString();
30 }
31
32 }