/* Date: January 14th, 1995 Version: 1.0b3 Updated: Fixed possible ArrayOutOfBounds exception/error in the GetLine method. Fixed a few font bugs. Version: 1.0b2 Updated: Reconfigured font array to correspond to the ISO8859 alphabet and added fonts to correspond. Fonts are now 11 pixels high by 5 pixels wide. An extra blank line is added to the right. Letters are drawn within a 9 pixel box with 2 pixels permitted below the base line and above the ascent line for characters like small j and y and accents. Version: 1.0b1 Description: This is a data object for storing the Ticker Tape's 5x7 LED fonts. Although each character is designed into a 5 x 7 matrix as with some real life LEDs the actual LEDs turned on in the 5 x 7 matrix are returned one line at a time (one of 5 lines). Note also that there are in fact 6 lines per character, the reasoning behind that is to place a space line between each character - this might have been done more easily at a higher level - you can chose to ignore this line by reading in the first five lines of each character. Each line is encoded as a 7 bit digit with bit 0 at the top. For example, to have all 7 LEDs turned on is equivalent to the number 127; to have the top LED turned on is equivalent to the number 1. This class is only used once by the Ticker Tape class - whence the sloppy or lazy coding practice. Most but not necessarily all 7 bit ASCII characters have been coded. Coder: John Criswick, Ottawa, criswick@conveyor.com Copyright (c) 1995, 1996 John R. Criswick. All rights reserved. */ public class TickerFont { /* These are the 11 bit font definitions. Note that each is 6 pixels wide and that the 6th is always 0 in this code. Based on the ISO 8859 standard for which I used the following URL as a reference on January 4 - 5, 1996: http://www.bbsinc.com/iso8859.html In the following table, the hex value is the actual ASCII value. I only show the occasional hex value. The index value is the index into this font array. Note that I chop out some of the ASCII definitions as they are not used or needed (e.g. control characters). */ int itsData[][] = { // Starting at hex 0x20 character hex index {0, 0, 0, 0, 0, 0}, // space 0x20 0 {0, 0, 380, 0, 0, 0}, // ! 0x21 1 {0, 12, 0, 12, 0, 0}, // " 2 {80, 248, 80, 248, 80, 0}, // # 3 {16, 168, 508, 168, 64, 0}, // $ 4 {140, 76, 32, 400, 392, 0}, // % 5 {200, 308, 340, 136, 320, 0}, // & 6 {0, 0, 12, 0, 0, 0}, // ' 7 {0, 248, 260, 0, 0, 0}, // ( 8 {0, 0, 260, 248, 0, 0}, // ) 9 {168, 112, 508, 112, 168, 0}, // * 10 {0, 32, 112, 32, 0, 0}, // + 11 {0, 512, 384, 0, 0, 0}, // , 12 {0, 32, 32, 32, 0, 0}, // - 13 {0, 0, 256, 0, 0, 0}, // . 14 {128, 64, 32, 16, 8, 0}, // / 15 {112, 136, 260, 136, 112, 0}, // 0 0x30 16 {0, 272, 508, 256, 0, 0}, // 1 17 {408, 324, 324, 292, 280, 0}, // 2 18 {136, 260, 260, 292, 216, 0}, // 3 19 {48, 40, 36, 508, 32, 0}, // 4 20 {316, 292, 292, 292, 192, 0}, // 5 21 {248, 292, 292, 292, 192, 0}, // 6 22 {0, 4, 388, 100, 28, 0}, // 7 23 {216, 292, 292, 292, 216, 0}, // 8 24 {24, 292, 292, 292, 248, 0}, // 9 25 {0, 0, 160, 0, 0, 0}, // : 26 {0, 512, 416, 0, 0, 0}, // ; 27 {0, 32, 80, 136, 0, 0}, // < 28 {0, 80, 80, 80, 0, 0}, // = 29 {0, 136, 80, 32, 0, 0}, // > 30 {8, 4, 324, 36, 24, 0}, // ? 31 {248, 260, 372, 340, 56, 0}, // @ 0x40 32 {496, 72, 68, 72, 496, 0}, // A 33 {508, 292, 292, 292, 216, 0}, // B 34 {248, 260, 260, 260, 136, 0}, // C 35 {508, 260, 260, 260, 248, 0}, // D 36 {508, 292, 292, 292, 260, 0}, // E 37 {508, 36, 36, 4, 4, 0}, // F 38 {248, 260, 260, 292, 232, 0}, // G 39 {508, 32, 32, 32, 508, 0}, // H 40 {0, 0, 508, 0, 0, 0}, // I 41 {192, 256, 256, 256, 252, 0}, // J 42 {508, 32, 80, 136, 260, 0}, // K 43 {508, 256, 256, 256, 256, 0}, // L 44 {508, 8, 16, 8, 508, 0}, // M 45 {508, 8, 16, 32, 508, 0}, // N 46 {248, 260, 260, 260, 248, 0}, // O 47 {508, 36, 36, 36, 24, 0}, // P 0x50 48 {248, 260, 324, 388, 504, 0}, // Q 49 {508, 36, 100, 164, 280, 0}, // R 50 {152, 292, 292, 292, 200, 0}, // S 51 {4, 4, 508, 4, 4, 0}, // T 52 {252, 256, 256, 256, 252, 0}, // U 53 {124, 128, 256, 128, 124, 0}, // V 54 {252, 256, 128, 256, 252, 0}, // W 55 {260, 136, 112, 136, 260, 0}, // X 56 {12, 16, 480, 16, 12, 0}, // Y 57 {388, 324, 292, 276, 268, 0}, // Z 58 {0, 508, 260, 260, 0, 0}, // [ 59 {8, 16, 32, 64, 128, 0}, // \ 60 {0, 260, 260, 508, 0, 0}, // ] 61 {0, 32, 16, 32, 0, 0}, // ^ 62 {256, 256, 256, 256, 256, 0}, // _ 63 {0, 4, 8, 0, 0, 0}, // ` 64 {128, 336, 336, 224, 256, 0}, // a 0x60 65 {508, 288, 272, 272, 224, 0}, // b 66 {224, 272, 272, 272, 0, 0}, // c 67 {224, 272, 272, 292, 508, 0}, // d 68 {224, 336, 336, 336, 96, 0}, // e 69 {16, 504, 20, 4, 0, 0}, // f 70 {224, 1296, 1296, 1296, 992, 0}, // g 71 {4, 508, 16, 16, 480, 0}, // h 72 {0, 0, 500, 0, 0, 0}, // i 73 {512, 1024, 1012, 0, 0, 0}, // j 74 {0, 508, 64, 160, 272, 0}, // k 75 {0, 4, 508, 0, 0, 0}, // l 76 {480, 16, 96, 16, 480, 0}, // m 77 {496, 16, 16, 480, 0, 0}, // n 78 {224, 272, 272, 272, 224, 0}, // o 79 {2032, 160, 272, 272, 224, 0}, // p 0x70 80 {224, 272, 272, 160, 2032, 0}, // q 81 {0, 496, 32, 16, 16, 0}, // r 82 {288, 336, 336, 336, 144, 0}, // s 83 {0, 16, 252, 272, 0, 0}, // t 84 {240, 256, 256, 256, 240, 0}, // u 85 {48, 192, 256, 192, 48, 0}, // v 86 {240, 256, 192, 256, 240, 0}, // w 87 {272, 160, 64, 160, 272, 0}, // x 88 {0, 1264, 1280, 768, 240, 0}, // y 89 {272, 400, 336, 304, 272, 0}, // z 90 {0, 32, 216, 260, 0, 0}, // { 91 {0, 0, 508, 0, 0, 0}, // | 92 {0, 260, 216, 32, 0, 0}, // } 93 {32, 16, 32, 64, 32, 0}, // ~ 94 // Skip ISO8859 characters 127 to 160 // (I don't implement a non-breaking space) // hex index {0, 0, 500, 0, 0, 0}, // 0xa1 95 {224, 272, 1016, 272, 0, 0}, // cent 96 {278, 249, 273, 273, 128, 0}, // pound sterline 97 {136, 112, 80, 112, 136, 0}, // currency 98 {44, 56, 488, 56, 44, 0}, // Yen 99 {0, 0, 476, 0, 0, 0}, // Broken bar 100 {56, 340, 340, 340, 224, 0}, // 101 {0, 4, 0, 4, 0, 0}, // 102 {248, 372, 396, 340, 248, 0}, // 103 {80, 106, 106, 106, 124, 0}, // fem ordinal 104 {32, 80, 168, 80, 136, 0}, // l. angle quotes 105 {32, 32, 32, 32, 224, 0}, // not sign 106 {32, 32, 32, 32, 32, 0}, // hyphen 107 {500, 212, 292, 260, 504, 0}, // reg mark 108 {0, 4, 4, 4, 0, 0}, // - 109 {0, 7, 5, 7, 0, 0}, // 0xb0 110 {0, 160, 240, 160, 0, 0}, // 111 {0, 9, 13, 11, 0, 0}, // Super 2 112 {0, 9, 11, 13, 0, 0}, // Super 3 113 {0, 4, 2, 0, 0, 0}, // 114 {1024, 1008, 256, 256, 240, 0}, // 115 {24, 36, 36, 508, 508, 0}, // 116 {0, 56, 56, 56, 0, 0}, // 117 {0, 1024, 1536, 0, 0, 0}, // spacing cedilla 118 {0, 2, 15, 0, 0, 0}, // Super 1 119 {92, 98, 98, 98, 92, 0}, // masc ordinal 120 {136, 80, 168, 80, 32, 0}, // r. angle quotes 121 {132, 94, 160, 208, 488, 0}, // 1/4 122 {68, 62, 336, 424, 320, 0}, // 1/2 123 {146, 86, 186, 208, 488, 0}, // 3/4 124 {128, 256, 276, 288, 192, 0}, // inverted ques 125 {496, 73, 70, 72, 496, 0}, // 0xc0 126 {496, 74, 69, 72, 496, 0}, // A acute 127 {496, 74, 69, 74, 496, 0}, // A circ 128 {498, 73, 70, 73, 496, 0}, // A tild 129 {496, 74, 68, 74, 496, 0}, // A uml 130 {496, 75, 71, 75, 496, 0}, // A ring 131 {504, 36, 508, 292, 292, 0}, // 132 {248, 1284, 1796, 260, 136, 0}, // cedil 133 {508, 293, 294, 292, 292, 0}, // E grave 134 {508, 294, 293, 292, 292, 0}, // 135 {508, 294, 293, 294, 292, 0}, // E circ 136 {508, 294, 292, 294, 292, 0}, // E uml 137 {0, 0, 509, 2, 0, 0}, // I grave 138 {0, 2, 509, 0, 0, 0}, // I acute 139 {0, 2, 509, 2, 0, 0}, // I circ 140 {0, 2, 508, 2, 0, 0}, // I uml 141 {0, 0, 128, 320, 0, 0}, // eth 142 {510, 9, 18, 33, 508, 0}, // 0xd1 143 {248, 261, 262, 260, 248, 0}, // O grave 144 {248, 262, 261, 260, 248, 0}, // O acute 145 {248, 262, 261, 262, 248, 0}, // O circ 146 {250, 261, 262, 261, 248, 0}, // O tild 147 {248, 262, 260, 262, 248, 0}, // O uml 148 {0, 80, 32, 80, 0, 0}, // times sign 149 {240, 200, 168, 152, 120, 0}, // O slash 150 {252, 257, 258, 256, 252, 0}, // U grave 151 {252, 258, 257, 256, 252, 0}, // U acute 152 {252, 258, 257, 258, 252, 0}, // U circ 153 {252, 258, 256, 258, 252, 0}, // U uml 154 {12, 18, 481, 16, 12, 0}, // Y acute 155 {16, 504, 20, 492, 0, 0}, // THORN 156 {508, 276, 276, 296, 192, 0}, // sharp s 157 {128, 338, 340, 224, 256, 0}, // a grave 0xe0 158 {128, 340, 338, 224, 256, 0}, // 159 {128, 340, 338, 228, 256, 0}, // 160 {132, 338, 340, 226, 256, 0}, // 161 {128, 340, 336, 228, 256, 0}, // a uml 162 {128, 342, 342, 224, 256, 0}, // a ring 163 {400, 336, 224, 336, 352, 0}, // 164 {224, 1296, 1808, 272, 0, 0}, // 165 {224, 338, 340, 336, 96, 0}, // 166 {224, 340, 338, 336, 96, 0}, // 167 {224, 340, 338, 340, 96, 0}, // 168 {224, 340, 336, 340, 96, 0}, // e uml 169 {0, 2, 500, 0, 0, 0}, // 170 {0, 4, 498, 0, 0, 0}, // 171 {0, 4, 498, 4, 0, 0}, // 172 {0, 4, 496, 4, 0, 0}, // 173 {0, 0, 280, 128, 0, 0}, // eth 0xf0 174 {500, 18, 20, 482, 0, 0}, // 175 {224, 274, 276, 272, 224, 0}, // 176 {224, 276, 274, 272, 224, 0}, // 177 {224, 276, 274, 276, 224, 0}, // 178 {228, 274, 276, 274, 224, 0}, // 179 {224, 276, 272, 276, 224, 0}, // 180 {32, 32, 168, 32, 32, 0}, // 181 {224, 400, 336, 304, 224, 0}, // 182 {240, 258, 260, 256, 240, 0}, // 183 {240, 260, 258, 256, 240, 0}, // 184 {240, 260, 258, 260, 240, 0}, // 185 {240, 260, 256, 260, 240, 0}, // 186 {0, 1268, 1282, 768, 240, 0}, // y acute 187 {16, 504, 20, 508, 0, 0}, // thorn 188 {0, 1268, 1280, 772, 240, 0} // y uml 0xff 189 }; public void TickerFont() { } /* Method to obtain the above data line by line (each character is composed of 6 vertical lines in). In order to get the entire definition for a character this routine will need to be called 6 times... */ public int GetLine(char theCharacter, int theLine) { int index; index = (int) theCharacter & 0x00ff; // I don't do characters between 127 and 160 if ((index >= 127) && (index <= 160)) { index = 32; // default to a space character } else if (index > 160) { index -= 34; } // Subtract 32 because we start index=0 at the space character // (space character is ASCII 32 or hex 0x20) index -= 32; /* Make sure the index is within the bounds of the array as opposed to having to deal with an ArrayOutOfBounds exception. 0 is equivalent to a space character so that seems a reasonable error character to return. */ if (index < 0) { index = 0; } else if (index > 189) { index = 0; } return (itsData[index][theLine]); } }