Mercurial > mplayer.hg
annotate sub/font_load.c @ 36679:36cbede21428
Fix bug with unicode font loading for font.desc files.
Unicode glyphs might not get loaded even if they are requested and
available.
Fix it by checking the font encoding rather than the subtitle encoding
when loading the font.
author | ib |
---|---|
date | Sat, 01 Feb 2014 16:57:50 +0000 |
parents | a1e273544f61 |
children |
rev | line source |
---|---|
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
1 /* |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
2 * This file is part of MPlayer. |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
3 * |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
7 * (at your option) any later version. |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
8 * |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
13 * |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
17 */ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
18 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
19 #include "config.h" |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
20 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
21 #include <stdio.h> |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
22 #include <stdlib.h> |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
23 #include <string.h> |
36679
36cbede21428
Fix bug with unicode font loading for font.desc files.
ib
parents:
35252
diff
changeset
|
24 #include <strings.h> |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
25 #include <sys/types.h> |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
26 #include <sys/stat.h> |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
27 #include <unistd.h> |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
28 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
29 #include "font_load.h" |
32467 | 30 #include "sub.h" |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
31 #include "mp_msg.h" |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
32 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
33 raw_file* load_raw(char *name,int verbose){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
34 int bpp; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
35 raw_file* raw=malloc(sizeof(raw_file)); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
36 unsigned char head[32]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
37 FILE *f=fopen(name,"rb"); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
38 if(!f) goto err_out; // can't open |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
39 if(fread(head,32,1,f)<1) goto err_out; // too small |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
40 if(memcmp(head,"mhwanh",6)) goto err_out; // not raw file |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
41 raw->w=head[8]*256+head[9]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
42 raw->h=head[10]*256+head[11]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
43 raw->c=head[12]*256+head[13]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
44 if(raw->w == 0) // 2 bytes were not enough for the width... read 4 bytes from the end of the header |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
45 raw->w = ((head[28]*0x100 + head[29])*0x100 + head[30])*0x100 + head[31]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
46 if(raw->c>256) goto err_out; // too many colors!? |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
47 mp_msg(MSGT_OSD, MSGL_DBG2, "RAW: %s %d x %d, %d colors\n",name,raw->w,raw->h,raw->c); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
48 if(raw->c){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
49 raw->pal=malloc(raw->c*3); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
50 fread(raw->pal,3,raw->c,f); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
51 bpp=1; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
52 } else { |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
53 raw->pal=NULL; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
54 bpp=3; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
55 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
56 raw->bmp=malloc(raw->h*raw->w*bpp); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
57 fread(raw->bmp,raw->h*raw->w*bpp,1,f); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
58 fclose(f); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
59 return raw; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
60 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
61 err_out: |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
62 if (f) |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
63 fclose(f); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
64 free(raw); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
65 return NULL; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
66 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
67 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
68 font_desc_t* read_font_desc(const char* fname,float factor,int verbose){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
69 unsigned char sor[1024]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
70 unsigned char sor2[1024]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
71 FILE *f = NULL; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
72 char *dn; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
73 //struct stat fstate; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
74 char section[64]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
75 int i,j; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
76 int chardb=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
77 int fontdb=-1; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
78 int first=1; |
36679
36cbede21428
Fix bug with unicode font loading for font.desc files.
ib
parents:
35252
diff
changeset
|
79 int unicode; |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
80 |
35252 | 81 font_desc_t *desc=calloc(1, sizeof(*desc)); |
82 if(!desc) goto fail_out; | |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
83 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
84 f=fopen(fname,"rt");if(!f){ mp_msg(MSGT_OSD, MSGL_V, "font: can't open file: %s\n",fname); goto fail_out;} |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
85 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
86 i = strlen (fname) - 9; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
87 if ((dn = malloc(i+1))){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
88 strncpy (dn, fname, i); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
89 dn[i]='\0'; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
90 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
91 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
92 desc->fpath = dn; // search in the same dir as fonts.desc |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
93 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
94 // desc->fpath=get_path("font/"); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
95 // if (stat(desc->fpath, &fstate)!=0) desc->fpath=DATADIR"/font"; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
96 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
97 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
98 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
99 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
100 // set up some defaults, and erase table |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
101 desc->charspace=2; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
102 desc->spacewidth=12; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
103 desc->height=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
104 for(i=0;i<65536;i++) desc->start[i]=desc->width[i]=desc->font[i]=-1; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
105 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
106 section[0]=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
107 |
36679
36cbede21428
Fix bug with unicode font loading for font.desc files.
ib
parents:
35252
diff
changeset
|
108 unicode = !subtitle_font_encoding || strcasecmp(subtitle_font_encoding, "unicode") == 0; |
36cbede21428
Fix bug with unicode font loading for font.desc files.
ib
parents:
35252
diff
changeset
|
109 |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
110 while(fgets(sor,1020,f)){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
111 unsigned char* p[8]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
112 int pdb=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
113 unsigned char *s=sor; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
114 unsigned char *d=sor2; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
115 int ec=' '; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
116 int id=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
117 sor[1020]=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
118 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
119 /* skip files that look like: TTF (0x00, 0x01), PFM (0x00, 0x01), PFB |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
120 * (0x80, 0x01), PCF (0x01, 0x66), fon ("MZ"), gzipped (0x1f, 0x8b) */ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
121 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
122 if (first) { |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
123 if (!sor[0] || sor[1] == 1 || (sor[0] == 'M' && sor[1] == 'Z') || (sor[0] == 0x1f && sor[1] == 0x8b) || (sor[0] == 1 && sor[1] == 0x66)) { |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
124 mp_msg(MSGT_OSD, MSGL_ERR, "%s doesn't look like a bitmap font description, ignoring.\n", fname); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
125 goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
126 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
127 first = 0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
128 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
129 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
130 p[0]=d;++pdb; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
131 while(1){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
132 int c=*s++; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
133 if(c==0 || c==13 || c==10) break; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
134 if(!id){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
135 if(c==39 || c==34){ id=c;continue;} // idezojel |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
136 if(c==';' || c=='#') break; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
137 if(c==9) c=' '; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
138 if(c==' '){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
139 if(ec==' ') continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
140 *d=0; ++d; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
141 p[pdb]=d;++pdb; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
142 if(pdb>=8) break; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
143 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
144 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
145 } else { |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
146 if(id==c){ id=0;continue;} // idezojel |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
147 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
148 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
149 *d=c;d++; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
150 ec=c; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
151 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
152 if(d==sor2) continue; // skip empty lines |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
153 *d=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
154 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
155 // printf("params=%d sor=%s\n",pdb,sor); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
156 // for(i=0;i<pdb;i++) printf(" param %d = '%s'\n",i,p[i]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
157 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
158 if(pdb==1 && p[0][0]=='['){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
159 int len=strlen(p[0]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
160 if(len && len<63 && p[0][len-1]==']'){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
161 strcpy(section,p[0]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
162 mp_msg(MSGT_OSD, MSGL_DBG2, "font: Reading section: %s\n",section); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
163 if(strcmp(section,"[files]")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
164 ++fontdb; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
165 if(fontdb>=16){ mp_msg(MSGT_OSD, MSGL_ERR, "font: Too many bitmaps defined.\n");goto fail_out;} |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
166 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
167 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
168 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
169 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
170 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
171 if(strcmp(section,"[fpath]")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
172 if(pdb==1){ |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32467
diff
changeset
|
173 free (desc->fpath); // release previously allocated memory |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
174 desc->fpath=strdup(p[0]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
175 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
176 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
177 } else |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
178 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
179 #ifdef __AMIGAOS4__ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
180 #define FONT_PATH_SEP "" |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
181 #else |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
182 //! path seperator for font paths, may not be more than one character |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
183 #define FONT_PATH_SEP "/" |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
184 #endif |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
185 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
186 if(strcmp(section,"[files]")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
187 char *default_dir=MPLAYER_DATADIR FONT_PATH_SEP "font"; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
188 if(pdb==2 && strcmp(p[0],"alpha")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
189 char *cp; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
190 if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
191 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
192 snprintf(cp,strlen(desc->fpath)+strlen(p[1])+2,"%s" FONT_PATH_SEP "%s", |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
193 desc->fpath,p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
194 if(!((desc->pic_a[fontdb]=load_raw(cp,verbose)))){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
195 free(cp); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
196 if (!(cp=malloc(strlen(default_dir)+strlen(p[1])+2))) |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
197 goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
198 snprintf(cp,strlen(default_dir)+strlen(p[1])+2,"%s" FONT_PATH_SEP "%s", |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
199 default_dir,p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
200 if (!((desc->pic_a[fontdb]=load_raw(cp,verbose)))){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
201 mp_msg(MSGT_OSD, MSGL_ERR, "Can't load font bitmap: %s\n",p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
202 free(cp); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
203 goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
204 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
205 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
206 free(cp); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
207 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
208 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
209 if(pdb==2 && strcmp(p[0],"bitmap")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
210 char *cp; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
211 if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
212 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
213 snprintf(cp,strlen(desc->fpath)+strlen(p[1])+2,"%s" FONT_PATH_SEP "%s", |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
214 desc->fpath,p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
215 if(!((desc->pic_b[fontdb]=load_raw(cp,verbose)))){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
216 free(cp); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
217 if (!(cp=malloc(strlen(default_dir)+strlen(p[1])+2))) |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
218 goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
219 snprintf(cp,strlen(default_dir)+strlen(p[1])+2,"%s" FONT_PATH_SEP "%s", |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
220 default_dir,p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
221 if (!((desc->pic_b[fontdb]=load_raw(cp,verbose)))){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
222 mp_msg(MSGT_OSD, MSGL_ERR, "Can't load font bitmap: %s\n",p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
223 free(cp); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
224 goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
225 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
226 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
227 free(cp); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
228 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
229 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
230 } else |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
231 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
232 if(strcmp(section,"[info]")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
233 if(pdb==2 && strcmp(p[0],"name")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
234 desc->name=strdup(p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
235 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
236 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
237 if(pdb==2 && strcmp(p[0],"descversion")==0){ |
33342
a96fc06e1ea7
Remove unused version variable, replace it by comment
reimar
parents:
32511
diff
changeset
|
238 // This version field was never used. |
a96fc06e1ea7
Remove unused version variable, replace it by comment
reimar
parents:
32511
diff
changeset
|
239 // Since bitmap fonts are now deprecated there is |
a96fc06e1ea7
Remove unused version variable, replace it by comment
reimar
parents:
32511
diff
changeset
|
240 // no point in handling it. |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
241 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
242 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
243 if(pdb==2 && strcmp(p[0],"spacewidth")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
244 desc->spacewidth=atoi(p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
245 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
246 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
247 if(pdb==2 && strcmp(p[0],"charspace")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
248 desc->charspace=atoi(p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
249 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
250 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
251 if(pdb==2 && strcmp(p[0],"height")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
252 desc->height=atoi(p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
253 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
254 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
255 } else |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
256 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
257 if(strcmp(section,"[characters]")==0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
258 if(pdb==3){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
259 int chr=p[0][0]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
260 int start=atoi(p[1]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
261 int end=atoi(p[2]); |
36679
36cbede21428
Fix bug with unicode font loading for font.desc files.
ib
parents:
35252
diff
changeset
|
262 if(unicode && (chr>=0x80)) chr=(chr<<8)+p[0][1]; |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
263 else if(strlen(p[0])!=1) chr=strtol(p[0],NULL,0); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
264 if(end<start) { |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
265 mp_msg(MSGT_OSD, MSGL_WARN, "error in font desc: end<start for char '%c'\n",chr); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
266 } else { |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
267 desc->start[chr]=start; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
268 desc->width[chr]=end-start+1; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
269 desc->font[chr]=fontdb; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
270 // printf("char %d '%c' start=%d width=%d\n",chr,chr,desc->start[chr],desc->width[chr]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
271 ++chardb; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
272 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
273 continue; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
274 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
275 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
276 mp_msg(MSGT_OSD, MSGL_ERR, "Syntax error in font desc: %s",sor); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
277 goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
278 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
279 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
280 fclose(f); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
281 f = NULL; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
282 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
283 if (first == 1) { |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
284 mp_msg(MSGT_OSD, MSGL_ERR, "%s is empty or a directory, ignoring.\n", fname); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
285 goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
286 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
287 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
288 //printf("font: pos of U = %d\n",desc->start[218]); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
289 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
290 for(i=0;i<=fontdb;i++){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
291 if(!desc->pic_a[i] || !desc->pic_b[i]){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
292 mp_msg(MSGT_OSD, MSGL_ERR, "font: Missing bitmap(s) for sub-font #%d\n",i); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
293 goto fail_out; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
294 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
295 //if(factor!=1.0f) |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
296 { |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
297 // re-sample alpha |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
298 int f=factor*256.0f; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
299 int size=desc->pic_a[i]->w*desc->pic_a[i]->h; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
300 int j; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
301 mp_msg(MSGT_OSD, MSGL_DBG2, "font: resampling alpha by factor %5.3f (%d) ",factor,f);fflush(stdout); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
302 for(j=0;j<size;j++){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
303 int x=desc->pic_a[i]->bmp[j]; // alpha |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
304 int y=desc->pic_b[i]->bmp[j]; // bitmap |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
305 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
306 #ifdef FAST_OSD |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
307 x=(x<(255-f))?0:1; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
308 #else |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
309 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
310 x=255-((x*f)>>8); // scale |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
311 //if(x<0) x=0; else if(x>255) x=255; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
312 //x^=255; // invert |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
313 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
314 if(x+y>255) x=255-y; // to avoid overflows |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
315 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
316 //x=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
317 //x=((x*f*(255-y))>>16); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
318 //x=((x*f*(255-y))>>16)+y; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
319 //x=(x*f)>>8;if(x<y) x=y; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
320 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
321 if(x<1) x=1; else |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
322 if(x>=252) x=0; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
323 #endif |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
324 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
325 desc->pic_a[i]->bmp[j]=x; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
326 // desc->pic_b[i]->bmp[j]=0; // hack |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
327 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
328 mp_msg(MSGT_OSD, MSGL_DBG2, "DONE!\n"); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
329 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
330 if(!desc->height) desc->height=desc->pic_a[i]->h; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
331 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
332 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
333 j='_';if(desc->font[j]<0) j='?'; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
334 for(i=0;i<65536;i++) |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
335 if(desc->font[i]<0){ |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
336 desc->start[i]=desc->start[j]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
337 desc->width[i]=desc->width[j]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
338 desc->font[i]=desc->font[j]; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
339 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
340 desc->font[' ']=-1; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
341 desc->width[' ']=desc->spacewidth; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
342 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
343 mp_msg(MSGT_OSD, MSGL_V, "Bitmap font %s loaded successfully! (%d chars)\n",fname,chardb); |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
344 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
345 return desc; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
346 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
347 fail_out: |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
348 if (f) |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
349 fclose(f); |
35252 | 350 if (desc) { |
351 free(desc->fpath); | |
352 free(desc->name); | |
353 free(desc); | |
354 } | |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
355 return NULL; |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
356 } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
357 |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
358 #ifndef CONFIG_FREETYPE |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
359 void render_one_glyph(font_desc_t *desc, int c) {} |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
360 int kerning(font_desc_t *desc, int prevc, int c) { return 0; } |
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
diff
changeset
|
361 #endif |