changeset 8224:fefc56153615

Fix freetype. Freetype is highly recommended for a nice output ;)
author albeu
date Mon, 18 Nov 2002 00:09:37 +0000
parents a88e53ef3029
children c032962b51a1
files libmenu/Makefile libmenu/menu.c libmenu/vf_menu.c
diffstat 3 files changed, 37 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmenu/Makefile	Sun Nov 17 17:41:19 2002 +0000
+++ b/libmenu/Makefile	Mon Nov 18 00:09:37 2002 +0000
@@ -12,7 +12,7 @@
 
 
 .c.o:
-	$(CC) -c $(CFLAGS) -o $@ $<
+	$(CC) -c $(CFLAGS) $(FREETYPE_INC) -o $@ $<
 
 $(LIBNAME):     $(OBJS)
 	$(AR) r $(LIBNAME) $(OBJS)
--- a/libmenu/menu.c	Sun Nov 17 17:41:19 2002 +0000
+++ b/libmenu/menu.c	Mon Nov 18 00:09:37 2002 +0000
@@ -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') {
--- a/libmenu/vf_menu.c	Sun Nov 17 17:41:19 2002 +0000
+++ b/libmenu/vf_menu.c	Mon Nov 18 00:09:37 2002 +0000
@@ -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;