[vlc-devel] commit: win32text: add multiline support (Pierre Ynard )

git version control git at videolan.org
Sat Sep 19 00:50:42 CEST 2009


vlc | branch: 1.0-bugfix | Pierre Ynard <linkfanel at yahoo.fr> | Thu Sep 17 19:19:42 2009 +0200| [cee2651eb84c0c01234042fced69f4ce6b46b604] | committer: Pierre Ynard 

win32text: add multiline support
(cherry picked from commit 6f18addb6b651047b4464dc314af5b92f5adc4b4)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cee2651eb84c0c01234042fced69f4ce6b46b604
---

 modules/misc/win32text.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/modules/misc/win32text.c b/modules/misc/win32text.c
index 93ca344..bfb9fff 100644
--- a/modules/misc/win32text.c
+++ b/modules/misc/win32text.c
@@ -1,10 +1,11 @@
 /*****************************************************************************
  * win32text.c : Text drawing routines using the TextOut win32 API
  *****************************************************************************
- * Copyright (C) 2002 - 2005 the VideoLAN team
+ * Copyright (C) 2002 - 2009 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin at videolan.org>
+ *          Pierre Ynard
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -302,8 +303,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
     int i, i_width, i_height;
     HBITMAP bitmap, bitmap_bak;
     BITMAPINFO *p_bmi;
-    RECT rect = {0};
-    SIZE size;
+    RECT rect = { 0, 0, 0, 0 };
 
     /* Sanity check */
     if( !p_region_in || !p_region_out ) return VLC_EGENERIC;
@@ -344,8 +344,9 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
     SetTextColor( p_sys->hcdc, RGB( (i_font_color >> 16) & 0xff,
                   (i_font_color >> 8) & 0xff, i_font_color & 0xff) );
 
-    GetTextExtentPoint( p_sys->hcdc, psz_string, _tcslen(psz_string), &size );
-    i_width = rect.right = size.cx; i_height = rect.bottom = size.cy;
+    DrawText( p_sys->hcdc, psz_string, -1, &rect,
+              DT_CALCRECT | DT_CENTER | DT_NOPREFIX );
+    i_width = rect.right; i_height = rect.bottom;
 
     p_bmi = malloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*16);
     memset( p_bmi, 0, sizeof(BITMAPINFOHEADER) );
@@ -376,8 +377,8 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
     bitmap_bak = SelectObject( p_sys->hcdc, bitmap );
     FillRect( p_sys->hcdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );
 
-    //TextOut( p_sys->hcdc, 0, 0, psz_string, strlen(psz_string) );
-    if( !DrawText( p_sys->hcdc, psz_string, -1, &rect, 0 ) )
+    if( !DrawText( p_sys->hcdc, psz_string, -1, &rect,
+                   DT_CENTER | DT_NOPREFIX ) )
     {
         msg_Err( p_filter, "could not draw text" );
     }




More information about the vlc-devel mailing list