Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

OSD: multiline text

  • Loading branch information...
commit 6c20769e5dd4046bb937284b28e7d28272aa73d5 1 parent 1c8d4a5
@sbourdeauducq sbourdeauducq authored
Showing with 22 additions and 13 deletions.
  1. +18 −8 src/font.c
  2. +2 −3 src/font.h
  3. +2 −2 src/osd.c
View
26 src/font.c
@@ -1,6 +1,6 @@
/*
* Flickernoise
- * Copyright (C) 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2010, 2011 Sebastien Bourdeauducq
* Copyright (C) 2002-2009 Norman Feske <norman.feske@genode-labs.com>
* Genode Labs, Feske & Helmuth Systementwicklung GbR
*
@@ -56,8 +56,8 @@ static void draw_pixel(struct font_context *ctx, int x, int y, int r, unsigned c
{
if(x < 0) return;
if(x >= ctx->fb_w) return;
- /*if(y < 0) return;
- if(y >= ctx->fb_h) return;*/
+ if(y < 0) return;
+ if(y >= ctx->fb_h) return;
if(r)
i = 255-i;
ctx->fb[x+y*ctx->fb_w] = MAKERGB565(i >> 3, i >> 2, i >> 3);
@@ -83,12 +83,22 @@ int font_draw_char(struct font_context *ctx, int x, int y, int r, unsigned char
return w;
}
-void font_draw_string(struct font_context *ctx, int x, int y, int r, const char *str, int maxlen)
+void font_draw_string(struct font_context *ctx, int x, int y, int r, const char *str)
{
- while((maxlen > 0) && (*str)) {
- x += font_draw_char(ctx, x, y, r, (unsigned char)(*str));
+ unsigned char c;
+ int xb;
+ struct tff_file_hdr *tff = (struct tff_file_hdr *)ctx->font;
+
+ xb = x;
+ while(*str) {
+ c = (unsigned char)(*str);
+ if((x+i2u32(&tff->wtab[c])) >= (ctx->fb_w-1)) {
+ x = xb;
+ y += i2u32(&tff->img_h);
+ if(y >= (ctx->fb_h-1))
+ break;
+ }
+ x += font_draw_char(ctx, x, y, r, c);
str++;
- maxlen--;
}
}
-
View
5 src/font.h
@@ -1,6 +1,6 @@
/*
* Flickernoise
- * Copyright (C) 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2010, 2011 Sebastien Bourdeauducq
* Copyright (C) 2002-2009 Norman Feske <norman.feske@genode-labs.com>
* Genode Labs, Feske & Helmuth Systementwicklung GbR
*
@@ -31,7 +31,6 @@ struct font_context {
void font_init_context(struct font_context *ctx, unsigned char *font, unsigned short *fb, int fb_w, int fb_h);
int font_get_height(struct font_context *ctx);
int font_draw_char(struct font_context *ctx, int x, int y, int r, unsigned char c);
-void font_draw_string(struct font_context *ctx, int x, int y, int r, const char *str , int maxlen);
+void font_draw_string(struct font_context *ctx, int x, int y, int r, const char *str);
#endif /* __FONT_H */
-
View
4 src/osd.c
@@ -25,7 +25,7 @@
#include "osd.h"
#define OSD_W 600
-#define OSD_H 52
+#define OSD_H 82
#define OSD_CORNER 15
#define OSD_CHROMAKEY 0x001f
@@ -86,7 +86,7 @@ static void clear_user_area()
void osd_event(const char *string)
{
clear_user_area();
- font_draw_string(&osd_font, OSD_CORNER, OSD_CORNER, 0, string, 64);
+ font_draw_string(&osd_font, OSD_CORNER, OSD_CORNER, 0, string);
osd_timer = OSD_DURATION;
}
Please sign in to comment.
Something went wrong with that request. Please try again.