changeset 2222:ddf897c38fb1

read font files from the same dir as font.desc or as specified in font.desc
author atlka
date Tue, 16 Oct 2001 10:14:04 +0000
parents 9fd911c931cd
children 560267b2ede8
files libvo/font_load.c
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/font_load.c	Tue Oct 16 02:31:14 2001 +0000
+++ b/libvo/font_load.c	Tue Oct 16 10:14:04 2001 +0000
@@ -45,6 +45,7 @@
 unsigned char sor2[1024];
 font_desc_t *desc;
 FILE *f;
+char *dn;
 struct stat fstate;
 char section[64];
 int i,j;
@@ -57,9 +58,19 @@
 
 f=fopen(fname,"rt");if(!f){ printf("font: can't open file: %s\n",fname); return NULL;}
 
-desc->fpath=get_path("font/");
+i = strlen (fname) - 9;
+if ((dn = malloc(i+1))!=NULL){
+   strncpy (dn, fname, i);
+   dn[i]='\0';
+}
+
+desc->fpath = dn; // search in the same dir as fonts.desc
 	
-if (stat(desc->fpath, &fstate)!=0) desc->fpath=DATADIR"/font";
+// desc->fpath=get_path("font/");
+// if (stat(desc->fpath, &fstate)!=0) desc->fpath=DATADIR"/font";
+
+	
+	
 	
 // set up some defaults, and erase table
 desc->charspace=2;
@@ -120,6 +131,8 @@
   
   if(strcmp(section,"[fpath]")==0){
       if(pdb==1){
+	  if (desc->fpath)
+	     free (desc->fpath); // release previously allocated memory
           desc->fpath=strdup(p[0]);
           continue;
       }