Skip to content

Commit 55bd3dd

Browse files
tectonic/dpx: remove useless code related to DPXTEST
We will never use/define DPXTEST, hence remove the dead code.
1 parent 9e70f6e commit 55bd3dd

File tree

2 files changed

+0
-332
lines changed

2 files changed

+0
-332
lines changed

tectonic/dpx-fontmap.c

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,158 +1280,3 @@ strip_options (const char *map_name, fontmap_opt *opt)
12801280

12811281
return font_name;
12821282
}
1283-
1284-
#ifdef DPXTEST
1285-
static void
1286-
dump_fontmap_rec (const char *key, const fontmap_rec *mrec)
1287-
{
1288-
fontmap_opt *opt = (fontmap_opt *) &mrec->opt;
1289-
1290-
if (mrec->map_name)
1291-
fprintf(stdout, " <!-- subfont");
1292-
else
1293-
fprintf(stdout, " <insert");
1294-
fprintf(stdout, " id=\"%s\"", key);
1295-
if (mrec->map_name)
1296-
fprintf(stdout, " map-name=\"%s\"", mrec->map_name);
1297-
if (mrec->enc_name)
1298-
fprintf(stdout, " enc-name=\"%s\"", mrec->enc_name);
1299-
if (mrec->font_name)
1300-
fprintf(stdout, " font-name=\"%s\"", mrec->font_name);
1301-
if (mrec->charmap.sfd_name && mrec->charmap.subfont_id) {
1302-
fprintf(stdout, " charmap=\"sfd:%s,%s\"",
1303-
mrec->charmap.sfd_name, mrec->charmap.subfont_id);
1304-
}
1305-
if (opt->slant != 0.0)
1306-
fprintf(stdout, " font-slant=\"%g\"", opt->slant);
1307-
if (opt->extend != 1.0)
1308-
fprintf(stdout, " font-extend=\"%g\"", opt->extend);
1309-
if (opt->charcoll)
1310-
fprintf(stdout, " glyph-order=\"%s\"", opt->charcoll);
1311-
if (opt->tounicode)
1312-
fprintf(stdout, " tounicode=\"%s\"", opt->tounicode);
1313-
if (opt->index != 0)
1314-
fprintf(stdout, " ttc-index=\"%d\"", opt->index);
1315-
if (opt->flags & FONTMAP_OPT_NOEMBED)
1316-
fprintf(stdout, " embedding=\"no\"");
1317-
if (opt->mapc >= 0) {
1318-
fprintf(stdout, " charmap=\"pad:");
1319-
if (opt->mapc > 0xffff)
1320-
fprintf(stdout, "%02x %02x", (opt->mapc >> 16) & 0xff, (opt->mapc >> 8) & 0xff);
1321-
else
1322-
fprintf(stdout, "%02x", (opt->mapc >> 8) & 0xff);
1323-
fprintf(stdout, "\"");
1324-
}
1325-
if (opt->flags & FONTMAP_OPT_VERT)
1326-
fprintf(stdout, " writing-mode=\"vertical\"");
1327-
if (opt->style != FONTMAP_STYLE_NONE) {
1328-
fprintf(stdout, " font-style=\"");
1329-
switch (opt->style) {
1330-
case FONTMAP_STYLE_BOLD:
1331-
fprintf(stdout, "bold");
1332-
break;
1333-
case FONTMAP_STYLE_ITALIC:
1334-
fprintf(stdout, "italic");
1335-
break;
1336-
case FONTMAP_STYLE_BOLDITALIC:
1337-
fprintf(stdout, "bolditalic");
1338-
break;
1339-
}
1340-
fprintf(stdout, "\"");
1341-
}
1342-
if (mrec->map_name)
1343-
fprintf(stdout, " / -->\n");
1344-
else
1345-
fprintf(stdout, " />\n");
1346-
}
1347-
1348-
void
1349-
dump_fontmaps (void)
1350-
{
1351-
struct ht_iter iter;
1352-
fontmap_rec *mrec;
1353-
char key[128], *kp;
1354-
int kl;
1355-
1356-
if (!fontmap)
1357-
return;
1358-
1359-
fprintf(stdout, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1360-
fprintf(stdout, "<!DOCTYPE fontmap SYSTEM \"fontmap.dtd\">\n");
1361-
fprintf(stdout, "<fontmap id=\"%s\">\n", "foo");
1362-
if (ht_set_iter(fontmap, &iter) == 0) {
1363-
do {
1364-
kp = ht_iter_getkey(&iter, &kl);
1365-
mrec = ht_iter_getval(&iter);
1366-
if (kl > 127)
1367-
continue;
1368-
memcpy(key, kp, kl); key[kl] = 0;
1369-
dump_fontmap_rec(key, mrec);
1370-
} while (!ht_iter_next(&iter));
1371-
}
1372-
ht_clear_iter(&iter);
1373-
fprintf(stdout, "</fontmap>\n");
1374-
1375-
return;
1376-
}
1377-
1378-
void
1379-
test_fontmap_help (void)
1380-
{
1381-
fprintf(stdout, "usage: fontmap [options] [mapfile...]\n");
1382-
fprintf(stdout, "-l, --lookup string\n");
1383-
fprintf(stdout, " Lookup fontmap entry for 'string' after loading mapfile(s).\n");
1384-
}
1385-
1386-
int
1387-
test_fontmap_main (int argc, char *argv[])
1388-
{
1389-
int i;
1390-
char *key = NULL;
1391-
1392-
for (;;) {
1393-
int c, optidx = 0;
1394-
static struct option long_options[] = {
1395-
{"lookup", 1, 0, 'l'},
1396-
{"help", 0, 0, 'h'},
1397-
{0, 0, 0, 0}
1398-
};
1399-
c = getopt_long(argc, argv, "l:h", long_options, &optidx);
1400-
if (c == -1)
1401-
break;
1402-
1403-
switch (c) {
1404-
case 'l':
1405-
key = optarg;
1406-
break;
1407-
case 'h':
1408-
test_fontmap_help();
1409-
return 0;
1410-
break;
1411-
default:
1412-
test_fontmap_help();
1413-
return -1;
1414-
break;
1415-
}
1416-
}
1417-
1418-
pdf_init_fontmaps();
1419-
for (i = optind; i < argc; i++)
1420-
pdf_load_fontmap_file(argv[i], FONTMAP_RMODE_REPLACE);
1421-
1422-
if (key == NULL)
1423-
dump_fontmaps();
1424-
else {
1425-
fontmap_rec *mrec;
1426-
mrec = pdf_lookup_fontmap_record(key);
1427-
if (mrec)
1428-
dump_fontmap_rec(key, mrec);
1429-
else {
1430-
dpx_warning("Fontmap entry \"%s\" not found.", key);
1431-
}
1432-
}
1433-
pdf_close_fontmaps();
1434-
1435-
return 0;
1436-
}
1437-
#endif /* DPXTEST */

tectonic/dpx-subfont.c

Lines changed: 0 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -472,180 +472,3 @@ release_sfd_record (void)
472472
num_sfd_records = max_sfd_records = 0;
473473
num_sfd_files = max_sfd_files = 0;
474474
}
475-
476-
477-
#ifdef DPXTEST
478-
/* SFD file dumper */
479-
#ifdef HAVE_ICONV
480-
#include <iconv.h>
481-
#else
482-
typedef int iconv_t;
483-
#endif
484-
#include <string.h>
485-
486-
static void
487-
dump_table (const char *sfd_name, const char *sub_name, iconv_t cd)
488-
{
489-
int rec_id, i;
490-
491-
rec_id = sfd_load_record(sfd_name, sub_name);
492-
if (rec_id < 0) {
493-
dpx_warning("Could not load SFD mapping for \"%s\"", sub_name);
494-
return;
495-
}
496-
fprintf(stdout, " <subfont id=\"%s\">\n", sub_name);
497-
for (i = 0; i < 256; i++) {
498-
unsigned short c = lookup_sfd_record(rec_id, i);
499-
char *p, inbuf[2];
500-
char *q, outbuf[32];
501-
size_t r, inbufleft = 2, outbufleft = 32;
502-
503-
if (c == 0)
504-
fprintf(stdout, " <!-- %02x: undefined -->", i);
505-
else {
506-
fprintf(stdout, " <a bi=\"%02x\" bo=\"%02x %02x\"", i, (c >> 8) & 0xff, c & 0xff);
507-
if (cd != (iconv_t) -1) {
508-
p = inbuf; q = outbuf;
509-
inbuf[0] = (c >> 8) & 0xff;
510-
inbuf[1] = c & 0xff;
511-
#ifdef HAVE_ICONV
512-
r = iconv(cd, &p, &inbufleft, &q, &outbufleft);
513-
if (r == -1) {
514-
if (verbose) {
515-
dpx_warning("Conversion to Unicode failed for subfont-id=\"%s\" code=\"0x%02x\"",
516-
sub_name, i);
517-
dpx_warning(">> with: %s", strerror(errno));
518-
}
519-
} else {
520-
outbuf[32-outbufleft] = 0;
521-
fprintf(stdout, " uc=\"%s\"", outbuf);
522-
}
523-
#endif /* HAVE_ICONV */
524-
}
525-
fprintf(stdout, " />");
526-
}
527-
fprintf(stdout, "\n");
528-
}
529-
fprintf(stdout, " </subfont>\n");
530-
return;
531-
}
532-
533-
#define subfontDefinition_DTD "\
534-
<!ELEMENT subfontDefinition (subfont+)>\n\
535-
<!ATTLIST subfontDefinition\n\
536-
id CDATA #REQUIRED\n\
537-
output-encoding CDATA #IMPLIED\n\
538-
>\n\
539-
<!ELEMENT subfont (a*)>\n\
540-
<!ATTLIST subfont\n\
541-
id CDATA #REQUIRED\n\
542-
>\n\
543-
<!ELEMENT a EMPTY>\n\
544-
<!ATTLIST a\n\
545-
bi NMTOKENS #REQUIRED\n\
546-
bo NMTOKENS #REQUIRED\n\
547-
uc CDATA #IMPLIED\n\
548-
>\
549-
"
550-
551-
void
552-
test_subfont_help (void)
553-
{
554-
fprintf(stdout, "usage: subfont [options] SFD_name\n");
555-
fprintf(stdout, "-e, --encoding string\n");
556-
fprintf(stdout, " Target (output) encoding of SFD mapping is 'string'.\n");
557-
fprintf(stdout, " It must be an encoding name recognized by iconv.\n");
558-
fprintf(stdout, " With this option write Unicode character in auxiliary attribute 'uc'.\n");
559-
fprintf(stdout, "-s, --subfont-id string\n");
560-
fprintf(stdout, " Load and dump mapping table only for subfont 'string'.\n");
561-
}
562-
563-
int
564-
test_subfont_main (int argc, char *argv[])
565-
{
566-
char *sfd_name = NULL, *sub_name = NULL;
567-
char *from = NULL;
568-
int i;
569-
iconv_t cd = (iconv_t) -1;
570-
571-
for (;;) {
572-
int c, optidx = 0;
573-
static struct option long_options[] = {
574-
{"encoding", 1, 0, 'e'}, /* for to-Unicode conversion */
575-
{"subfont-id", 1, 0, 's'},
576-
{"help", 0, 0, 'h'},
577-
{0, 0, 0, 0}
578-
};
579-
c = getopt_long(argc, argv, "e:s:h", long_options, &optidx);
580-
if (c == -1)
581-
break;
582-
583-
switch (c) {
584-
case 'e':
585-
from = optarg;
586-
break;
587-
case 's':
588-
sub_name = optarg;
589-
break;
590-
case 'h':
591-
test_subfont_help();
592-
return 0;
593-
break;
594-
default:
595-
test_subfont_help();
596-
return -1;
597-
break;
598-
}
599-
}
600-
if (optind < argc) {
601-
sfd_name = argv[optind++];
602-
}
603-
604-
if (sfd_name == NULL) {
605-
dpx_warning("No SFD file name specified.");
606-
test_subfont_help();
607-
return -1;
608-
}
609-
if (!from)
610-
cd = (iconv_t) -1;
611-
else {
612-
#ifdef HAVE_ICONV
613-
cd = iconv_open("utf-8", from);
614-
if (cd == (iconv_t) -1) {
615-
dpx_warning("Can't open iconv conversion descriptor for %s --> utf-8", from);
616-
return -1;
617-
}
618-
#else
619-
dpx_warning("Your system doesn't have iconv() in libc!");
620-
#endif
621-
}
622-
623-
fprintf(stdout, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
624-
fprintf(stdout, "<!DOCTYPE subfontDefinition [\n%s\n]>\n",
625-
subfontDefinition_DTD);
626-
fprintf(stdout, "<subfontDefinition id=\"%s\" output-encoding=\"%s\">\n",
627-
sfd_name, from ? from : "unknown");
628-
if (sub_name == NULL || !strcmp(sub_name, "all")) {
629-
char **sub_id;
630-
int num_ids = 0;
631-
sub_id = sfd_get_subfont_ids(sfd_name, &num_ids);
632-
if (!sub_id)
633-
dpx_warning("Could not open SFD file: %s", sfd_name);
634-
else {
635-
for (i = 0; i < num_ids; i++)
636-
dump_table(sfd_name, sub_id[i], cd);
637-
}
638-
} else {
639-
dump_table(sfd_name, sub_name, cd);
640-
}
641-
fprintf(stdout, "</subfontDefinition>\n");
642-
643-
#ifdef HAVE_ICONV
644-
if (cd != (iconv_t) -1)
645-
iconv_close(cd);
646-
#endif
647-
648-
return 0;
649-
}
650-
651-
#endif /* DPXTEST */

0 commit comments

Comments
 (0)