0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 20:03:10 +02:00

read font files from the same dir as font.desc or as specified in font.desc

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2223 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
atlka 2001-10-16 10:14:04 +00:00
parent 48f75aa656
commit dbff3945fd

View File

@ -45,6 +45,7 @@ unsigned char sor[1024];
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 @@ memset(desc,0,sizeof(font_desc_t));
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
// desc->fpath=get_path("font/");
// if (stat(desc->fpath, &fstate)!=0) desc->fpath=DATADIR"/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 @@ while(fgets(sor,1020,f)){
if(strcmp(section,"[fpath]")==0){
if(pdb==1){
if (desc->fpath)
free (desc->fpath); // release previously allocated memory
desc->fpath=strdup(p[0]);
continue;
}