comparison gui/skin/font.c @ 33073:334e19411421

Improve handling of the comment character. The comment character is safe now between (double) quotation marks. This simplifies handling in the font description file and allows it to be used in label texts.
author ib
date Wed, 30 Mar 2011 14:24:11 +0000
parents f64d41dac10b
children 8b561660a6f7
comparison
equal deleted inserted replaced
33072:036e8492be61 33073:334e19411421
74 74
75 int fntRead(char *path, char *fname) 75 int fntRead(char *path, char *fname)
76 { 76 {
77 FILE *f; 77 FILE *f;
78 unsigned char tmp[512]; 78 unsigned char tmp[512];
79 unsigned char *ptmp;
80 unsigned char command[32]; 79 unsigned char command[32];
81 unsigned char param[256]; 80 unsigned char param[256];
82 int id, n, i; 81 int id, n, i;
83 82
84 id = fntAddNewFont(fname); 83 id = fntAddNewFont(fname);
98 97
99 while (fgets(tmp, sizeof(tmp), f)) { 98 while (fgets(tmp, sizeof(tmp), f)) {
100 tmp[strcspn(tmp, "\n\r")] = 0; // remove any kind of newline, if any 99 tmp[strcspn(tmp, "\n\r")] = 0; // remove any kind of newline, if any
101 strswap(tmp, '\t', ' '); 100 strswap(tmp, '\t', ' ');
102 trim(tmp); 101 trim(tmp);
103 ptmp = strchr(tmp, ';'); 102 decomment(tmp);
104
105 if (ptmp && !(ptmp == tmp + 1 && tmp[0] == '"' && tmp[2] == '"'))
106 *ptmp = 0;
107 103
108 if (!*tmp) 104 if (!*tmp)
109 continue; 105 continue;
110 106
111 n = (strncmp(tmp, "\"=", 2) == 0 ? 1 : 0); 107 n = (strncmp(tmp, "\"=", 2) == 0 ? 1 : 0);