]> git.sesse.net Git - vlc/commitdiff
win32text: add multiline support
authorPierre Ynard <linkfanel@yahoo.fr>
Thu, 17 Sep 2009 17:19:42 +0000 (19:19 +0200)
committerPierre Ynard <linkfanel@yahoo.fr>
Thu, 17 Sep 2009 17:19:42 +0000 (19:19 +0200)
modules/misc/win32text.c

index c172d8809950e6f6b964d24fe7ddeccd7eb3cbbd..89fc5f8db33eda056253c895fa9f3578fe4c2619 100644 (file)
@@ -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@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" );
     }