// text39.cpp //////////////////////////////////////////////////////////////// // // USEPA/OAR/ORIA National Air and Radiation Environmental Laboratory // // Author: Keith D. McCroan // Date: 1991 // // Text39 converts a string of valid Code 3-of-9 characters into // lines of pixels and returns the pixel values as a byte array. // // The characters were digitized at home on a very old personal computer, // stored in a text file as 0's and 1's, and converted to hex on the // NAREL VAX. // // Function: // // bool Text39(const char* s, unsigned char* line, int n) // ////////////////////////////////////////////////////////////////////////////// #include #include #include #include "text39.h" typedef unsigned char byte; // 0-9 static byte digit[10][10] = { {0x00,0x00,0x38,0x44,0x4c,0x54,0x64,0x44,0x38,0x00}, {0x00,0x00,0x08,0x18,0x08,0x08,0x08,0x08,0x1c,0x00}, {0x00,0x00,0x38,0x44,0x04,0x08,0x10,0x20,0x7c,0x00}, {0x00,0x00,0x38,0x44,0x04,0x18,0x04,0x44,0x38,0x00}, {0x00,0x00,0x08,0x18,0x28,0x48,0x7c,0x08,0x08,0x00}, {0x00,0x00,0x7c,0x40,0x78,0x04,0x04,0x44,0x38,0x00}, {0x00,0x00,0x38,0x40,0x78,0x44,0x44,0x44,0x38,0x00}, {0x00,0x00,0x7c,0x04,0x04,0x08,0x10,0x10,0x10,0x00}, {0x00,0x00,0x38,0x44,0x44,0x38,0x44,0x44,0x38,0x00}, {0x00,0x00,0x38,0x44,0x44,0x44,0x3c,0x04,0x38,0x00}}; // A-Z static byte letter[26][10] = { {0x00,0x00,0x38,0x44,0x44,0x7c,0x44,0x44,0x44,0x00}, {0x00,0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x78,0x00}, {0x00,0x00,0x38,0x44,0x40,0x40,0x40,0x44,0x38,0x00}, {0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x00}, {0x00,0x00,0x7c,0x40,0x40,0x78,0x40,0x40,0x7c,0x00}, {0x00,0x00,0x7c,0x40,0x40,0x78,0x40,0x40,0x40,0x00}, {0x00,0x00,0x38,0x44,0x40,0x4c,0x44,0x44,0x38,0x00}, {0x00,0x00,0x44,0x44,0x44,0x7c,0x44,0x44,0x44,0x00}, {0x00,0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x38,0x00}, {0x00,0x00,0x04,0x04,0x04,0x04,0x44,0x44,0x38,0x00}, {0x00,0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00}, {0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7e,0x00}, {0x00,0x00,0x44,0x6c,0x54,0x44,0x44,0x44,0x44,0x00}, {0x00,0x00,0x44,0x64,0x54,0x4c,0x44,0x44,0x44,0x00}, {0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00}, {0x00,0x00,0x78,0x44,0x44,0x78,0x40,0x40,0x40,0x00}, {0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x04}, {0x00,0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x44,0x00}, {0x00,0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x38,0x00}, {0x00,0x00,0x7c,0x10,0x10,0x10,0x10,0x10,0x10,0x00}, {0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00}, {0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x28,0x10,0x00}, {0x00,0x00,0x44,0x44,0x44,0x44,0x54,0x6c,0x44,0x00}, {0x00,0x00,0x44,0x28,0x10,0x10,0x10,0x28,0x44,0x00}, {0x00,0x00,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x00}, {0x00,0x00,0x7c,0x04,0x08,0x10,0x20,0x40,0x7c,0x00}}; static byte other[8][10] = { {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // space {0x00,0x00,0x10,0x54,0x38,0x54,0x10,0x00,0x00,0x00}, // * {0x00,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10}, // $ {0x00,0x00,0x3c,0x54,0x58,0x28,0x34,0x54,0x48,0x00}, // % {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00}, // . {0x00,0x00,0x00,0x10,0x10,0x7c,0x10,0x10,0x00,0x00}, // + {0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00}, // - {0x00,0x00,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20}}; // / ////////////////////////////////////////////////////////////////////////////// // Text39 ////////////////////////////////////////////////////////////////////////////// // Return the n'th pixel line for a string of text. // Line 0 is the top. Line 9 is the bottom. // // Parameter I/O Description // --------- --- --------------- // s I Text // line O Bits representing on/off pixels // n I Line number, 0..9 bool Text39(const char *s, byte *line, int n) { static char list[9] = " *$%.+-/"; char* pc; // This font requires only 10 lines of pixels. if (n < 0 || n >= 10) return false; while (*s) { if (isdigit(*s)) { *line = digit[*s-'0'][n]; } else if (isupper(*s)) { *line = letter[*s-'A'][n]; } else if ((pc = strchr (list, *s)) != NULL) { *line = other[pc - list][n]; } else { return 0; } ++s; ++line; } return true; } ////////////////////////////// end of text39.cpp /////////////////////////////