Replace duplicated code by a macro.
[mplayer/glamo.git] / libvo / font_load.h
blob5371b54cbf1a1e337efca6232a936297f8ac1b1c
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_FONT_LOAD_H
20 #define MPLAYER_FONT_LOAD_H
22 #ifdef CONFIG_FREETYPE
23 #include <ft2build.h>
24 #include FT_FREETYPE_H
25 #endif
27 typedef struct {
28 unsigned char *bmp;
29 unsigned char *pal;
30 int w,h,c;
31 #ifdef CONFIG_FREETYPE
32 int charwidth,charheight,pen,baseline,padding;
33 int current_count, current_alloc;
34 #endif
35 } raw_file;
37 typedef struct font_desc {
38 #ifdef CONFIG_FREETYPE
39 int dynamic;
40 #endif
41 char *name;
42 char *fpath;
43 int spacewidth;
44 int charspace;
45 int height;
46 // char *fname_a;
47 // char *fname_b;
48 raw_file* pic_a[16];
49 raw_file* pic_b[16];
50 short font[65536];
51 int start[65536]; // short is not enough for unicode fonts
52 short width[65536];
53 int freetype;
55 #ifdef CONFIG_FREETYPE
56 int face_cnt;
58 FT_Face faces[16];
59 FT_UInt glyph_index[65536];
61 int max_width, max_height;
63 struct
65 int g_r;
66 int o_r;
67 int g_w;
68 int o_w;
69 int o_size;
70 unsigned volume;
72 unsigned *g;
73 unsigned *gt2;
74 unsigned *om;
75 unsigned char *omt;
76 unsigned short *tmp;
77 } tables;
78 #endif
80 } font_desc_t;
82 extern font_desc_t* vo_font;
83 extern font_desc_t* sub_font;
85 extern char *subtitle_font_encoding;
86 extern float text_font_scale_factor;
87 extern float osd_font_scale_factor;
88 extern float subtitle_font_radius;
89 extern float subtitle_font_thickness;
90 extern int subtitle_autoscale;
92 extern int vo_image_width;
93 extern int vo_image_height;
95 extern int force_load_font;
97 int init_freetype(void);
98 int done_freetype(void);
100 font_desc_t* read_font_desc_ft(const char* fname,int face_index,int movie_width, int movie_height, float font_scale_factor);
101 void free_font_desc(font_desc_t *desc);
103 void render_one_glyph(font_desc_t *desc, int c);
104 int kerning(font_desc_t *desc, int prevc, int c);
106 void load_font_ft(int width, int height, font_desc_t **desc, const char *name, float font_scale_factor);
108 void blur(unsigned char *buffer, unsigned short *tmp2, int width, int height,
109 int stride, int *m2, int r, int mwidth);
111 raw_file* load_raw(char *name,int verbose);
112 font_desc_t* read_font_desc(const char* fname,float factor,int verbose);
114 #endif /* MPLAYER_FONT_LOAD_H */