001: // ymage8BitFontGenerator.java
002: // ---------------------------
003: // by Marc Nause
004: // created: 05.04.2007
005: //
006: // based on:
007: // ymageFontGenerator.java
008: // ---------------------------
009: // (C) by Michael Peter Christen; mc@anomic.de
010: // first published on http://www.anomic.de
011: // Frankfurt, Germany, 2005
012: // created: 31.10.2005
013: //
014: // This program is free software; you can redistribute it and/or modify
015: // it under the terms of the GNU General Public License as published by
016: // the Free Software Foundation; either version 2 of the License, or
017: // (at your option) any later version.
018: //
019: // This program is distributed in the hope that it will be useful,
020: // but WITHOUT ANY WARRANTY; without even the implied warranty of
021: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
022: // GNU General Public License for more details.
023: //
024: // You should have received a copy of the GNU General Public License
025: // along with this program; if not, write to the Free Software
026: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
027: //
028: // Using this software in any meaning (reading, learning, copying, compiling,
029: // running) means that you agree that the Author(s) is (are) not responsible
030: // for cost, loss of data or any harm that may be caused directly or indirectly
031: // by usage of this softare or this documentation. The usage of this software
032: // is on your own risk. The installation and usage (starting/running) of this
033: // software may allow other people or application to access your computer and
034: // any attached devices and is highly dependent on the configuration of the
035: // software which must be done by the user of the software; the author(s) is
036: // (are) also not responsible for proper configuration and usage of the
037: // software, even if provoked by documentation provided together with
038: // the software.
039: //
040: // Any changes to this file according to the GPL as documented in the file
041: // gpl.txt aside this file in the shipment you received can be done to the
042: // lines that follows this copyright notice here, but changes must not be
043: // done inside the copyright notive above. A re-distribution must contain
044: // the intact and unchanged copyright notice.
045: // Contributions and changes to the program code must be marked as such.
046:
047: package de.anomic.ymage;
048:
049: public class ymage8BitFontGenerator {
050:
051: //A valid ymage font has 96 characters:
052:
053: /*
054: 0x20: !"#$%&'
055: 0x28:()*+,-./
056: 0x30:01234567
057: 0x38:89:;<=>?
058: 0x40:@ABCDEFG
059: 0x48:HIJKLMNO
060: 0x50:PQRSTUVW
061: 0x58:XYZ[\]^_
062: 0x60:`abcdefg
063: 0x68:hijklmno
064: 0x70:pqrstuvw
065: 0x78:xyz{|}~
066: */
067:
068: //Each character has the same height of m lines with n pixels each.
069: //While m does not need to equal n both have to stay consistend through
070: //the whole font.
071: public static final String[][] font = {
072: {
073: "........", //0x20
074: "........", "........", "........", "........",
075: "........", "........", "........" },
076: { "...X....", "...X....", "...X....", "...X....",
077: "...X....", "........", "...X....", "........" },
078: { "..X.X...", "..X.X...", "........", "........",
079: "........", "........", "........", "........" },
080: { "..X.X...", "..X.X...", "XXXXXXX.", "..X.X...",
081: "XXXXXXX.", "..X.X...", "..X.X...", "........" },
082: { "...XX...", ".XXXXXX.", "X..XX...", ".XXXXX..",
083: "...XX.X.", "XXXXXX..", "...X....", "........" },
084: { ".XX...X.", ".XX..X..", "....X...", "...X....",
085: "..X.....", ".X...XX.", "X....XX.", "........" },
086: { ".XX.....", "X..X....", ".XX.....", "..X...X.",
087: "X..X.X..", "X...X...", ".XXX..X.", "........" },
088: { "...X....", "...X....", "........", "........",
089: "........", "........", "........", "........" },
090: { "....X...", "...X....", "..X.....", "..X.....",
091: "..X.....", "...X....", "....X...", "........" },
092: { "...X....", "....X...", ".....X..", ".....X..",
093: ".....X..", "....X...", "...X....", "........" },
094: { "...X....", ".X.X.X..", "..XXX...", "XXXXXXX.",
095: "..XXX...", ".X..X.X.", "...X....", "........" },
096: { "........", "...X....", "...X....", ".XXXXX..",
097: "...X....", "...X....", "........", "........" },
098: { "........", "........", "........", "........",
099: "........", "...XX...", "...XX...", "....X..." },
100: { "........", "........", "........", ".XXXXX..",
101: "........", "........", "........", "........" },
102: { "........", "........", "........", "........",
103: "........", "...XX...", "...XX...", "........" },
104: { "......X.", ".....X..", "....X...", "...X....",
105: "..X.....", ".X......", "X.......", "........" },
106: { ".XXXXX..", "X....XX.", "X...X.X.", "X..X..X.",
107: "X.X...X.", "XX....X.", ".XXXXX..", "........" },
108: { "...X....", "..XX....", ".X.X....", "...X....",
109: "...X....", "...X....", ".XXXXX..", "........" },
110: { "..XXX...", ".X...X..", ".....X..", "....X...",
111: "...X....", "..X.....", ".XXXXX..", "........" },
112: { "..XXX...", ".X...X..", ".....X..", "...XX...",
113: ".....X..", ".X...X..", "..XXX...", "........" },
114: { ".....X..", "....XX..", "...X.X..", "..X..X..",
115: ".XXXXXX.", ".....X..", ".....X..", "........" },
116: { ".XXXXXX.", ".X......", ".X......", ".XXXXX..",
117: "......X.", "......X.", ".XXXXX..", "........" },
118: { "..XXX...", ".X...X..", ".X......", ".XXXX...",
119: ".X...X..", ".X...X..", "..XXX...", "........" },
120: { ".XXXXX..", ".....X..", ".....X..", "....X...",
121: "...X....", "...X....", "...X....", "........" },
122: { "..XXX...", ".X...X..", ".X...X..", "..XXX...",
123: ".X...X..", ".X...X..", "..XXX...", "........" },
124: { "..XXX...", ".X...X..", ".X...X..", "..XXXX..",
125: ".....X..", ".X...X..", "..XXX...", "........" },
126: { "........", "........", "...XX...", "...XX...",
127: "........", "...XX...", "...XX...", "........" },
128: { "........", "........", "...XX...", "...XX...",
129: "........", "...XX...", "...XX...", "....X..." },
130: { ".....XX.", "...XX...", ".XX.....", "X.......",
131: ".XX.....", "...XX...", ".....XX.", "........" },
132: { "........", "........", "..XXXX..", "........",
133: "..XXXX..", "........", "........", "........" },
134: { "XX......", "..XX....", "....XX..", "......X.",
135: "....XX..", "..XX....", "XX......", "........", },
136: { "..XXX...", ".X...X..", ".....X..", "....X...",
137: "...X....", "........", "...X....", "........" },
138: { ".XXXXX..", "X.....X.", "X...XXX.", "X..X..X.",
139: "X...XXX.", "X.......", ".XXXXXX.", "........" },
140: { ".XXXXX..", "X.....X.", "X.....X.", "XXXXXXX.",
141: "X.....X.", "X.....X.", "X.....X.", "........" },
142: { "XXXXXX..", "X.....X.", "X.....X.", "XXXXXX..",
143: "X.....X.", "X.....X.", "XXXXXX..", "........" },
144: { "..XXXX..", ".X....X.", "X.......", "X.......",
145: "X.......", ".X....X.", "..XXXX..", "........" },
146: { "XXXXX...", "X....X..", "X.....X.", "X.....X.",
147: "X.....X.", "X....X..", "XXXXX...", "........" },
148: { "XXXXXXX.", "X.......", "X.......", "XXXXXX..",
149: "X.......", "X.......", "XXXXXXX.", "........" },
150: { "XXXXXXX.", "X.......", "X.......", "XXXXXX..",
151: "X.......", "X.......", "X.......", "........" },
152: { ".XXXXX..", "X.......", "X.......", "X..XXXX.",
153: "X.....X.", "X.....X.", ".XXXXX..", "........" },
154: { "X.....X.", "X.....X.", "X.....X.", "XXXXXXX.",
155: "X.....X.", "X.....X.", "X.....X.", "........" },
156: { "..XXX...", "...X....", "...X....", "...X....",
157: "...X....", "...X....", "..XXX...", "........" },
158: { "...XXX..", "....X...", "....X...", "....X...",
159: "....X...", "X...X...", ".XXX....", "........" },
160: { "X....XX.", "X...XX..", "X..XX...", "XXX.....",
161: "X..XX...", "X...XX..", "X....XX.", "........" },
162: { "X.......", "X.......", "X.......", "X.......",
163: "X.......", "X.......", "XXXXXXX.", "........" },
164: { "X.....X.", "XX...XX.", "X.X.X.X.", "X..X..X.",
165: "X.....X.", "X.....X.", "X.....X.", "........" },
166: { "X.....X.", "XX....X.", "X.X...X.", "X..X..X.",
167: "X...X.X.", "X....XX.", "X.....X.", "........" },
168: { ".XXXXX..", "X.....X.", "X.....X.", "X.....X.",
169: "X.....X.", "X.....X.", ".XXXXX..", "........" },
170: { "XXXXXX..", "X.....X.", "X.....X.", "XXXXXX..",
171: "X.......", "X.......", "X.......", "........" },
172: { ".XXXXX..", "X.....X.", "X.....X.", "X.....X.",
173: "X.....X.", "X...X.X.", ".XXXXX..", "......X." },
174: { "XXXXXX..", "X.....X.", "X.....X.", "XXXXXX..",
175: "X...X...", "X....X..", "X.....X.", "........" },
176: { ".XXXXX..", "X.....X.", "X.......", ".XXXXX..",
177: "......X.", "X.....X.", ".XXXXX..", "........" },
178: { "XXXXXXX.", "...X....", "...X....", "...X....",
179: "...X....", "...X....", "...X....", "........" },
180: { "X.....X.", "X.....X.", "X.....X.", "X.....X.",
181: "X.....X.", "X.....X.", ".XXXXX..", "........" },
182: { "X.....X.", "X.....X.", "X.....X.", "X.....X.",
183: ".X...X..", "..X.X...", "...X....", "........" },
184: { "X.....X.", "X.....X.", "X.....X.", "X.....X.",
185: "X..X..X.", "X.X.X.X.", ".X...X..", "........" },
186: { "X.....X.", ".X...X..", "..X.X...", "...X....",
187: "..X.X...", ".X...X..", "X.....X.", "........" },
188: { "X.....X.", ".X...X..", "..X.X...", "...X....",
189: "...X....", "...X....", "...X....", "........" },
190: { "XXXXXXX.", ".....X..", "....X...", "...X....",
191: "..X.....", ".X......", "XXXXXXX.", "........" },
192: { "..XXXX..", "..X.....", "..X.....", "..X.....",
193: "..X.....", "..X.....", "..XXXX..", "........" },
194: { "X.......", ".X......", "..X.....", "...X....",
195: "....X...", ".....X..", "......X.", "........" },
196: { "..XXXX..", ".....X..", ".....X..", ".....X..",
197: ".....X..", ".....X..", "..XXXX..", "........" },
198: { "...X....", "..X.X...", ".X...X..", "........",
199: "........", "........", "........", "........" },
200: { "........", "........", "........", "........",
201: "........", "........", "XXXXXXX.", "........" },
202: { "...X....", "....X...", "........", "........",
203: "........", "........", "........", "........" },
204: { "........", "........", ".XXXX...", ".....X..",
205: ".XXXXX..", "X....X..", ".XXXX.X.", "........" },
206: { "X.......", "X.......", "X.......", "XXXXXX..",
207: "X.....X.", "X.....X.", "XXXXXX..", "........" },
208: { "........", "........", ".XXXXXX.", "X.......",
209: "X.......", "X.......", ".XXXXXX.", "........" },
210: { "......X.", "......X.", "......X.", ".XXXXXX.",
211: "X.....X.", "X.....X.", ".XXXXXX.", "........" },
212: { "........", "........", ".XXXXX..", "X.....X.",
213: "XXXXXXX.", "X.......", ".XXXXX..", "........" },
214: { "...XX...", "..X.....", "..X.....", ".XXX....",
215: "..X.....", "..X.....", "..X.....", "........" },
216: { "........", "........", ".XXXXX..", "X.....X.",
217: "X.....X.", ".XXXXXX.", "......X.", ".XXXXX.." },
218: { "X.......", "X.......", "X.......", "XXXXXX..",
219: "X.....X.", "X.....X.", "X.....X.", "........" },
220: { "........", "...X....", "........", "..XX....",
221: "...X....", "...X....", "..XXX...", "........" },
222: { "........", "....X...", "........", "...XX...",
223: "....X...", "....X...", "....X...", "..XX...." },
224: { "X.......", "X.......", "X....XX.", "X..XX...",
225: "XXX.....", "X..XX...", "X....XX.", "........" },
226: { "..XX....", "...X....", "...X....", "...X....",
227: "...X....", "...X....", "..XXX...", "........" },
228: { "........", "........", ".XX.XX..", "X..X..X.",
229: "X..X..X.", "X..X..X.", "X..X..X.", "........" },
230: { "........", "........", ".XXXXX..", "X.....X.",
231: "X.....X.", "X.....X.", "X.....X.", "........" },
232: { "........", "........", ".XXXXX..", "X.....X.",
233: "X.....X.", "X.....X.", ".XXXXX..", "........" },
234: { "........", "........", "XXXXXX..", "X.....X.",
235: "X.....X.", "XXXXXX..", "X.......", "X......." },
236: { "........", "........", ".XXXXXX.", "X.....X.",
237: "X.....X.", ".XXXXXX.", "......X.", "......X." },
238: { "........", "........", "X.XXXX..", "XX....X.",
239: "X.......", "X.......", "X.......", "........" },
240: { "........", "........", ".XXXXX..", "X.......",
241: ".XXXXX..", "......X.", ".XXXXX..", "........" },
242: { "...X....", "...X....", "...X....", ".XXXXX..",
243: "...X....", "...X....", "....XX..", "........" },
244: { "........", "........", "X.....X.", "X.....X.",
245: "X.....X.", "X.....X.", ".XXXXX..", "........" },
246: { "........", "........", "X.....X.", "X.....X.",
247: ".X...X..", "..X.X...", "...X....", "........" },
248: { "........", "........", "X.....X.", "X.....X.",
249: "X..X..X.", "X.X.X.X.", ".X...X..", "........" },
250: { "........", "........", "X.....X.", ".XX.XX..",
251: "...X....", ".XX.XX..", "X.....X.", "........" },
252: { "........", "........", "X.....X.", "X.....X.",
253: "X.....X.", ".XXXXXX.", "......X.", ".XXXXX.." },
254: { "........", "........", "XXXXXXX.", "....XX..",
255: "...X....", ".XX.....", "XXXXXXX.", "........" },
256: { "...XX...", "..X.....", "..X.....", "XX......",
257: "..X.....", "..X.....", "...XX...", "........" },
258: { "...X....", "...X....", "...X....", "...X....",
259: "...X....", "...X....", "...X....", "...X...." },
260: { "...XX...", ".....X..", ".....X..", "......XX",
261: ".....X..", ".....X..", "...XX...", "........" },
262: { "........", "........", "..X.....", ".X.XX.X.",
263: ".....X..", "........", "........", "........" },
264: { "XXXXXXX.", "X.....X.", "X.....X.", "X.....X.",
265: "X.....X.", "X.....X.", "XXXXXXX.", "........" },
266:
267: };
268:
269: public static void main(String[] args) {
270: String[] letter;
271: int b;
272: int v;
273: int c = 0;
274: int n = -1;
275: int m = -1;
276: String s;
277:
278: //check if font has correct number of letters
279: if (font.length != 96) {
280: System.out.println("\nWARNING: Font has " + font.length
281: + " letters, should have 96 letters.");
282: System.out.println(" Font will be invalid!\n");
283: }
284:
285: for (int i = 0; i < font.length; i++) {
286: letter = font[i];
287: b = 0;
288:
289: //check if all letters have same numbers of lines
290: if ((letter.length != n) && (n == -1)) {
291: n = letter.length;
292: } else if (letter.length != n) {
293: System.out.println("\n\nWARNING: Letter number " + i
294: + " has different number of lines ("
295: + letter.length + ") than predecessors (" + n
296: + ").");
297: System.out.println(" Font will be invalid!\n");
298: }
299:
300: for (int j = 0; j < letter.length; j++) {
301:
302: b = b << letter[j].length();
303: v = 16;
304:
305: //check if all letters have same number of lines
306: if ((letter[j].length() != m) && (m == -1)) {
307: m = letter[j].length();
308: } else if (letter[j].length() != m) {
309: System.out.println("\n\nWARNING: Letter number "
310: + i + " has a different number of bits ("
311: + letter[j].length()
312: + ") than predecessors (" + m
313: + ") in line " + j + ".");
314: System.out
315: .println(" Font will be invalid!\n");
316: }
317:
318: for (int col = 0; col < letter[j].length(); col++) {
319:
320: if (letter[j].charAt(col) == 'X')
321: b += v;
322: v = v >> 1;
323: }
324: }
325: s = Long.toHexString(b).toUpperCase();
326: while (s.length() < (letter.length * m / 8))
327: s = "0" + s;
328: System.out.print("0x" + s + ",");
329: c++;
330: if (c >= 8) {
331: System.out.println();
332: c = 0;
333: }
334: }
335: }
336:
337: }
|