47 unsigned char glyph[16][2]) {
53 sscanf (hexstring,
"%X", codept);
54 length = strlen (hexstring);
55 for (i = length - 1; i > 0 && hexstring[i] !=
'\n'; i--);
57 for (i = 0; i < 9 && hexstring[i] !=
':'; i++);
59 *width = (length - i) * 4 / 16;
61 for (row = 0; row < 16; row++) {
62 sscanf (&hexstring[i],
"%2hhX", &glyph [row][0]);
65 sscanf (&hexstring[i],
"%2hhX", &glyph [row][1]);
69 glyph [row][1] = 0x00;
92 unsigned char glyph[16][2],
93 unsigned char glyphbits [16][16]) {
95 unsigned char tmp_byte;
99 for (row = 0; row < 16; row++) {
100 tmp_byte = glyph [row][0];
102 for (column = 0; column < 8; column++) {
103 glyphbits [row][column] = tmp_byte & mask ? 1 : 0;
108 tmp_byte = glyph [row][1];
113 for (column = 8; column < 16; column++) {
114 glyphbits [row][column] = tmp_byte & mask ? 1 : 0;
151 unsigned char glyphbits [16][16],
152 unsigned char transpose [2][16]) {
157 for (column = 0; column < 8; column++) {
158 transpose [0][column] =
159 (glyphbits [ 0][column] << 7) |
160 (glyphbits [ 1][column] << 6) |
161 (glyphbits [ 2][column] << 5) |
162 (glyphbits [ 3][column] << 4) |
163 (glyphbits [ 4][column] << 3) |
164 (glyphbits [ 5][column] << 2) |
165 (glyphbits [ 6][column] << 1) |
166 (glyphbits [ 7][column] );
167 transpose [1][column] =
168 (glyphbits [ 8][column] << 7) |
169 (glyphbits [ 9][column] << 6) |
170 (glyphbits [10][column] << 5) |
171 (glyphbits [11][column] << 4) |
172 (glyphbits [12][column] << 3) |
173 (glyphbits [13][column] << 2) |
174 (glyphbits [14][column] << 1) |
175 (glyphbits [15][column] );
178 for (column = 8; column < width; column++) {
179 transpose [0][column] =
180 (glyphbits [0][column] << 7) |
181 (glyphbits [1][column] << 6) |
182 (glyphbits [2][column] << 5) |
183 (glyphbits [3][column] << 4) |
184 (glyphbits [4][column] << 3) |
185 (glyphbits [5][column] << 2) |
186 (glyphbits [6][column] << 1) |
187 (glyphbits [7][column] );
188 transpose [1][column] =
189 (glyphbits [ 8][column] << 7) |
190 (glyphbits [ 9][column] << 6) |
191 (glyphbits [10][column] << 5) |
192 (glyphbits [11][column] << 4) |
193 (glyphbits [12][column] << 3) |
194 (glyphbits [13][column] << 2) |
195 (glyphbits [14][column] << 1) |
196 (glyphbits [15][column] );
200 for (column = 8; column < width; column++)
201 transpose [0][column] = transpose [1][column] = 0x00;
222 unsigned char glyph [16][2],
228 if (codept <= 0xFFFF) {
229 sprintf (outstring,
"%04X:", codept);
233 sprintf (outstring,
"%06X:", codept);
237 for (row = 0; row < 16; row++) {
238 sprintf (&outstring[i],
"%02X", glyph [row][0]);
242 sprintf (&outstring[i],
"%02X", glyph [row][1]);
268 unsigned char transpose [2][16],
274 if (codept <= 0xFFFF) {
275 sprintf (outstring,
"%04X:", codept);
279 sprintf (outstring,
"%06X:", codept);
283 for (column = 0; column < 8; column++) {
284 sprintf (&outstring[i],
"%02X", transpose [0][column]);
288 for (column = 8; column < 16; column++) {
289 sprintf (&outstring[i],
"%02X", transpose [0][column]);
293 for (column = 0; column < 8; column++) {
294 sprintf (&outstring[i],
"%02X", transpose [1][column]);
298 for (column = 8; column < 16; column++) {
299 sprintf (&outstring[i],
"%02X", transpose [1][column]);
void hexpose(int width, unsigned char glyphbits[16][16], unsigned char transpose[2][16])
Transpose a Unifont .hex format glyph into 2 column-major sub-arrays.
void glyph2bits(int width, unsigned char glyph[16][2], unsigned char glyphbits[16][16])
Convert a Unifont binary glyph into a binary glyph array of bits.
void xglyph2string(int width, unsigned codept, unsigned char transpose[2][16], char *outstring)
Convert a code point and transposed glyph into a Unifont .hex string.
void parse_hex(char *hexstring, int *width, unsigned *codept, unsigned char glyph[16][2])
Decode a Unifont .hex file into Uniocde code point and glyph.
void glyph2string(int width, unsigned codept, unsigned char glyph[16][2], char *outstring)
Convert a glyph code point and byte array into a Unifont .hex string.