7 #include <sys/unistd.h>
26 printf(
"[openFont]fx->path=[%s]\n", fx->
path);
27 f = fopen(fx->
path,
"r");
29 printf(
"[openFont]fopen=%p\n", f);
32 printf(
"Fontx:%s not found.\n", fx->
path);
38 if (fread(buf, 1,
sizeof(buf), fx->
file) !=
sizeof(buf)) {
40 printf(
"Fontx:%s not FONTX format.\n", fx->
path);
46 for (uint32_t i = 0; i < strlen(buf); i++) {
47 printf(
"buf[%d]=0x%x\n", i, buf[i]);
50 memcpy(fx->
fxname, &buf[6], 8);
53 fx->
is_ank = (buf[16] == 0);
55 fx->
fsz = (fx->
w + 7) / 8 * fx->
h;
57 printf(
"Fontx:%s is too big font size.\n", fx->
path);
75 for (
int i = 0; i < 2; i++) {
76 printf(
"fxs[%d]->path=%s\n", i, fxs[i].path);
77 printf(
"fxs[%d]->opened=%d\n", i, fxs[i].opened);
78 printf(
"fxs[%d]->fxname=%s\n", i, fxs[i].fxname);
79 printf(
"fxs[%d]->valid=%d\n", i, fxs[i].valid);
80 printf(
"fxs[%d]->is_ank=%d\n", i, fxs[i].is_ank);
81 printf(
"fxs[%d]->w=%d\n", i, fxs[i].w);
82 printf(
"fxs[%d]->h=%d\n", i, fxs[i].h);
83 printf(
"fxs[%d]->fsz=%d\n", i, fxs[i].fsz);
84 printf(
"fxs[%d]->bc=%d\n", i, fxs[i].bc);
89 printf(
"fx->w=%d\n", fx->
w);
94 printf(
"fx->h=%d\n", fx->
h);
104 printf(
"[GetFontx]ascii=0x%x\n", ascii);
105 for (i = 0; i < 2; i++) {
109 printf(
"[GetFontx]openFontxFile[%d] ok\n", i);
113 printf(
"[GetFontx]fxs.is_ank fxs.fsz=%d\n", fxs[i].fsz);
114 offset = 17 + ascii * fxs[i].
fsz;
116 printf(
"[GetFontx]offset=%d\n", offset);
117 if (fseek(fxs[i].file, offset, SEEK_SET)) {
118 printf(
"Fontx:seek(%u) failed.\n", offset);
121 if (fread(pGlyph, 1, fxs[i].fsz, fxs[i].file) != fxs[i].fsz) {
122 printf(
"Fontx:fread failed.\n");
135 void Font2Bitmap(uint8_t *fonts, uint8_t *line, uint8_t w, uint8_t h,
138 for (y = 0; y < (h / 8); y++) {
139 for (x = 0; x < w; x++) {
140 line[y * 32 + x] = 0;
147 for (y = 0; y < h; y++) {
148 for (x = 0; x < w; x++) {
149 uint8_t d = fonts[fontp + x / 8];
150 uint8_t linep = (y / 8) * 32 + x;
151 if (d & (0x80 >> (x % 8)))
152 line[linep] = line[linep] + (1 << mask);
157 fontp += (w + 7) / 8;
161 for (y = 0; y < (h / 8); y++) {
162 for (x = 0; x < w; x++) {
163 line[y * 32 + x] =
RotateByte(line[y * 32 + x]);
172 for (y = 0; y < (h / 8); y++) {
173 for (x = 0; x < w; x++) {
174 wk = line[y * 32 + x];
175 if ((y + 1) == (h / 8))
176 line[y * 32 + x] = wk + 0x80;
184 for (y = 0; y < (h / 8); y++) {
185 for (x = 0; x < w; x++) {
186 wk = line[y * 32 + x];
187 line[y * 32 + x] = ~wk;
192 void ShowFont(uint8_t *fonts, uint8_t pw, uint8_t ph) {
194 printf(
"[ShowFont pw=%d ph=%d]\n", pw, ph);
196 for (y = 0; y < ph; y++) {
198 for (x = 0; x < pw; x++) {
199 if (fonts[fpos + x / 8] & (0x80 >> (x % 8))) {
206 fpos = fpos + (pw + 7) / 8;
213 printf(
"[ShowBitmap pw=%d ph=%d]\n", pw, ph);
216 for (y = 0; y < ph; y++) {
218 for (x = 0; x < pw; x++) {
220 if (bitmap[x + (y / 8) * 32] & (0x80 >> fpos)) {
237 for (j = 0; j < 8; j++) {
238 ch2 = (ch2 << 1) + (ch1 & 0x01);