[Mplayer-cvslog] CVS: main/libmenu Makefile,1.1,1.2 menu.c,1.1,1.2 vf_menu.c,1.1,1.2
Alban Bedel CVS
albeu at mplayerhq.hu
Mon Nov 18 01:09:56 CET 2002
Update of /cvsroot/mplayer/main/libmenu
In directory mail:/var/tmp.root/cvs-serv22407/libmenu
Modified Files:
Makefile menu.c vf_menu.c
Log Message:
Fix freetype. Freetype is highly recommended for a nice output ;)
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile 14 Nov 2002 23:47:11 -0000 1.1
+++ Makefile 18 Nov 2002 00:09:37 -0000 1.2
@@ -12,7 +12,7 @@
.c.o:
- $(CC) -c $(CFLAGS) -o $@ $<
+ $(CC) -c $(CFLAGS) $(FREETYPE_INC) -o $@ $<
$(LIBNAME): $(OBJS)
$(AR) r $(LIBNAME) $(OBJS)
Index: menu.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- menu.c 14 Nov 2002 23:47:11 -0000 1.1
+++ menu.c 18 Nov 2002 00:09:37 -0000 1.2
@@ -262,6 +262,20 @@
return NULL;
}
+// return the real height of a char:
+static inline int get_height(int c,int h){
+ int font;
+ if ((font=vo_font->font[c])>=0)
+ if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h;
+ return h;
+}
+
+#ifdef HAVE_FREETYPE
+#define render_txt(t) { char* p = t; while(*p) render_one_glyph(vo_font,*p++); }
+#else
+#define render_txt(t)
+#endif
+
void menu_draw_text(mp_image_t* mpi,char* txt, int x, int y) {
draw_alpha_f draw_alpha = get_draw_alpha(mpi->imgfmt);
@@ -272,6 +286,8 @@
return;
}
+ render_txt(txt);
+
while (*txt) {
unsigned char c=*txt++;
if ((font=vo_font->font[c])>=0 && (x + vo_font->width[c] <= mpi->w) && (y + vo_font->pic_a[font]->h <= mpi->h))
@@ -301,6 +317,8 @@
return;
}
+ render_txt(txt);
+
if(x > mpi->w || y > mpi->h)
return;
@@ -456,6 +474,7 @@
int menu_text_length(char* txt) {
int l = 0;
+ render_txt(txt);
while (*txt) {
unsigned char c=*txt++;
l += vo_font->width[c]+vo_font->charspace;
@@ -466,7 +485,8 @@
void menu_text_size(char* txt,int max_width, int vspace, int warp, int* _w, int* _h) {
int l = 1, i = 0;
int w = 0;
-
+
+ render_txt(txt);
while (*txt) {
unsigned char c=*txt++;
if(c == '\n' || (warp && i + vo_font->width[c] >= max_width)) {
@@ -486,6 +506,7 @@
int menu_text_num_lines(char* txt, int max_width) {
int l = 1, i = 0;
+ render_txt(txt);
while (*txt) {
unsigned char c=*txt++;
if(c == '\n' || i + vo_font->width[c] > max_width) {
@@ -500,6 +521,7 @@
char* menu_text_get_next_line(char* txt, int max_width) {
int i = 0;
+ render_txt(txt);
while (*txt) {
unsigned char c=*txt;
if(c == '\n') {
Index: vf_menu.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/vf_menu.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- vf_menu.c 14 Nov 2002 23:47:11 -0000 1.1
+++ vf_menu.c 18 Nov 2002 00:09:37 -0000 1.2
@@ -14,6 +14,7 @@
#include "../libvo/fastmemcpy.h"
#include "../libvo/video_out.h"
+#include "../libvo/font_load.h"
#include "../input/input.h"
#include "../m_struct.h"
#include "menu.h"
@@ -217,6 +218,17 @@
}
}
+static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height,
+ unsigned int flags, unsigned int outfmt) {
+#ifdef HAVE_FREETYPE
+ // here is the right place to get screen dimensions
+ if (force_load_font) {
+ force_load_font = 0;
+ load_font(width,height);
+ }
+#endif
+ return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
+}
static int open(vf_instance_t *vf, char* args){
if(!st_priv) {
st_priv = calloc(1,sizeof(struct vf_priv_s));
@@ -229,6 +241,7 @@
mp_input_add_cmd_filter((mp_input_cmd_filter)cmd_filter,st_priv);
}
+ vf->config = config;
vf->put_image = put_image;
vf->get_image = get_image;
vf->uninit=uninit;
More information about the MPlayer-cvslog
mailing list