const char * (UsageLines [] ) = { "p4label59: Reads text from standard input,", "writes P4 pbm to standard output using fixed-width.", "Usage: p4label59 (output image width) (output image height)", "Only ASCII characters are recognized.", "", "January 4, 2023. Latest at gopher://sdf.org/1/users/julianbr", }; const int NumUsageLines = sizeof (UsageLines)/sizeof (UsageLines [0] ); #define NUM_ROWS 59 #define LETTER_SPACING 4 #define LINE_SPACING 4 #define MARGIN 20 int MaxNumColumns; int (Outlines [] ) [NUM_ROWS] = { {15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* ! */ {903, 903, 903, 903, 903, 903, 903, 903, 903, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* \ */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 774, 774, 774, 1806, 1806, 1806, 1806, 1806, 1806, 16383, 16383, 16383, 3612, 3612, 3612, 3612, 3612, 16383, 16383, 16383, 16383, 7224, 7224, 7224, 7224, 7224, 6192, 6192, 6192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* # */ {480, 480, 480, 480, 480, 480, 480, 2040, 4092, 4092, 8190, 7662, 15855, 14823, 14816, 14816, 14816, 14816, 15840, 7648, 8160, 8160, 4064, 2040, 1020, 508, 510, 494, 495, 487, 487, 487, 487, 14823, 15855, 7662, 7662, 8190, 4092, 2040, 1008, 480, 480, 480, 480, 480, 480, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* $ */ {14339, 32259, 65031, 61191, 124687, 116494, 116494, 116510, 116508, 116540, 124728, 61240, 65144, 31856, 14576, 224, 480, 480, 448, 960, 896, 1920, 1792, 1792, 3840, 3584, 7680, 7292, 7420, 15614, 14798, 31175, 29127, 61895, 61895, 57799, 123343, 115182, 114942, 98556, 98424, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* % */ {896, 4032, 4032, 7904, 7392, 7392, 7408, 15472, 15472, 15472, 14576, 7408, 7392, 7392, 8160, 16320, 32640, 32512, 63232, 59136, 59264, 58240, 123776, 115648, 115648, 115136, 115136, 115175, 114919, 114919, 123135, 123007, 57470, 57470, 61502, 28732, 30780, 15480, 8184, 8184, 1992, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* & */ {15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* ' */ {2, 3, 7, 7, 7, 14, 14, 14, 30, 28, 28, 28, 28, 60, 60, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 60, 28, 28, 28, 28, 28, 14, 14, 14, 15, 7, 7, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* { */ {16, 48, 56, 56, 56, 28, 28, 28, 30, 14, 14, 14, 14, 15, 15, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 15, 14, 14, 14, 14, 14, 28, 28, 28, 60, 56, 56, 48, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* */ {3075, 3591, 3591, 3855, 3855, 1950, 924, 1020, 504, 504, 4095, 4095, 4095, 504, 504, 1020, 924, 1950, 1806, 3855, 3591, 3591, 3075, 3075, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* * */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 240, 240, 240, 240, 240, 240, 4095, 4095, 4095, 240, 240, 240, 240, 240, 240, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* + */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 15, 14, 14, 14, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* , */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4095, 4095, 4095, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* - */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* . */ {3, 3, 3, 7, 7, 7, 15, 14, 14, 14, 30, 28, 28, 60, 56, 56, 56, 120, 112, 112, 240, 224, 224, 224, 480, 448, 448, 960, 896, 896, 1920, 1920, 1792, 1792, 3840, 3584, 3584, 3584, 3072, 3072, 3072, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* / */ {3968, 8128, 16352, 32752, 30960, 61560, 57400, 122940, 122908, 114716, 245790, 245790, 491535, 491535, 491535, 491535, 491535, 491535, 493327, 495503, 495503, 495503, 493327, 491535, 491535, 491535, 491535, 491535, 507919, 245790, 245790, 245790, 122940, 122940, 122940, 61560, 63736, 32752, 16352, 8128, 3968, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 0 */ {30, 30, 30, 30, 62, 62, 62, 62, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 63, 63, 63, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 1 */ {4064, 16368, 65528, 131068, 122942, 245791, 229391, 491535, 491535, 491535, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 30, 30, 30, 30, 60, 60, 56, 120, 240, 240, 480, 992, 960, 1984, 3968, 7936, 32256, 524287, 524287, 524287, 524287, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 2 */ {4032, 16368, 32760, 65532, 127038, 253982, 507919, 491535, 491535, 491535, 491535, 15, 15, 15, 15, 15, 30, 62, 124, 2040, 2032, 2040, 2044, 62, 30, 15, 15, 15, 15, 15, 491535, 491535, 491535, 491535, 491534, 245790, 122942, 131068, 65528, 32752, 8128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 3 */ {120, 120, 248, 248, 504, 1016, 1016, 2040, 3960, 3960, 7800, 15480, 31864, 30840, 61560, 127096, 123000, 245880, 245880, 524287, 524287, 524287, 524287, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 4 */ {524287, 524287, 524287, 524287, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 523776, 524160, 524256, 524272, 504, 124, 62, 30, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 30, 62, 124, 248, 496, 262112, 262080, 262016, 261888, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 5 */ {15, 255, 1023, 2047, 4064, 7936, 15872, 31744, 63488, 126976, 122880, 245760, 245760, 491520, 491520, 491520, 458752, 458752, 466912, 491504, 524280, 524284, 516158, 507934, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 229391, 229391, 245790, 254014, 131068, 131064, 65520, 32736, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 6 */ {524287, 524287, 524287, 524287, 30, 30, 30, 60, 60, 60, 120, 120, 248, 240, 240, 496, 480, 992, 960, 1984, 1920, 3968, 3840, 7936, 7680, 7680, 15360, 15360, 30720, 30720, 61440, 61440, 122880, 122880, 253952, 245760, 507904, 507904, 491520, 491520, 491520, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 7 */ {16368, 32760, 65532, 131070, 254015, 507935, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 507935, 516159, 258174, 131068, 65528, 65532, 131070, 254015, 507935, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 507935, 516159, 262142, 131068, 65528, 32752, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 8 */ {16352, 32752, 65528, 131068, 258174, 254014, 507935, 507935, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 507919, 507935, 254015, 258175, 131071, 65527, 32743, 16327, 7, 15, 15, 15, 31, 30, 62, 124, 248, 496, 992, 1984, 16256, 524032, 523776, 522240, 516096, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* 9 */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* : */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 15, 14, 14, 14, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* ; */ {3, 7, 7, 15, 14, 30, 60, 60, 120, 112, 240, 480, 480, 960, 896, 1920, 1792, 3840, 3584, 3584, 3072, 3072, 3584, 3840, 3840, 1920, 896, 960, 448, 480, 240, 240, 120, 56, 60, 28, 30, 15, 7, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* < */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4095, 4095, 4095, 0, 0, 0, 0, 0, 4095, 4095, 4095, 4095, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* = */ {0, 0, 0, 0, 0, 0, 3584, 3584, 3840, 1920, 960, 992, 480, 240, 120, 60, 30, 30, 15, 7, 3, 7, 15, 15, 30, 60, 120, 240, 240, 480, 960, 1920, 3840, 3840, 3584, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* > */ {480, 1008, 2040, 3900, 3612, 7182, 7182, 15375, 14343, 14343, 14343, 14343, 7, 7, 7, 15, 14, 14, 30, 28, 124, 120, 112, 480, 480, 480, 480, 480, 480, 480, 480, 480, 0, 0, 0, 0, 0, 480, 480, 480, 480, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* ? */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7936, 16256, 32704, 29152, 61664, 57568, 58336, 124896, 116720, 118640, 118392, 118392, 118392, 118640, 116720, 124896, 58336, 57584, 61688, 29180, 32766, 16287, 7943, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* @ */ {1792, 3968, 3968, 3968, 8128, 8128, 7616, 15840, 15840, 30960, 30960, 30960, 30960, 61560, 61560, 61560, 122940, 122940, 122940, 114716, 245790, 262142, 262142, 262142, 524287, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* A */ {524160, 524256, 524272, 524280, 491772, 491582, 491551, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491551, 491582, 491644, 524280, 524272, 524256, 524272, 491768, 491644, 491582, 491551, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491551, 491582, 491644, 524280, 524272, 524256, 524224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* B */ {16320, 32736, 65520, 131064, 258172, 516158, 507935, 491535, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 507904, 516126, 258110, 129148, 65528, 32752, 16352, 8128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* C */ {524224, 524256, 524272, 524280, 491772, 491646, 491583, 491551, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491551, 491583, 491646, 491772, 524280, 524272, 524256, 524224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* D */ {524287, 524287, 524287, 524287, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 524272, 524272, 524272, 524272, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 524287, 524287, 524287, 524287, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* E */ {524287, 524287, 524287, 524287, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 524272, 524272, 524272, 524272, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* F */ {8128, 16352, 32752, 65528, 127100, 122940, 122940, 245822, 245790, 245790, 229406, 491550, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491775, 491775, 491775, 491775, 491535, 491535, 491535, 491535, 245791, 245791, 245822, 122940, 123004, 127224, 65520, 65504, 32704, 16256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* G */ {491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 524287, 524287, 524287, 524287, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* H */ {63, 63, 63, 63, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 63, 63, 63, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* I */ {63, 63, 63, 63, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 122910, 122910, 122910, 127038, 131068, 65528, 32752, 8128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* J */ {491527, 491527, 491535, 491551, 491582, 491644, 491644, 491768, 491760, 492000, 492480, 493440, 495488, 499456, 507392, 523264, 522240, 520192, 516096, 507904, 507904, 516096, 520192, 522240, 522240, 523264, 507392, 499456, 495488, 493440, 493504, 492512, 492016, 491760, 491640, 491644, 491580, 491550, 491551, 491535, 491535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* K */ {491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 524287, 524287, 524287, 524287, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* L */ {15728655, 15728655, 15728655, 15728655, 15728655, 16252959, 16252959, 16515135, 16515135, 16646207, 16646271, 16646271, 16711807, 16711935, 16711935, 16187631, 16220655, 16220655, 15958479, 15975375, 15844239, 15853455, 15853455, 15793935, 15793935, 15760911, 15760911, 15744015, 15744015, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* M */ {491535, 491535, 491535, 491535, 507919, 507919, 516111, 516111, 520207, 520207, 520207, 522255, 522255, 523279, 506895, 506895, 499215, 499215, 499215, 495375, 495375, 493455, 493455, 493519, 492495, 492495, 492015, 492015, 492031, 491775, 491775, 491647, 491647, 491583, 491583, 491551, 491551, 491535, 491535, 491535, 491535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* N */ {4032, 8160, 16368, 32760, 63736, 122940, 122942, 245790, 245790, 507935, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 507935, 507934, 245790, 254012, 122936, 129272, 65520, 32736, 16320, 8064, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* O */ {499584, 524256, 524280, 524280, 516348, 491582, 491551, 491535, 491535, 491535, 491535, 491535, 491535, 491551, 491582, 491644, 492024, 524272, 524256, 524224, 524032, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* P */ {8128, 16352, 32752, 32760, 61688, 57468, 122940, 114750, 245790, 245791, 245775, 245775, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491919, 492431, 508879, 246751, 246783, 254462, 127486, 131068, 65528, 32752, 8176, 120, 120, 124, 60, 60, 62, 30, 30, 31, 15, 15, 15, 0, 0, 0, 0, 0, 0, }, /* Q */ {524160, 524224, 524272, 524280, 491772, 491582, 491551, 491551, 491535, 491535, 491535, 491535, 491535, 491551, 491582, 491644, 491768, 524272, 524256, 524224, 523776, 499200, 499200, 499200, 495360, 495360, 493440, 493440, 492480, 492000, 492000, 491760, 491768, 491640, 491580, 491582, 491550, 491551, 491535, 491535, 491535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* R */ {8064, 32736, 65528, 131068, 123006, 245791, 229391, 491535, 491535, 491520, 491520, 491520, 491520, 491520, 491520, 245760, 245760, 122880, 126976, 65472, 32752, 16376, 4092, 124, 30, 30, 15, 15, 15, 15, 15, 15, 491535, 491535, 491535, 507934, 258110, 262140, 131064, 65520, 16352, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* S */ {524287, 524287, 524287, 524287, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* T */ {491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 245790, 262142, 131068, 65528, 16352, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* U */ {491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 491535, 507935, 245790, 245790, 245790, 245790, 245790, 245790, 122940, 122940, 122940, 57404, 61564, 61560, 61560, 61560, 63736, 30960, 30960, 30960, 14560, 14560, 15840, 15840, 7616, 8128, 8128, 8128, 3968, 3968, 3968, 1792, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* V */ {15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15728655, 15744015, 15760399, 15760911, 15760911, 16318239, 7929631, 7923486, 7923614, 7989150, 7979934, 7979934, 8111070, 3916764, 4162044, 4162044, 4129020, 2031864, 1966200, 1966200, 1966200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* W */ {491535, 491535, 491535, 491535, 507935, 245790, 254014, 254014, 122940, 122940, 127096, 61560, 63728, 30960, 32224, 16352, 16320, 8128, 8128, 3968, 3968, 8128, 8128, 8128, 8128, 15840, 14560, 30960, 30960, 61560, 61560, 122940, 122940, 114718, 245790, 245791, 507935, 491535, 491535, 491535, 491535, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* X */ {491535, 491535, 491535, 491535, 245790, 245790, 254012, 122940, 122936, 127096, 61552, 30960, 30944, 31200, 16320, 16320, 8064, 7936, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* Y */ {524287, 524287, 524287, 524287, 30, 30, 62, 60, 60, 124, 120, 248, 240, 496, 480, 480, 960, 960, 1984, 1920, 3968, 3840, 7936, 7680, 7680, 15872, 15360, 31744, 30720, 30720, 61440, 61440, 122880, 122880, 253952, 245760, 245760, 524287, 524287, 524287, 524287, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* Z */ {255, 255, 255, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* [ */ {3072, 3072, 3072, 3584, 3584, 3584, 3840, 1792, 1792, 1792, 1920, 896, 896, 960, 448, 448, 448, 480, 224, 224, 240, 112, 112, 112, 120, 56, 56, 60, 28, 28, 30, 30, 14, 14, 15, 7, 7, 7, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* \ */ {255, 255, 255, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* ] */ {240, 240, 504, 504, 504, 1020, 1020, 924, 1950, 1806, 1806, 3855, 3591, 3591, 3591, 3075, 3075, 3075, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* ^ */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131071, 131071, 131071, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* _ */ {32, 48, 48, 56, 56, 56, 60, 28, 30, 14, 14, 15, 7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* ` */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4094, 4095, 4095, 4095, 15, 7, 7, 7, 7, 2031, 4095, 8191, 16383, 15391, 14351, 14351, 14351, 14351, 15391, 16383, 8191, 4095, 2031, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* a */ {15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15600, 16376, 16380, 16382, 16159, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 16159, 16382, 16380, 16376, 15600, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* b */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1008, 2040, 4092, 8190, 15903, 15375, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15375, 15903, 8190, 4092, 2040, 1008, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* c */ {15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 975, 2047, 4095, 8191, 15935, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15935, 8191, 4095, 2047, 975, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* d */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1008, 2040, 4092, 8190, 15903, 15375, 15375, 15375, 15375, 15375, 16383, 16383, 16383, 16383, 15360, 15360, 15360, 15360, 15902, 8190, 4092, 2040, 1008, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* e */ {1008, 2040, 4092, 8190, 15903, 15375, 15375, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 16376, 16376, 16376, 16376, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* f */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 975, 2047, 4095, 8191, 15935, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15935, 8191, 4095, 2047, 975, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 7695, 7967, 4094, 2044, 1016, 496, }, /* g */ {15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15608, 16380, 16382, 16383, 16159, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* h */ {0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* i */ {0, 0, 0, 0, 0, 0, 30, 31, 31, 31, 14, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 3855, 3855, 3999, 4094, 2044, 1016, 496, }, /* j */ {15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15375, 15391, 15422, 15484, 15608, 15856, 16352, 16320, 16256, 16128, 15872, 15360, 15872, 16128, 16256, 16320, 16352, 15856, 15608, 15484, 15422, 15391, 15375, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* k */ {31, 31, 31, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* l */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 999408, 1048568, 1048572, 1048574, 1036063, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 986895, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* m */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15608, 16380, 16382, 16383, 16159, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* n */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1008, 2040, 4092, 8190, 15903, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15903, 8190, 4092, 2040, 1008, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* o */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15600, 16376, 16380, 16382, 16159, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 16159, 16382, 16380, 16376, 15600, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, }, /* p */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 975, 2047, 4095, 8191, 15935, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 7743, 8191, 4095, 2047, 975, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, }, /* q */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15608, 16380, 16382, 16383, 16143, 15367, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* r */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1020, 2046, 4095, 8191, 15887, 15360, 15360, 15360, 15360, 15872, 8184, 4092, 2046, 1023, 31, 15, 15, 14351, 15391, 16382, 8188, 4088, 2032, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* s */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3840, 3840, 3840, 3840, 3840, 16376, 16376, 16376, 16376, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3847, 3983, 4095, 2046, 1020, 504, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 15935, 16383, 8191, 4095, 1999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* t */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15375, 15375, 15375, 15375, 15375, 15375, 15375, 7710, 7710, 7710, 7710, 7710, 3612, 3900, 3900, 3900, 2040, 2040, 2040, 1008, 480, 480, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* u */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 493327, 493327, 493327, 493327, 495503, 495503, 495503, 499663, 499663, 499663, 499151, 507375, 245230, 243950, 260350, 129276, 129276, 129276, 127100, 127100, 61560, 61560, 61560, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* v */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14343, 15375, 15375, 15375, 7710, 3612, 3900, 1848, 2040, 1008, 480, 480, 480, 1008, 2040, 1848, 3900, 3612, 7710, 15375, 15375, 15375, 14343, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* w */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14351, 14351, 15375, 15375, 15887, 7695, 7695, 3855, 3855, 3855, 1807, 1935, 910, 910, 974, 462, 510, 252, 252, 252, 124, 124, 60, 60, 120, 120, 120, 120, 112, 112, 240, 240, 224, 224, 480, 448, 960, 16256, 16256, 16128, 7168, }, /* x */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16383, 16383, 16383, 16383, 30, 28, 60, 60, 120, 240, 240, 480, 448, 960, 1920, 1920, 3840, 3584, 7680, 16383, 16383, 16383, 16383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* y */ {3, 7, 15, 30, 28, 28, 28, 56, 56, 56, 56, 56, 56, 56, 48, 56, 56, 120, 240, 224, 192, 224, 240, 248, 120, 56, 56, 56, 56, 56, 56, 56, 56, 56, 60, 28, 28, 28, 15, 15, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* z */ {15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* | */ {192, 224, 240, 120, 56, 56, 56, 28, 28, 28, 28, 28, 28, 28, 12, 28, 28, 30, 15, 7, 3, 7, 15, 31, 30, 28, 28, 28, 28, 28, 28, 28, 28, 28, 60, 56, 56, 56, 240, 240, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* } */ {1008, 2040, 4092, 8190, 15903, 15375, 15375, 15375, 15375, 15375, 15903, 8190, 4092, 2040, 1008, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3840, 8064, 8128, 15808, 14816, 14816, 487, 231, 254, 254, 124, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* ~ */ }; int NumOutlines = sizeof (Outlines) / sizeof (Outlines [0] ); #include <stdlib.h> #include <stdio.h> void WriteLabel (unsigned char (* TextLine) [NUM_ROWS] , int width, int height) { int * Outline; int c, i, j, byte, NumTextLines, NumImageLines, NumChars, MaxNumChars, PowerOf2; int row, position, NumColumns; NumImageLines = 0; printf ("P4\n"); printf ("%d %d\n", width, height); for (i = 0; i < MARGIN; i++) { if (NumImageLines < height) { for (byte = 0; byte < (width + 7)/8; byte++) putchar (0); } NumImageLines++; } NumTextLines = 0; MaxNumChars = 0; c = getchar (); while (c != EOF) { NumChars = 0; for (i = 0; i < NUM_ROWS; i++) { for (byte = 0; byte < (width + 7)/8; byte++) TextLine [byte] [i] = 0; } while (c != '\n' && c != EOF) { if (c - '!' >= 0 && c - '!' < NumOutlines) { PowerOf2 = 1; NumColumns = 0; Outline = Outlines [c - '!']; for (i = 0; i < NUM_ROWS; i++) { row = Outline [i]; while (PowerOf2 <= row) { PowerOf2 *= 2; NumColumns++; } } if (NumColumns > MaxNumColumns) NumColumns = MaxNumColumns; for (i = 0; i < NumColumns; i++) { position = MARGIN + NumChars*(MaxNumColumns + LETTER_SPACING) + (MaxNumColumns - NumColumns)/2 + i; if (position < width) { byte = position/8; for (j = 0; j < NUM_ROWS; j++) { row = Outline [j]; if (row & (1 << (NumColumns - i - 1) ) ) TextLine [byte] [j] += (1 << (7 - position%8) ); } } } } NumChars++; c = getchar (); } for (i = 0; i < NUM_ROWS; i++) { if (NumImageLines < height) { for (byte = 0; byte < (width + 7)/8; byte++) putchar (TextLine [byte] [i] ); } NumImageLines++; } for (i = 0; i < LINE_SPACING; i++) { if (NumImageLines < height) { for (byte = 0; byte < (width + 7)/8; byte++) putchar (0); } NumImageLines++; } if (MaxNumChars < NumChars) MaxNumChars = NumChars; NumTextLines++; if (c != EOF) c = getchar (); } while (NumImageLines < height) { for (byte = 0; byte < (width + 7)/8; byte++) putchar (0); NumImageLines++; } fprintf (stderr, "p4label59: Fits "); fprintf (stderr, " %d", 2*MARGIN + MaxNumChars*MaxNumColumns + LETTER_SPACING*(MaxNumChars - 1) ); fprintf (stderr, "x%d,", 2*MARGIN + (NumTextLines - 1)*LINE_SPACING + NumTextLines*NUM_ROWS); fprintf (stderr, " writing %dx%d.\n", width, height); } int main (int argc, char * * argv) { unsigned char (* TextLine) [NUM_ROWS]; int i, j, width, height, PowerOf2, row; char c; PowerOf2 = 1; MaxNumColumns = 0; for (i = 0; i < NumOutlines; i++) { for (j = 0; j < NUM_ROWS; j++) { row = Outlines [i] [j]; while (PowerOf2 <= row) { PowerOf2 *= 2; MaxNumColumns++; } } } if (argc == 1) { for (i = 0; i < NumUsageLines; i++) printf ("%s\n", UsageLines [i] ); printf ("Each character %dx%d,", MaxNumColumns, NUM_ROWS); printf (" letter spacing %d, line spacing %d,", LETTER_SPACING, LINE_SPACING); printf (" margin %d.\n", MARGIN); } else if (argc == 3) { if ( sscanf (argv [1], "%d%c", & width, & c) != 1 || sscanf (argv [2], "%d%c", & height, & c) != 1 || width <= 0 || height <= 0) { fprintf (stderr, "p4label5928: Improper \"%s\" \"%s\",", argv [1], argv [2] ); fprintf (stderr, " expecting width and height.\n"); } else { TextLine = malloc (NUM_ROWS*((width + 7)/8) ); if (TextLine == NULL) fprintf (stderr, "***p4label59: Not enough memory.\n"); else { WriteLabel (TextLine, width, height); free (TextLine); } } } else printf ("Usage: %s: (width) (height)\n", argv [0] ); return 0; }