- for (k = 0; k < wxNUM_WEIGHTS; k++) {
- switch (k) {
- case wxWEIGHT_NORMAL: weight = "Medium"; break;
- case wxWEIGHT_LIGHT: weight = "Light"; break;
- case wxWEIGHT_BOLD:
- default: weight = "Bold";
- }
- for (j = 0; j < wxNUM_STYLES; j++) {
- switch (j) {
- case wxSTYLE_NORMAL: style = "Straight"; break;
- case wxSTYLE_ITALIC: style = "Italic"; break;
- case wxSTYLE_SLANT:
- default: style = "Slant";
- }
- names[0] = resname;
- names[1] = weight;
- names[2] = style;
-
- SearchResource(devresname, names, 3, &v);
-
- /* Expand macros in the found string: */
- found:
- int len, closer = 0, startpos = 0;
-
- len = (v ? strlen(v) : 0);
- for (i = 0; i < len; i++) {
- if (v[i] == '$' && ((v[i+1] == '[') || (v[i+1] == '{'))) {
- startpos = i;
- closer = (v[i+1] == '[') ? ']' : '}';
- ++i;
- } else if (v[i] == closer) {
- int newstrlen;
- const char *r = (char *) NULL; bool delete_r = FALSE;
- char *name;
-
- name = v + startpos + 2;
- v[i] = 0;
-
- if (closer == '}') {
- int i, count, len;
- char **names;
-
- for (i = 0, count = 1; name[i]; i++)
- if (name[i] == ',')
- count++;
-
- len = i;
-
- names = new char*[count];
- names[0] = name;
- for (i = 0, count = 1; i < len; i++)
- if (name[i] == ',') {
- names[count++] = name + i + 1;
- name[i] = 0;
- }
-
- SearchResource("", (const char **)names, count, (char **)&r);
- delete_r = (r != 0);
- delete[] names;
-
- if (!r) {
- for (i = 0; i < len; i++)
- if (!name[i])
- name[i] = ',';
- r = "";
- printf("Bad resource name \"%s\" in font lookup\n", name);
- }
- } else if (!strcmp(name, "weight")) {
- r = weight;
- } else if (!strcmp(name, "style")) {
- r = style;
- } else if (!strcmp(name, "family")) {
- r = resname;
- } else {
- r = "";
- printf("Bad font macro name \"%s\"\n", name);
- }
-
- // add r to v
- newstrlen = strlen(r);
- char *naya = new char[startpos + newstrlen + len - i];
- memcpy(naya, v, startpos);
- memcpy(naya + startpos, r, newstrlen);
- memcpy(naya + startpos + newstrlen, v + i + 1, len - i);
- if (delete_r)
- delete[] (char*)r;
- delete[] v;
- v = naya;
-
- goto found;
- }
- }
- /* We have a final value: */
- map[k][j] = v;
- }
+ for (k = 0; k < wxNUM_WEIGHTS; k++)
+ {
+ switch (k)
+ {
+ case wxWEIGHT_NORMAL: weight = "Medium"; break;
+ case wxWEIGHT_LIGHT: weight = "Light"; break;
+ case wxWEIGHT_BOLD:
+ default: weight = "Bold";
+ }
+ for (j = 0; j < wxNUM_STYLES; j++)
+ {
+ switch (j)
+ {
+ case wxSTYLE_NORMAL: style = "Straight"; break;
+ case wxSTYLE_ITALIC: style = "Italic"; break;
+ case wxSTYLE_SLANT:
+ default: style = "Slant";
+ }
+ names[0] = resname;
+ names[1] = weight;
+ names[2] = style;
+
+ SearchResource(devresname, names, 3, &v);
+
+ // Expand macros in the found string:
+found:
+ int len, closer = 0, startpos = 0;
+
+ len = (v ? strlen(v) : 0);
+ for (i = 0; i < len; i++)
+ {
+ if (v[i] == '$' && ((v[i+1] == '[') || (v[i+1] == '{')))
+ {
+ startpos = i;
+ closer = (v[i+1] == '[') ? ']' : '}';
+ ++i;
+ }
+ else if (v[i] == closer)
+ {
+ int newstrlen;
+ const char *r = (char *) NULL; bool delete_r = FALSE;
+ char *name;
+
+ name = v + startpos + 2;
+ v[i] = 0;
+
+ if (closer == '}')
+ {
+ int i, count, len;
+ char **names;
+
+ for (i = 0, count = 1; name[i]; i++)
+ if (name[i] == ',')
+ count++;
+
+ len = i;
+
+ names = new char*[count];
+ names[0] = name;
+ for (i = 0, count = 1; i < len; i++)
+ if (name[i] == ',')
+ {
+ names[count++] = name + i + 1;
+ name[i] = 0;
+ }
+
+ SearchResource("", (const char **)names, count, (char **)&r);
+ delete_r = (r != 0);
+ delete[] names;
+
+ if (!r)
+ {
+ for (i = 0; i < len; i++)
+ if (!name[i])
+ name[i] = ',';
+ r = "";
+ wxLogError( "Bad resource name in font lookup." );
+ }
+ } else if (!strcmp(name, "weight")) {
+ r = weight;
+ } else if (!strcmp(name, "style")) {
+ r = style;
+ } else if (!strcmp(name, "family")) {
+ r = resname;
+ } else {
+ r = "";
+ wxLogError( "Bad font macro name." );
+ }
+
+ // add r to v
+ newstrlen = strlen(r);
+ char *naya = new char[startpos + newstrlen + len - i];
+ memcpy(naya, v, startpos);
+ memcpy(naya + startpos, r, newstrlen);
+ memcpy(naya + startpos + newstrlen, v + i + 1, len - i);
+ if (delete_r)
+ delete[] (char*)r;
+ delete[] v;
+ v = naya;
+
+ goto found;
+ }
+ }
+ // We have a final value:
+ map[k][j] = v;
+ }