From: Ben Harris Date: Sat, 2 Nov 2024 10:02:28 +0000 (+0000) Subject: Generate 'head' table for TTX X-Git-Tag: bedstead-3.246~77 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=9899c0e4a655ba4962d1cc7be70716e3ede79db7;p=bedstead.git Generate 'head' table for TTX --- diff --git a/bedstead.c b/bedstead.c index f44517d..3db3a4e 100644 --- a/bedstead.c +++ b/bedstead.c @@ -104,6 +104,9 @@ #include #include #include +#include + +#define VERSION "002.009" #define XSIZE 6 #define YSIZE 10 @@ -2674,6 +2677,31 @@ fullname_to_fontname(char const *fullname) return fontname; } +/* Get a suitable asctime-format time string for a TTX file. */ +static char * +time_for_ttx(void) +{ + time_t now; + struct tm *timeptr; + char *timestr; + + /* Work out what timestamp to use. */ + now = time(NULL); + if (now == (time_t)-1) { + fprintf(stderr, "Can't get current time\n"); + return NULL; + } + timeptr = gmtime(&now); + if (timeptr == NULL) { + fprintf(stderr, "Can't convert time to UTC\n"); + return NULL; + } + timestr = asctime(timeptr); + assert(strlen(timestr) == 25); + timestr[24] = '\0'; /* Remove newline. */ + return timestr; +} + static int compare_glyphs_by_name(const void *va, const void *vb) { @@ -2731,7 +2759,7 @@ main(int argc, char **argv) bool gen_bdf = false; int i; int extraglyphs = 0; - char *endptr; + char *endptr, *timestr; if (argc == 2 && strcmp(argv[1], "--complement") == 0) { glyph_complement(); @@ -2816,6 +2844,34 @@ main(int argc, char **argv) extraglyphs++; printf("\n"); printf("\n"); + printf(" \n"); + printf(" \n"); + printf(" \n", VERSION); + printf(" \n"); + printf(" \n"); + /* + * Flags: + * Baseline and left sidebearing point at (0,0) + * Force ppem to integer + */ + printf(" \n"); + printf(" \n", (int)(YSIZE * YPIX)); + if ((timestr = time_for_ttx()) == NULL) return 1; + printf(" \n", timestr); + printf(" \n", timestr); + printf(" \n", 0); + printf(" \n", (int)(-2 * YPIX)); + printf(" \n", (int)(XSIZE * XPIX)); + printf(" \n", (int)((YSIZE - 2) * YPIX)); + printf(" \n", + width->ttfwidth > 5 ? '1' : '0', /* Expanded? */ + width->ttfwidth < 5 ? '1' : '0', /* Condensed? */ + weight->ttfweight > 500 ? '1' : '0'); /* Bold? */ + printf(" \n", (int)YSIZE); + printf(" \n"); /* Fully bi-di. */ + printf(" \n"); + printf(" \n"); + printf(" \n"); /* printf("FontName: %s\n", fullname_to_fontname(get_fullname())); */ /* printf("FullName: %s\n", get_fullname()); */ /* printf("FamilyName: Bedstead\n"); */