Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
MinecraftFont.java
1 package org.bukkit.map;
2 
3 /**
4  * Represents the built-in Minecraft font.
5  */
6 public class MinecraftFont extends MapFont {
7 
8  private static final int spaceSize = 2;
9 
10  private static final String fontChars =
11  " !\"#$%&'()*+,-./0123456789:;<=>?" +
12  "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" +
13  "'abcdefghijklmnopqrstuvwxyz{|}~\u007F" +
14  "\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7" + // Çüéâäàåç
15  "\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5" + // êëèïîìÄÅ
16  "\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9" + // ÉæÆôöòûù
17  "\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0191" + // ÿÖÜø£Ø׃
18  "\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA" + // áíóúñѪº
19  "\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB"; // ¿®¬½¼¡«»
20 
21  private static final int[][] fontData = new int[][] {
22  /* null */ {0,0,0,0,0,0,0,0},
23  /* 1 */ {126,129,165,129,189,153,129,126},
24  /* 2 */ {126,255,219,255,195,231,255,126},
25  /* 3 */ {54,127,127,127,62,28,8,0},
26  /* 4 */ {8,28,62,127,62,28,8,0},
27  /* 5 */ {28,62,28,127,127,62,28,62},
28  /* 6 */ {8,8,28,62,127,62,28,62},
29  /* 7 */ {0,0,24,60,60,24,0,0},
30  /* 8 */ {255,255,231,195,195,231,255,255},
31  /* 9 */ {0,60,102,66,66,102,60,0},
32  /* 10 */ {255,195,153,189,189,153,195,255},
33  /* 11 */ {240,224,240,190,51,51,51,30},
34  /* 12 */ {60,102,102,102,60,24,126,24},
35  /* 13 */ {252,204,252,12,12,14,15,7},
36  /* 14 */ {254,198,254,198,198,230,103,3},
37  /* 15 */ {153,90,60,231,231,60,90,153},
38  /* 16 */ {1,7,31,127,31,7,1,0},
39  /* 17 */ {64,112,124,127,124,112,64,0},
40  /* 18 */ {24,60,126,24,24,126,60,24},
41  /* 19 */ {102,102,102,102,102,0,102,0},
42  /* 20 */ {254,219,219,222,216,216,216,0},
43  /* 21 */ {124,198,28,54,54,28,51,30},
44  /* 22 */ {0,0,0,0,126,126,126,0},
45  /* 23 */ {24,60,126,24,126,60,24,255},
46  /* 24 */ {24,60,126,24,24,24,24,0},
47  /* 25 */ {24,24,24,24,126,60,24,0},
48  /* 26 */ {0,24,48,127,48,24,0,0},
49  /* 27 */ {0,12,6,127,6,12,0,0},
50  /* 28 */ {0,0,3,3,3,127,0,0},
51  /* 29 */ {0,36,102,255,102,36,0,0},
52  /* 30 */ {0,24,60,126,255,255,0,0},
53  /* 31 */ {0,255,255,126,60,24,0,0},
54  /* */ {0,0,0,0,0,0,0,0},
55  /* ! */ {1,1,1,1,1,0,1,0},
56  /* " */ {10,10,5,0,0,0,0,0},
57  /* # */ {10,10,31,10,31,10,10,0},
58  /* $ */ {4,30,1,14,16,15,4,0},
59  /* % */ {17,9,8,4,2,18,17,0},
60  /* & */ {4,10,4,22,13,9,22,0},
61  /* ' */ {2,2,1,0,0,0,0,0},
62  /* ( */ {12,2,1,1,1,2,12,0},
63  /* ) */ {3,4,8,8,8,4,3,0},
64  /* * */ {0,0,9,6,9,0,0,0},
65  /* + */ {0,4,4,31,4,4,0,0},
66  /* , */ {0,0,0,0,0,1,1,1},
67  /* - */ {0,0,0,31,0,0,0,0},
68  /* . */ {0,0,0,0,0,1,1,0},
69  /* / */ {16,8,8,4,2,2,1,0},
70  /* 0 */ {14,17,25,21,19,17,14,0},
71  /* 1 */ {4,6,4,4,4,4,31,0},
72  /* 2 */ {14,17,16,12,2,17,31,0},
73  /* 3 */ {14,17,16,12,16,17,14,0},
74  /* 4 */ {24,20,18,17,31,16,16,0},
75  /* 5 */ {31,1,15,16,16,17,14,0},
76  /* 6 */ {12,2,1,15,17,17,14,0},
77  /* 7 */ {31,17,16,8,4,4,4,0},
78  /* 8 */ {14,17,17,14,17,17,14,0},
79  /* 9 */ {14,17,17,30,16,8,6,0},
80  /* : */ {0,1,1,0,0,1,1,0},
81  /* ; */ {0,1,1,0,0,1,1,1},
82  /* < */ {8,4,2,1,2,4,8,0},
83  /* = */ {0,0,31,0,0,31,0,0},
84  /* > */ {1,2,4,8,4,2,1,0},
85  /* ? */ {14,17,16,8,4,0,4,0},
86  /* @ */ {30,33,45,45,61,1,30,0},
87  /* A */ {14,17,31,17,17,17,17,0},
88  /* B */ {15,17,15,17,17,17,15,0},
89  /* C */ {14,17,1,1,1,17,14,0},
90  /* D */ {15,17,17,17,17,17,15,0},
91  /* E */ {31,1,7,1,1,1,31,0},
92  /* F */ {31,1,7,1,1,1,1,0},
93  /* G */ {30,1,25,17,17,17,14,0},
94  /* H */ {17,17,31,17,17,17,17,0},
95  /* I */ {7,2,2,2,2,2,7,0},
96  /* J */ {16,16,16,16,16,17,14,0},
97  /* K */ {17,9,7,9,17,17,17,0},
98  /* L */ {1,1,1,1,1,1,31,0},
99  /* M */ {17,27,21,17,17,17,17,0},
100  /* N */ {17,19,21,25,17,17,17,0},
101  /* O */ {14,17,17,17,17,17,14,0},
102  /* P */ {15,17,15,1,1,1,1,0},
103  /* Q */ {14,17,17,17,17,9,22,0},
104  /* R */ {15,17,15,17,17,17,17,0},
105  /* S */ {30,1,14,16,16,17,14,0},
106  /* T */ {31,4,4,4,4,4,4,0},
107  /* U */ {17,17,17,17,17,17,14,0},
108  /* V */ {17,17,17,17,10,10,4,0},
109  /* W */ {17,17,17,17,21,27,17,0},
110  /* X */ {17,10,4,10,17,17,17,0},
111  /* Y */ {17,10,4,4,4,4,4,0},
112  /* Z */ {31,16,8,4,2,1,31,0},
113  /* [ */ {7,1,1,1,1,1,7,0},
114  /* \ */ {1,2,2,4,8,8,16,0},
115  /* ] */ {7,4,4,4,4,4,7,0},
116  /* ^ */ {4,10,17,0,0,0,0,0},
117  /* _ */ {0,0,0,0,0,0,0,31},
118  /* ` */ {1,1,2,0,0,0,0,0},
119  /* a */ {0,0,14,16,30,17,30,0},
120  /* b */ {1,1,13,19,17,17,15,0},
121  /* c */ {0,0,14,17,1,17,14,0},
122  /* d */ {16,16,22,25,17,17,30,0},
123  /* e */ {0,0,14,17,31,1,30,0},
124  /* f */ {12,2,15,2,2,2,2,0},
125  /* g */ {0,0,30,17,17,30,16,15},
126  /* h */ {1,1,13,19,17,17,17,0},
127  /* i */ {1,0,1,1,1,1,1,0},
128  /* j */ {16,0,16,16,16,17,17,14},
129  /* k */ {1,1,9,5,3,5,9,0},
130  /* l */ {1,1,1,1,1,1,2,0},
131  /* m */ {0,0,11,21,21,17,17,0},
132  /* n */ {0,0,15,17,17,17,17,0},
133  /* o */ {0,0,14,17,17,17,14,0},
134  /* p */ {0,0,13,19,17,15,1,1},
135  /* q */ {0,0,22,25,17,30,16,16},
136  /* r */ {0,0,13,19,1,1,1,0},
137  /* s */ {0,0,30,1,14,16,15,0},
138  /* t */ {2,2,7,2,2,2,4,0},
139  /* u */ {0,0,17,17,17,17,30,0},
140  /* v */ {0,0,17,17,17,10,4,0},
141  /* w */ {0,0,17,17,21,21,30,0},
142  /* x */ {0,0,17,10,4,10,17,0},
143  /* y */ {0,0,17,17,17,30,16,15},
144  /* z */ {0,0,31,8,4,2,31,0},
145  /* { */ {12,2,2,1,2,2,12,0},
146  /* | */ {1,1,1,0,1,1,1,0},
147  /* } */ {3,4,4,8,4,4,3,0},
148  /* ~ */ {38,25,0,0,0,0,0,0},
149  /* ⌂ */ {0,0,4,10,17,17,31,0},
150  /* Ç */ {14,17,1,1,17,14,16,12},
151  /* ü */ {10,0,17,17,17,17,30,0},
152  /* é */ {24,0,14,17,31,1,30,0},
153  /* â */ {14,17,14,16,30,17,30,0},
154  /* ä */ {10,0,14,16,30,17,30,0},
155  /* à */ {3,0,14,16,30,17,30,0},
156  /* å */ {4,0,14,16,30,17,30,0},
157  /* ç */ {0,14,17,1,17,14,16,12},
158  /* ê */ {14,17,14,17,31,1,30,0},
159  /* ë */ {10,0,14,17,31,1,30,0},
160  /* è */ {3,0,14,17,31,1,30,0},
161  /* ï */ {5,0,2,2,2,2,2,0},
162  /* î */ {14,17,4,4,4,4,4,0},
163  /* ì */ {3,0,2,2,2,2,2,0},
164  /* Ä */ {17,14,17,31,17,17,17,0},
165  /* Å */ {4,0,14,17,31,17,17,0},
166  /* É */ {24,0,31,1,7,1,31,0},
167  /* æ */ {0,0,10,20,30,5,30,0},
168  /* Æ */ {30,5,15,5,5,5,29,0},
169  /* ô */ {14,17,14,17,17,17,14,0},
170  /* ö */ {10,0,14,17,17,17,14,0},
171  /* ò */ {3,0,14,17,17,17,14,0},
172  /* û */ {14,17,0,17,17,17,30,0},
173  /* ù */ {3,0,17,17,17,17,30,0},
174  /* ÿ */ {10,0,17,17,17,30,16,15},
175  /* Ö */ {17,14,17,17,17,17,14,0},
176  /* Ü */ {17,0,17,17,17,17,14,0},
177  /* ø */ {0,0,14,25,21,19,14,4},
178  /* £ */ {12,18,2,15,2,2,31,0},
179  /* Ø */ {14,17,25,21,19,17,14,0},
180  /* × */ {0,0,5,2,5,0,0,0},
181  /* ƒ */ {8,20,4,14,4,4,5,2},
182  /* á */ {24,0,14,16,30,17,30,0},
183  /* í */ {3,0,1,1,1,1,1,0},
184  /* ó */ {24,0,14,17,17,17,14,0},
185  /* ú */ {24,0,17,17,17,17,30,0},
186  /* ñ */ {31,0,15,17,17,17,17,0},
187  /* Ñ */ {31,0,17,19,21,25,17,0},
188  /* ª */ {14,16,31,30,0,31,0,0},
189  /* º */ {14,17,17,14,0,31,0,0},
190  /* ¿ */ {4,0,4,2,1,17,14,0},
191  /* ® */ {0,30,45,37,43,30,0,0},
192  /* ¬ */ {0,0,0,31,16,16,0,0},
193  /* ½ */ {17,9,8,4,18,10,25,0},
194  /* ¼ */ {17,9,8,4,26,26,17,0},
195  /* ¡ */ {0,1,0,1,1,1,1,0},
196  /* « */ {0,20,10,5,10,20,0,0},
197  /* » */ {0,5,10,20,10,5,0,0},
198  /* 176 */ {68,17,68,17,68,17,68,17},
199  /* 177 */ {170,85,170,85,170,85,170,85},
200  /* 178 */ {219,238,219,119,219,238,219,119},
201  /* 179 */ {24,24,24,24,24,24,24,24},
202  /* 180 */ {24,24,24,24,31,24,24,24},
203  /* 181 */ {24,24,31,24,31,24,24,24},
204  /* 182 */ {108,108,108,108,111,108,108,108},
205  /* 183 */ {0,0,0,0,127,108,108,108},
206  /* 184 */ {0,0,31,24,31,24,24,24},
207  /* 185 */ {108,108,111,96,111,108,108,108},
208  /* 186 */ {108,108,108,108,108,108,108,108},
209  /* 187 */ {0,0,127,96,111,108,108,108},
210  /* 188 */ {108,108,111,96,127,0,0,0},
211  /* 189 */ {108,108,108,108,127,0,0,0},
212  /* 190 */ {24,24,31,24,31,0,0,0},
213  /* 191 */ {0,0,0,0,31,24,24,24},
214  /* 192 */ {24,24,24,24,248,0,0,0},
215  /* 193 */ {24,24,24,24,255,0,0,0},
216  /* 194 */ {0,0,0,0,255,24,24,24},
217  /* 195 */ {24,24,24,24,248,24,24,24},
218  /* 196 */ {0,0,0,0,255,0,0,0},
219  /* 197 */ {24,24,24,24,255,24,24,24},
220  /* 198 */ {24,24,248,24,248,24,24,24},
221  /* 199 */ {108,108,108,108,236,108,108,108},
222  /* 200 */ {108,108,236,12,252,0,0,0},
223  /* 201 */ {0,0,252,12,236,108,108,108},
224  /* 202 */ {108,108,239,0,255,0,0,0},
225  /* 203 */ {0,0,255,0,239,108,108,108},
226  /* 204 */ {108,108,236,12,236,108,108,108},
227  /* 205 */ {0,0,255,0,255,0,0,0},
228  /* 206 */ {108,108,239,0,239,108,108,108},
229  /* 207 */ {24,24,255,0,255,0,0,0},
230  /* 208 */ {108,108,108,108,255,0,0,0},
231  /* 209 */ {0,0,255,0,255,24,24,24},
232  /* 210 */ {0,0,0,0,255,108,108,108},
233  /* 211 */ {108,108,108,108,252,0,0,0},
234  /* 212 */ {24,24,248,24,248,0,0,0},
235  /* 213 */ {0,0,248,24,248,24,24,24},
236  /* 214 */ {0,0,0,0,252,108,108,108},
237  /* 215 */ {108,108,108,108,255,108,108,108},
238  /* 216 */ {24,24,255,24,255,24,24,24},
239  /* 217 */ {24,24,24,24,31,0,0,0},
240  /* 218 */ {0,0,0,0,248,24,24,24},
241  /* 219 */ {255,255,255,255,255,255,255,255},
242  /* 220 */ {0,0,0,0,255,255,255,255},
243  /* 221 */ {15,15,15,15,15,15,15,15},
244  /* 222 */ {240,240,240,240,240,240,240,240},
245  /* 223 */ {255,255,255,255,0,0,0,0},
246  /* 224 */ {0,0,110,59,19,59,110,0},
247  /* 225 */ {0,30,51,31,51,31,3,3},
248  /* 226 */ {0,63,51,3,3,3,3,0},
249  /* 227 */ {0,127,54,54,54,54,54,0},
250  /* 228 */ {63,51,6,12,6,51,63,0},
251  /* 229 */ {0,0,126,27,27,27,14,0},
252  /* 230 */ {0,102,102,102,102,62,6,3},
253  /* 231 */ {0,110,59,24,24,24,24,0},
254  /* 232 */ {63,12,30,51,51,30,12,63},
255  /* 233 */ {28,54,99,127,99,54,28,0},
256  /* 234 */ {28,54,99,99,54,54,119,0},
257  /* 235 */ {56,12,24,62,51,51,30,0},
258  /* 236 */ {0,0,126,219,219,126,0,0},
259  /* 237 */ {96,48,126,219,219,126,6,3},
260  /* 238 */ {28,6,3,31,3,6,28,0},
261  /* 239 */ {30,51,51,51,51,51,51,0},
262  /* 240 */ {0,63,0,63,0,63,0,0},
263  /* 241 */ {12,12,63,12,12,0,63,0},
264  /* 242 */ {6,12,24,12,6,0,63,0},
265  /* 243 */ {24,12,6,12,24,0,63,0},
266  /* 244 */ {112,216,216,24,24,24,24,24},
267  /* 245 */ {24,24,24,24,24,27,27,14},
268  /* 246 */ {12,12,0,63,0,12,12,0},
269  /* 247 */ {0,110,59,0,110,59,0,0},
270  /* 248 */ {28,54,54,28,0,0,0,0},
271  /* 249 */ {0,0,0,24,24,0,0,0},
272  /* 250 */ {0,0,0,0,24,0,0,0},
273  /* 251 */ {240,48,48,48,55,54,60,56},
274  /* 252 */ {30,54,54,54,54,0,0,0},
275  /* 253 */ {14,24,12,6,30,0,0,0},
276  /* 254 */ {0,0,60,60,60,60,0,0},
277  /* 255 */ {0,0,0,0,0,0,0,0},
278  };
279 
280  /**
281  * A static non-malleable MinecraftFont.
282  */
283  public static final MinecraftFont Font = new MinecraftFont(false);
284 
285  /**
286  * Initialize a new MinecraftFont.
287  */
288  public MinecraftFont() {
289  this(true);
290  }
291 
292  private MinecraftFont(boolean malleable) {
293  for (int i = 1; i < fontData.length; ++i) {
294  char ch = (char) i;
295  if (i >= 32 && i < 32 + fontChars.length()) {
296  ch = fontChars.charAt(i - 32);
297  }
298 
299  if (ch == ' ') {
300  setChar(ch, new CharacterSprite(spaceSize, 8, new boolean[spaceSize * 8]));
301  continue;
302  }
303 
304  int[] rows = fontData[i];
305  int width = 0;
306  for (int r = 0; r < 8; ++r) {
307  for (int c = 0; c < 8; ++c) {
308  if ((rows[r] & (1 << c)) != 0 && c > width) {
309  width = c;
310  }
311  }
312  }
313  ++width;
314 
315  boolean[] data = new boolean[width * 8];
316  for (int r = 0; r < 8; ++r) {
317  for (int c = 0; c < width; ++c) {
318  data[r * width + c] = (rows[r] & (1 << c)) != 0;
319  }
320  }
321 
322  setChar(ch, new CharacterSprite(width, 8, data));
323  }
324 
325  this.malleable = malleable;
326  }
327 
328 }
static final MinecraftFont Font
void setChar(char ch, CharacterSprite sprite)
Definition: MapFont.java:21