From 6a529f89e20913dd3b0e1c9f13e9c53864725555 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 10 Oct 2009 18:05:11 +0100 Subject: [PATCH] Pull out creation of lookups into its own function, since main() was getting a bit big. --- ttxt.c | 64 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/ttxt.c b/ttxt.c index e461a66..3b49f6d 100644 --- a/ttxt.c +++ b/ttxt.c @@ -105,6 +105,7 @@ #include #include #include +#include #define XSIZE 6 #define YSIZE 10 @@ -547,6 +548,8 @@ struct glyph { {{000,000,037,002,004,010,037,000,000}, -1, "z.sc" }, }; +static void dolookups(struct glyph *); + inline int getpix(char data[YSIZE], int x, int y, unsigned flags) { @@ -617,30 +620,7 @@ main(int argc, char **argv) printf("Width: 600\n"); printf("Flags: W\n"); printf("LayerCount: 2\n"); - if ((glyphs[i].flags & SC)) - printf("Substitution2: \"%s\" %c%s.sc\n", - isupper((unsigned char)glyphs[i].name[0]) ? - "c2sc" : "smcp", - tolower((unsigned char)glyphs[i].name[0]), - glyphs[i].name + 1); - switch (glyphs[i].flags & Amask) { - case A1: - printf("MultipleSubs2: \"tails\" uni%04X tail1\n", - (unsigned)glyphs[i].unicode); - break; - case A2: - printf("MultipleSubs2: \"tails\" uni%04X tail2\n", - (unsigned)glyphs[i].unicode); - break; - case A3: - printf("MultipleSubs2: \"tails\" uni%04X tail3\n", - (unsigned)glyphs[i].unicode); - break; - case AFI: - printf("Substitution2: \"finaisol\" uni%04X.fina\n", - (unsigned)glyphs[i].unicode); - break; - } + dolookups(&glyphs[i]); dochar(glyphs[i].data, glyphs[i].flags); printf("EndChar\n"); } @@ -649,6 +629,42 @@ main(int argc, char **argv) return 0; } +void +dolookups(struct glyph *g) +{ + char glyphname[32]; + + if (g->name) + strcpy(glyphname, g->name); + else + sprintf(glyphname, "uni%04X", g->unicode); + + if ((g->flags & SC)) + printf("Substitution2: \"%s\" %c%s.sc\n", + isupper((unsigned char)g->name[0]) ? + "c2sc" : "smcp", + tolower((unsigned char)g->name[0]), + g->name + 1); + switch (g->flags & Amask) { + case A1: + printf("MultipleSubs2: \"tails\" %s tail1\n", + glyphname); + break; + case A2: + printf("MultipleSubs2: \"tails\" %s tail2\n", + glyphname); + break; + case A3: + printf("MultipleSubs2: \"tails\" %s tail3\n", + glyphname); + break; + case AFI: + printf("Substitution2: \"finaisol\" %s.fina\n", + glyphname); + break; + } +} + typedef struct vec { signed char x, y; } vec; -- 2.30.2