--- tgif-QPL-4.1.45/font.c.fontcheck 2006-06-14 07:29:58.000000000 +0900
+++ tgif-QPL-4.1.45/font.c 2007-01-04 11:28:03.000000000 +0900
@@ -363,16 +363,59 @@ static char *charCodeToName[] = {
#define InfoIndex(FontIdx,StyleIdx) (((FontIdx)*MAXFONTSTYLES+(StyleIdx))*3)
static int debugScalableFonts=FALSE; /* debug scalable font */
static char gszAttemptedFontName[MAXSTRING+1];
static struct PushedFontRec gstSavedFontInfo;
+static Bool IsFontExistent(font_name, dbflag)
+ char *font_name;
+ int dbflag;
+{
+ unsigned char c;
+ unsigned char *buf, *dist, *src;
+ char **font_list;
+ int actual_count_return;
+
+ if (!font_name)
+ return False;
+
+ buf = (unsigned char*)malloc (strlen(font_name) + 3);
+ if (!buf)
+ return False;
+
+ /* replace "%d" to "*" */
+ dist = buf;
+ if (!dbflag)
+ *dist++ = '*';
+
+ src = font_name;
+ while ((c = *src++)) {
+ if (c == '%' && isalpha(*src))
+ c = '*', src++;
+ *dist++ = c;
+ }
+ if (!dbflag)
+ *dist++ = '*';
+ *dist = '\0';
+
+ font_list = XListFonts(mainDisplay, buf, 1, &actual_count_return);
+
+ free(buf);
+ if (font_list)
+ XFreeFontNames(font_list);
+
+ if (actual_count_return)
+ return True;
+ else
+ return False;
+}
+
int IsFontDoubleByte(font_index)
int font_index;
{
return fontFamilies[font_index].double_byte;
}
int IsDoubleByteFontVertical(font_index, style)
int font_index, style;
@@ -2875,27 +2918,29 @@ void InitAdditionalFonts()
strcpy(buf, c_ptr);
for (font_ptr=buf; *font_ptr != '\0' &&
strchr(" ,\t\n\r",*font_ptr) != NULL; font_ptr++) {
}
if (font_ptr != NULL && *font_ptr != '\0') {
int ok=TRUE, index;
char **font_strings=NULL;
struct TmpFontFmlyRec *fmly_ptr=NULL;
+ Bool isFontExistent=False;
while (ok && font_ptr != NULL && *font_ptr != '\0') {
font_strings = (char**)malloc((MAXFONTSTYLES*3)*sizeof(char *));
if (font_strings == NULL) FailAllocMessage();
for (i=0, index=0; i<MAXFONTSTYLES; i++) {
char *rgstry=NULL, *ps_name=NULL, *dup_ptr;
dup_ptr = (font_ptr == NULL ? NULL : UtilStrDup(font_ptr));
if ((font_ptr=strtok(font_ptr,",\t\n\r")) != NULL &&
(rgstry=strtok(NULL,",\t\n\r")) != NULL &&
- (ps_name=strtok(NULL," ,\t\n\r")) != NULL) {
+ (ps_name=strtok(NULL," ,\t\n\r")) != NULL &&
+ (isFontExistent=IsFontExistent(font_ptr, 0)) == True) {
font_strings[index] = (char*)malloc(MAXSTRING*sizeof(char));
if (font_strings[index] == NULL) FailAllocMessage();
strcpy(font_strings[index], font_ptr);
UtilTrimBlanks(font_strings[index++]);
font_strings[index] = (char*)malloc(MAXSTRING*sizeof(char));
if (font_strings[index] == NULL) FailAllocMessage();
strcpy(font_strings[index], rgstry);
UtilTrimBlanks(font_strings[index++]);
@@ -2926,23 +2971,34 @@ void InitAdditionalFonts()
} else if (rgstry == NULL) {
sprintf(gszMsgBox,
TgLoadString(STID_INVALID_X_REG_INFO_IN_XDEF),
TOOL_NAME, "AdditionalFonts", dup_ptr);
} else if (ps_name == NULL) {
sprintf(gszMsgBox,
TgLoadString(STID_INVALID_PS_INFO_IN_XDEF),
TOOL_NAME, "AdditionalFonts", dup_ptr);
- }
- fprintf(stderr, "%s\n", gszMsgBox);
+ } else if (isFontExistent == False) {
+ ok = True;
+#ifdef _TGIF_DBG
+ sprintf(gszMsgBox,
+ "Warning: No such font: %s", font_ptr);
+#endif
+ for (font_ptr=(&ps_name[strlen(ps_name)+1]);
+ *font_ptr != '\0' &&
+ strchr(" ,\t\n\r",*font_ptr) != NULL; font_ptr++) {
+ }
+ }
+ if (*gszMsgBox)
+ fprintf(stderr, "%s\n", gszMsgBox);
}
if (dup_ptr != NULL) free(dup_ptr);
if (!ok) break;
}
- if (ok) {
+ if (ok && isFontExistent) {
num_new_fonts++;
fmly_ptr = (struct TmpFontFmlyRec *)malloc(
sizeof(struct TmpFontFmlyRec));
if (fmly_ptr == NULL) FailAllocMessage();
memset(fmly_ptr, 0, sizeof(struct TmpFontFmlyRec));
fmly_ptr->next = NULL;
fmly_ptr->prev = last_fmly;
fmly_ptr->font_strings = font_strings;
@@ -2968,27 +3024,29 @@ void InitAdditionalFonts()
strcpy(buf, c_ptr);
for (font_ptr=buf; *font_ptr != '\0' &&
strchr(" ,\t\n\r",*font_ptr) != NULL; font_ptr++) {
}
if (font_ptr != NULL && *font_ptr != '\0') {
int ok=TRUE, index;
char **font_strings=NULL;
struct TmpFontFmlyRec *fmly_ptr=NULL;
+ Bool isFontExistent=False;
while (ok && font_ptr != NULL && *font_ptr != '\0') {
font_strings = (char**)malloc((MAXFONTSTYLES*3)*sizeof(char *));
if (font_strings == NULL) FailAllocMessage();
for (i=0, index=0; i<MAXFONTSTYLES; i++) {
char *rgstry=NULL, *ps_name=NULL, *dup_ptr;
dup_ptr = (font_ptr == NULL ? NULL : UtilStrDup(font_ptr));
if ((font_ptr=strtok(font_ptr,",\t\n\r")) != NULL &&
(rgstry=strtok(NULL,",\t\n\r")) != NULL &&
- (ps_name=strtok(NULL," ,\t\n\r")) != NULL) {
+ (ps_name=strtok(NULL," ,\t\n\r")) != NULL &&
+ (isFontExistent=IsFontExistent(font_ptr, 1)) == True) {
font_strings[index] = (char*)malloc(MAXSTRING*sizeof(char));
if (font_strings[index] == NULL) FailAllocMessage();
strcpy(font_strings[index], font_ptr);
UtilTrimBlanks(font_strings[index++]);
font_strings[index] = (char*)malloc(MAXSTRING*sizeof(char));
if (font_strings[index] == NULL) FailAllocMessage();
strcpy(font_strings[index], rgstry);
UtilTrimBlanks(font_strings[index++]);
@@ -3019,23 +3077,34 @@ void InitAdditionalFonts()
} else if (rgstry == NULL) {
sprintf(gszMsgBox,
TgLoadString(STID_INVALID_X_REG_INFO_IN_XDEF),
TOOL_NAME, "SquareDoubleByteFonts", dup_ptr);
} else if (ps_name == NULL) {
sprintf(gszMsgBox,
TgLoadString(STID_INVALID_PS_INFO_IN_XDEF),
TOOL_NAME, "SquareDoubleByteFonts", dup_ptr);
- }
- fprintf(stderr, "%s\n", gszMsgBox);
+ } else if (isFontExistent == False) {
+ ok = True;
+#ifdef _TGIF_DBG
+ sprintf(gszMsgBox,
+ "Warning: No such font: %s", font_ptr);
+#endif
+ for (font_ptr=(&ps_name[strlen(ps_name)+1]);
+ *font_ptr != '\0' &&
+ strchr(" ,\t\n\r",*font_ptr) != NULL; font_ptr++) {
+ }
+ }
+ if (*gszMsgBox)
+ fprintf(stderr, "%s\n", gszMsgBox);
}
if (dup_ptr != NULL) free(dup_ptr);
if (!ok) break;
}
- if (ok) {
+ if (ok && isFontExistent) {
num_new_fonts++;
fmly_ptr = (struct TmpFontFmlyRec *)malloc(
sizeof(struct TmpFontFmlyRec));
if (fmly_ptr == NULL) FailAllocMessage();
memset(fmly_ptr, 0, sizeof(struct TmpFontFmlyRec));
fmly_ptr->next = NULL;
fmly_ptr->prev = last_fmly;
fmly_ptr->font_strings = font_strings;