Mercurial > hg > dmlib
comparison tools/fontconv.c @ 2408:60e119262c67
Option index re-ordering cleanup work.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 13 Jan 2020 21:21:25 +0200 |
parents | b7cd5dd0b82e |
children | bc05bcfc4598 |
comparison
equal
deleted
inserted
replaced
2407:c5a32812dd97 | 2408:60e119262c67 |
---|---|
22 SDL_Color optColor = { 255, 255, 255, 100 }; | 22 SDL_Color optColor = { 255, 255, 255, 100 }; |
23 | 23 |
24 | 24 |
25 static const DMOptArg optList[] = | 25 static const DMOptArg optList[] = |
26 { | 26 { |
27 { 0, '?', "help", "Show this help", OPT_NONE }, | 27 { 0, '?', "help" , "Show this help", OPT_NONE }, |
28 { 1, 'v', "verbose", "Be more verbose", OPT_NONE }, | 28 { 2, 'v', "verbose" , "Be more verbose", OPT_NONE }, |
29 { 2, 's', "size", "Set glyph dimensions (-s W:H or -s N) for image->font conversion", OPT_ARGREQ }, | 29 |
30 { 10, 's', "size" , "Set glyph dimensions (-s W:H or -s N) for image->font conversion", OPT_ARGREQ }, | |
30 #ifdef DM_GFX_TTF_TEXT | 31 #ifdef DM_GFX_TTF_TEXT |
31 { 3, 'c', "color", "TTF font rendering color (def: 0xFFFFFF)", OPT_ARGREQ }, | 32 { 12, 'c', "color" , "TTF font rendering color (def: 0xFFFFFF)", OPT_ARGREQ }, |
32 { 4, 'b', "bpp", "Render font in 8 or 32 bits per pixel (default 32)", OPT_ARGREQ }, | 33 { 14, 'b', "bpp" , "Render font in 8 or 32 bits per pixel (default 32)", OPT_ARGREQ }, |
33 #endif | 34 #endif |
34 }; | 35 }; |
35 | 36 |
36 const int optListN = sizeof(optList) / sizeof(optList[0]); | 37 const int optListN = sizeof(optList) / sizeof(optList[0]); |
37 | 38 |
38 | 39 |
40 void argShowHelp() | |
41 { | |
42 dmPrintBanner(stdout, dmProgName, | |
43 "[options] <sourcefile.(ttf|fnt|dmf|png)> <outputfile.dmf>"); | |
44 | |
45 dmArgsPrintHelp(stdout, optList, optListN, 0, 80 - 2); | |
46 printf( | |
47 "\n" | |
48 "This utility can be used to convert TSFONT files to bitmap DMFONT (DMF)\n" | |
49 "files, render TrueType TTF to DMFONT at desired glyph resolution, or\n" | |
50 "cut a PNG (or JPEG) image to glyphs of desired size.\n"); | |
51 } | |
52 | |
53 | |
39 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) | 54 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) |
40 { | 55 { |
41 switch (optN) | 56 switch (optN) |
42 { | 57 { |
43 case 0: | 58 case 0: |
44 dmPrintBanner(stdout, dmProgName, | 59 argShowHelp(); |
45 "[options] <sourcefile.(ttf|fnt|dmf|png)> <outputfile.dmf>"); | |
46 | |
47 dmArgsPrintHelp(stdout, optList, optListN, 0, 80 - 2); | |
48 printf( | |
49 "\n" | |
50 "This utility can be used to convert TSFONT files to bitmap DMFONT (DMF)\n" | |
51 "files, render TrueType TTF to DMFONT at desired glyph resolution, or\n" | |
52 "cut a PNG (or JPEG) image to glyphs of desired size.\n"); | |
53 | |
54 exit(0); | 60 exit(0); |
55 break; | 61 break; |
56 | 62 |
57 case 1: | 63 case 1: |
58 dmVerbosity++; | 64 dmVerbosity++; |
59 break; | 65 break; |
60 | 66 |
61 case 2: | 67 case 10: |
62 { | 68 { |
63 unsigned int fontW, fontH; | 69 unsigned int fontW, fontH; |
64 char *sep = strchr(optArg, ':'); | 70 char *sep = strchr(optArg, ':'); |
65 if (sep != NULL) | 71 if (sep != NULL) |
66 { | 72 { |
101 optSplitWidth = fontW; | 107 optSplitWidth = fontW; |
102 optSplitHeight = fontH; | 108 optSplitHeight = fontH; |
103 } | 109 } |
104 break; | 110 break; |
105 | 111 |
106 case 3: | 112 case 12: |
107 { | 113 { |
108 unsigned int colR, colG, colB, colA = 100; | 114 unsigned int colR, colG, colB, colA = 100; |
109 if (optArg[0] == '#' || optArg[0] == '$') optArg++; | 115 if (optArg[0] == '#' || optArg[0] == '$') optArg++; |
110 else | 116 else |
111 if (optArg[0] == '0' && optArg[1] == 'x') optArg += 2; | 117 if (optArg[0] == '0' && optArg[1] == 'x') optArg += 2; |
123 optColor.b = colB; | 129 optColor.b = colB; |
124 optColor.a = colA; | 130 optColor.a = colA; |
125 } | 131 } |
126 break; | 132 break; |
127 | 133 |
128 case 4: | 134 case 14: |
129 if (sscanf(optArg, "%d", &optBPP) != 1) | 135 if (sscanf(optArg, "%d", &optBPP) != 1) |
130 { | 136 { |
131 dmErrorMsg("Invalid argument for -b option, '%s'.\n", | 137 dmErrorMsg("Invalid argument for -b option, '%s'.\n", |
132 optArg); | 138 optArg); |
133 return FALSE; | 139 return FALSE; |