GNU Unifont: src/unihexpose.c Source File

GNU Unifont 15.1.02 Pan-Unicode font with complete Unicode Plane 0 coverage and partial coverage of higher planes

unihexpose.c
1/**
2 @file: unihetranspose.c
3
4 @brief: Transpose Unifont glyph bitmaps.
5
6 This program takes Unifont .hex format glyphs and converts those
7 glyphs so that each byte (two hexadecimal digits in the .hex file)
8 represents a column of 8 rows. This simplifies use with graphics
9 display controllers that write lines consisting of 8 rows at a time
10 to a display.
11
12 The bytes are ordered as first all the columns for the glyph in
13 the first 8 rows, then all the columns in the next 8 rows, with
14 columns ordered from left to right.
15
16 This file must be linked with functions in unifont-support.c.
17
18 @author Paul Hardy
19
20 @copyright Copyright © 2023 Paul Hardy
21*/
22/*
23 LICENSE:
24
25 This program is free software: you can redistribute it and/or modify
26 it under the terms of the GNU General Public License as published by
27 the Free Software Foundation, either version 2 of the License, or
28 (at your option) any later version.
29
30 This program is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 GNU General Public License for more details.
34
35 You should have received a copy of the GNU General Public License
36 along with this program. If not, see <http://www.gnu.org/licenses/>.
37*/
38#include <stdio.h>
39#include <stdlib.h>
40
41#define MAXWIDTH 128
42
43int
44 main (int argc, char *argv[]) {
45 unsigned codept; /* Unicode code point for glyph */
46 char instring [MAXWIDTH]; /* input Unifont hex string */
47 char outstring [MAXWIDTH]; /* output Unfont hex string */
48 int width; /* width of current glyph */
49 unsigned char glyph [16][2];
50 unsigned char glyphbits [16][16]; /* One glyphbits row, for transposing */
51 unsigned char transpose [2][16]; /* Transponsed glyphbits bitmap */
52
53 void print_syntax ();
54
55 void parse_hex (char *hexstring,
56 int *width,
57 unsigned *codept,
58 unsigned char glyph[16][2]);
59
60 void glyph2bits (int width,
61 unsigned char glyph[16][2],
62 unsigned char glyphbits [16][16]);
63
64 void hexpose (int width,
65 unsigned char glyphbits [16][16],
66 unsigned char transpose [2][16]);
67
68 void xglyph2string (int width, unsigned codept,
69 unsigned char transpose [2][16],
70 char *outstring);
71
72 if (argc > 1) {
73 print_syntax ();
74 exit (EXIT_FAILURE);
75 }
76
77 while (fgets (instring, MAXWIDTH, stdin) != NULL) {
78 parse_hex (instring, &width, &codept, glyph);
79
80 glyph2bits (width, glyph, glyphbits);
81
82 hexpose (width, glyphbits, transpose);
83
84 xglyph2string (width, codept, transpose, outstring);
85
86 fprintf (stdout, "%s\n", outstring);
87 }
88
89 exit (EXIT_SUCCESS);
90}
91
92
93void
94print_syntax () {
95
96 fprintf (stderr, "\nSyntax: unihexpose < input.hex > output.hex\n\n");
97
98 return;
99}
100
main
int main(int argc, char *argv[])
The main function.
Definition: hex2otf.c:2603
hexpose
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.
Definition: unifont-support.c:150
glyph2bits
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.
Definition: unifont-support.c:91
xglyph2string
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.
Definition: unifont-support.c:267
parse_hex
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.
Definition: unifont-support.c:44