Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 426) +++ trunk/src/main.c (revision 427) @@ -86,6 +86,7 @@ extern void stroke_init (void); #endif +char *fontfile_paths[] = {"./default_font", PCBLIBDIR "/default_font", NULL}; /* ---------------------------------------------------------------------- * initialize signal and error handlers @@ -1052,7 +1053,7 @@ @end ftable %end-doc */ - SSET (FontFile, "default_font", "default-font", + SSET (FontFile, NULL, "default-font", "File name of default font"), /* %start-doc options "5 Paths" @@ -1560,6 +1561,26 @@ } } +static void set_fontfile(void) +{ + if (Settings.FontFile == NULL) { + char **s; + for(s = fontfile_paths; *s != NULL; s++) { +fprintf(stderr, "font: '%s'\n", *s); + if (access (*s, R_OK) == 0) { + Settings.FontFile= *s; + break; + } + } + } + + if (Settings.FontFile == NULL) { + Message("Error: no font file found"); + exit(1); + } + +} + /* ---------------------------------------------------------------------- * main program */ @@ -1690,6 +1711,8 @@ exit (0); } + set_fontfile(); + /* Create a new PCB object in memory */ PCB = CreateNewPCB (); Index: trunk/src/parse_l.c =================================================================== --- trunk/src/parse_l.c (revision 426) +++ trunk/src/parse_l.c (revision 427) @@ -2436,9 +2436,14 @@ yyFont = Ptr; yyElement = NULL; + /* search through the font path for a font file */ + if ((Filename[0] == '/') || (strncmp(Filename, "./", 2) == 0) || (strncmp(Filename, "../", 2) == 0)) { + r = Parse(NULL, Settings.FontCommand, NULL, Filename, NULL); + if (r != "") + return r; + } + path = strdup (Settings.FontPath); - - /* search through the font path for a font file */ for (p = strtok (path, PCB_PATH_DELIMETER); p && *p; p = strtok (NULL, PCB_PATH_DELIMETER)) { Index: trunk/src/parse_l.l =================================================================== --- trunk/src/parse_l.l (revision 426) +++ trunk/src/parse_l.l (revision 427) @@ -352,9 +352,14 @@ yyFont = Ptr; yyElement = NULL; + /* search through the font path for a font file */ + if ((Filename[0] == '/') || (strncmp(Filename, "./", 2) == 0) || (strncmp(Filename, "../", 2) == 0)) { + r = Parse(NULL, Settings.FontCommand, NULL, Filename, NULL); + if (r != "") + return r; + } + path = strdup (Settings.FontPath); - - /* search through the font path for a font file */ for (p = strtok (path, PCB_PATH_DELIMETER); p && *p; p = strtok (NULL, PCB_PATH_DELIMETER)) {