Deleted Added
full compact
31c31
< __FBSDID("$FreeBSD: head/tools/tools/vt/fontcvt/fontcvt.c 219888 2011-03-22 21:31:31Z ed $");
---
> __FBSDID("$FreeBSD: head/tools/tools/vt/fontcvt/fontcvt.c 259680 2013-12-21 13:58:55Z emaste $");
42a43,46
> #define VFNT_MAPS 4
> #define VFNT_MAP_NORMAL 0
> #define VFNT_MAP_BOLD 2
>
51,53c55,62
< static TAILQ_HEAD(, glyph) glyph_list = TAILQ_HEAD_INITIALIZER(glyph_list);
< static unsigned int glyph_total, glyph_normal, glyph_bold,
< glyph_unique, glyph_dupe;
---
> TAILQ_HEAD(glyph_list, glyph);
> static struct glyph_list glyphs[VFNT_MAPS] = {
> TAILQ_HEAD_INITIALIZER(glyphs[0]),
> TAILQ_HEAD_INITIALIZER(glyphs[1]),
> TAILQ_HEAD_INITIALIZER(glyphs[2]),
> TAILQ_HEAD_INITIALIZER(glyphs[3]),
> };
> static unsigned int glyph_total, glyph_count[4], glyph_unique, glyph_dupe;
63,68c72,79
< static struct mapping_list mapping_list_normal =
< TAILQ_HEAD_INITIALIZER(mapping_list_normal);
< static struct mapping_list mapping_list_bold =
< TAILQ_HEAD_INITIALIZER(mapping_list_bold);
< static unsigned int mapping_total, mapping_normal, mapping_normal_folded,
< mapping_bold, mapping_bold_folded, mapping_unique, mapping_dupe;
---
> static struct mapping_list maps[VFNT_MAPS] = {
> TAILQ_HEAD_INITIALIZER(maps[0]),
> TAILQ_HEAD_INITIALIZER(maps[1]),
> TAILQ_HEAD_INITIALIZER(maps[2]),
> TAILQ_HEAD_INITIALIZER(maps[3]),
> };
> static unsigned int mapping_total, map_count[4], map_folded_count[4],
> mapping_unique, mapping_dupe;
80c91
< add_mapping(struct glyph *gl, unsigned int c, int bold)
---
> add_mapping(struct glyph *gl, unsigned int c, unsigned int map_idx)
87c98
< if (bold) {
---
> if (map_idx >= VFNT_MAP_BOLD) {
88a100
> unsigned normal_map_idx = map_idx - VFNT_MAP_BOLD;
90c102
< TAILQ_FOREACH(mp, &mapping_list_normal, m_list) {
---
> TAILQ_FOREACH(mp, &maps[normal_map_idx], m_list) {
119c131
< ml = bold ? &mapping_list_bold : &mapping_list_normal;
---
> ml = &maps[map_idx];
127,130c139
< if (bold)
< mapping_bold++;
< else
< mapping_normal++;
---
> map_count[map_idx]++;
137c146
< add_glyph(const uint8_t *bytes, int bold, int fallback)
---
> add_glyph(const uint8_t *bytes, unsigned int map_idx, int fallback)
139a149
> unsigned int i;
142,145c152
< if (bold)
< glyph_bold++;
< else
< glyph_normal++;
---
> glyph_count[map_idx]++;
147,150c154,159
< TAILQ_FOREACH(gl, &glyph_list, g_list) {
< if (memcmp(gl->g_data, bytes, wbytes * height) == 0) {
< glyph_dupe++;
< return (gl);
---
> for (i = 0; i < VFNT_MAPS; i++) {
> TAILQ_FOREACH(gl, &glyphs[i], g_list) {
> if (memcmp(gl->g_data, bytes, wbytes * height) == 0) {
> glyph_dupe++;
> return (gl);
> }
158c167
< TAILQ_INSERT_HEAD(&glyph_list, gl, g_list);
---
> TAILQ_INSERT_HEAD(&glyphs[map_idx], gl, g_list);
160c169
< TAILQ_INSERT_TAIL(&glyph_list, gl, g_list);
---
> TAILQ_INSERT_TAIL(&glyphs[map_idx], gl, g_list);
167c176,177
< parse_bdf(const char *filename, int bold __unused)
---
> parse_bitmap_line(uint8_t *left, uint8_t *right, unsigned int line,
> unsigned int dwidth)
168a179,216
> uint8_t *p;
> unsigned int i, subline;
>
> if (dwidth != width && dwidth != width * 2) {
> fprintf(stderr,
> "Unsupported width %u!\n", dwidth);
> return (1);
> }
>
> /* Move pixel data right to simplify splitting double characters. */
> line >>= (howmany(dwidth, 8) * 8) - dwidth;
>
> for (i = dwidth / width; i > 0; i--) {
> p = (i == 2) ? right : left;
>
> subline = line & ((1 << width) - 1);
> subline <<= (howmany(width, 8) * 8) - width;
>
> if (wbytes == 1) {
> *p = subline;
> } else if (wbytes == 2) {
> *p++ = subline >> 8;
> *p = subline;
> } else {
> fprintf(stderr,
> "Unsupported wbytes %u!\n", wbytes);
> return (1);
> }
>
> line >>= width;
> }
>
> return (0);
> }
>
> static int
> parse_bdf(const char *filename, unsigned int map_idx)
> {
172,173c220,221
< uint8_t bytes[wbytes * height];
< unsigned int curchar = 0, i, line;
---
> uint8_t bytes[wbytes * height], bytes_r[wbytes * height];
> unsigned int curchar = 0, dwidth = 0, i, line;
188a237,240
> if (strncmp(ln, "DWIDTH ", 7) == 0) {
> dwidth = atoi(ln + 7);
> }
>
197,204c249,250
< if (wbytes == 1) {
< bytes[i] = line;
< } else if (wbytes == 2) {
< bytes[i * 2 + 0] = line >> 8;
< bytes[i * 2 + 1] = line;
< } else {
< fprintf(stderr,
< "Unsupported wbytes!\n");
---
> if (parse_bitmap_line(bytes + i * wbytes,
> bytes_r + i * wbytes, line, dwidth) != 0)
206d251
< }
211,212c256,257
< if (!bold)
< gl = add_glyph(bytes, bold, 1);
---
> if (map_idx < VFNT_MAP_BOLD)
> gl = add_glyph(bytes, 0, 1);
214,215c259,260
< gl = add_glyph(bytes, bold, 0);
< if (add_mapping(gl, curchar, bold) != 0)
---
> gl = add_glyph(bytes, map_idx, 0);
> if (add_mapping(gl, curchar, map_idx) != 0)
216a262,267
> if (dwidth == width * 2) {
> gl = add_glyph(bytes_r, map_idx + 1, 0);
> if (add_mapping(gl, curchar,
> map_idx + 1) != 0)
> return (1);
> }
228c279
< unsigned int idx = 0;
---
> unsigned int i, idx = 0;
230,231c281,283
< TAILQ_FOREACH(gl, &glyph_list, g_list)
< gl->g_index = idx++;
---
> for (i = 0; i < VFNT_MAPS; i++)
> TAILQ_FOREACH(gl, &glyphs[i], g_list)
> gl->g_index = idx++;
237a290
> unsigned int i;
239,240c292,295
< TAILQ_FOREACH(gl, &glyph_list, g_list)
< fwrite(gl->g_data, wbytes * height, 1, fp);
---
> for (i = 0; i < VFNT_MAPS; i++) {
> TAILQ_FOREACH(gl, &glyphs[i], g_list)
> fwrite(gl->g_data, wbytes * height, 1, fp);
> }
244c299
< fold_mappings(int bold)
---
> fold_mappings(unsigned int map_idx)
246c301
< struct mapping_list *ml;
---
> struct mapping_list *ml = &maps[map_idx];
249,253d303
< if (bold)
< ml = &mapping_list_bold;
< else
< ml = &mapping_list_normal;
<
262,265c312
< if (bold)
< mapping_bold_folded++;
< else
< mapping_normal_folded++;
---
> map_folded_count[map_idx]++;
276c323
< write_mappings(FILE *fp, int bold)
---
> write_mappings(FILE *fp, unsigned int map_idx)
278c325
< struct mapping_list *ml;
---
> struct mapping_list *ml = &maps[map_idx];
283,287d329
< if (bold)
< ml = &mapping_list_bold;
< else
< ml = &mapping_list_normal;
<
305,307c347,349
< uint16_t nglyphs;
< uint16_t nmappings_normal;
< uint16_t nmappings_bold;
---
> uint16_t pad;
> uint32_t glyph_count;
> uint32_t map_count[4];
315c357
< .magic = "VFNT 1.0",
---
> .magic = "VFNT0002",
326,328c368,372
< fh.nglyphs = htobe16(glyph_unique);
< fh.nmappings_normal = htobe16(mapping_normal_folded);
< fh.nmappings_bold = htobe16(mapping_bold_folded);
---
> fh.glyph_count = htobe32(glyph_unique);
> fh.map_count[0] = htobe32(map_folded_count[0]);
> fh.map_count[1] = htobe32(map_folded_count[1]);
> fh.map_count[2] = htobe32(map_folded_count[2]);
> fh.map_count[3] = htobe32(map_folded_count[3]);
332c376
< write_mappings(fp, 0);
---
> write_mappings(fp, VFNT_MAP_NORMAL);
333a378,379
> write_mappings(fp, VFNT_MAP_BOLD);
> write_mappings(fp, 3);
342c388
< assert(sizeof(struct file_header) == 16);
---
> assert(sizeof(struct file_header) == 32);
352c398
< if (parse_bdf(argv[3], 0) != 0)
---
> if (parse_bdf(argv[3], VFNT_MAP_NORMAL) != 0)
354c400
< if (parse_bdf(argv[4], 1) != 0)
---
> if (parse_bdf(argv[4], VFNT_MAP_BOLD) != 0)
358a405,406
> fold_mappings(2);
> fold_mappings(3);
364,375c412,429
< "- glyph_total: %5u\n"
< "- glyph_normal: %5u\n"
< "- glyph_bold: %5u\n"
< "- glyph_unique: %5u\n"
< "- glyph_dupe: %5u\n"
< "- mapping_total: %5u\n"
< "- mapping_normal: %5u\n"
< "- mapping_normal_folded: %5u\n"
< "- mapping_bold: %5u\n"
< "- mapping_bold_folded: %5u\n"
< "- mapping_unique: %5u\n"
< "- mapping_dupe: %5u\n",
---
> "- glyph_total: %5u\n"
> "- glyph_normal: %5u\n"
> "- glyph_normal_right: %5u\n"
> "- glyph_bold: %5u\n"
> "- glyph_bold_right: %5u\n"
> "- glyph_unique: %5u\n"
> "- glyph_dupe: %5u\n"
> "- mapping_total: %5u\n"
> "- mapping_normal: %5u\n"
> "- mapping_normal_folded: %5u\n"
> "- mapping_normal_right: %5u\n"
> "- mapping_normal_right_folded: %5u\n"
> "- mapping_bold: %5u\n"
> "- mapping_bold_folded: %5u\n"
> "- mapping_bold_right: %5u\n"
> "- mapping_bold_right_folded: %5u\n"
> "- mapping_unique: %5u\n"
> "- mapping_dupe: %5u\n",
377c431,434
< glyph_normal, glyph_bold,
---
> glyph_count[0],
> glyph_count[1],
> glyph_count[2],
> glyph_count[3],
380,381c437,440
< mapping_normal, mapping_normal_folded,
< mapping_bold, mapping_bold_folded,
---
> map_count[0], map_folded_count[0],
> map_count[1], map_folded_count[1],
> map_count[2], map_folded_count[2],
> map_count[3], map_folded_count[3],