aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmenu
diff options
context:
space:
mode:
Diffstat (limited to 'libmenu')
-rw-r--r--libmenu/Makefile2
-rw-r--r--libmenu/menu.c24
-rw-r--r--libmenu/vf_menu.c13
3 files changed, 37 insertions, 2 deletions
diff --git a/libmenu/Makefile b/libmenu/Makefile
index 7886c13679..4e9c37b206 100644
--- a/libmenu/Makefile
+++ b/libmenu/Makefile
@@ -12,7 +12,7 @@ CFLAGS = $(OPTFLAGS) -I. -I.. -I../libmpcodecs $(EXTRA_INC) -Wall
.c.o:
- $(CC) -c $(CFLAGS) -o $@ $<
+ $(CC) -c $(CFLAGS) $(FREETYPE_INC) -o $@ $<
$(LIBNAME): $(OBJS)
$(AR) r $(LIBNAME) $(OBJS)
diff --git a/libmenu/menu.c b/libmenu/menu.c
index 89842f5c6e..f7eadcf38a 100644
--- a/libmenu/menu.c
+++ b/libmenu/menu.c
@@ -262,6 +262,20 @@ inline static draw_alpha_f get_draw_alpha(uint32_t fmt) {
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 @@ void menu_draw_text(mp_image_t* mpi,char* txt, int x, int y) {
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 @@ void menu_draw_text_full(mp_image_t* mpi,char* txt,
return;
}
+ render_txt(txt);
+
if(x > mpi->w || y > mpi->h)
return;
@@ -456,6 +474,7 @@ void menu_draw_text_full(mp_image_t* mpi,char* txt,
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 @@ int menu_text_length(char* txt) {
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 @@ void menu_text_size(char* txt,int max_width, int vspace, int warp, int* _w, int*
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 @@ int menu_text_num_lines(char* txt, int max_width) {
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') {
diff --git a/libmenu/vf_menu.c b/libmenu/vf_menu.c
index 5d84b55191..ecfc0f19c8 100644
--- a/libmenu/vf_menu.c
+++ b/libmenu/vf_menu.c
@@ -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 void uninit(vf_instance_t *vf) {
}
}
+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 @@ static int open(vf_instance_t *vf, char* args){
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;