* gtk2_font.cpp: GTK2 implementation of the Font class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: gtk2_font.cpp,v 1.7 2003/04/17 13:46:55 karibu Exp $
+ * $Id: gtk2_font.cpp,v 1.8 2003/04/17 15:43:29 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
//--- SKIN ------------------------------------------------------------------
#include "../src/graphics.h"
-#include "gtk2_graphics.h"
+#include "../os_graphics.h"
#include "../src/font.h"
-#include "gtk2_font.h"
+#include "../os_font.h"
{
Context = gdk_pango_context_get();
Layout = pango_layout_new( Context );
+
+ // Text properties setting
+ FontDesc = pango_font_description_new();
+
+ pango_font_description_set_family( FontDesc, fontname.c_str() );
+
+ pango_font_description_set_size( FontDesc, size * PANGO_SCALE );
+
+ if( italic )
+ pango_font_description_set_style( FontDesc, PANGO_STYLE_ITALIC );
+ else
+ pango_font_description_set_style( FontDesc, PANGO_STYLE_NORMAL );
+
+ pango_font_description_set_weight( FontDesc, (PangoWeight)weight );
+
+ /* FIXME: underline parameter */
+
+ // Set attributes
+ pango_layout_set_font_description( Layout, FontDesc );
}
//---------------------------------------------------------------------------
GTK2Font::~GTK2Font()
{
}
//---------------------------------------------------------------------------
-/*void GTK2Font::AssignGTK2Font( GdkDrawable *DC )
-{
- // Create font
- HGDIOBJ fontObj = CreateFont(
- -MulDiv( Size, GetDeviceCaps( DC, LOGPIXELSX ), 72 ),
- 0,
- 0, // angle of escapement
- 0, // base-line orientation angle
- Weight, // font weight
- Italic, // italic attribute flag
- Underline, // underline attribute flag
- 0, // strikeout attribute flag
- ANSI_CHARSET, // character set identifier
- OUT_TT_PRECIS, // output precision
- 0, // clipping precision
- ANTIALIASED_QUALITY, // output quality
- 0, // pitch and family
- FontName.c_str() // pointer to typeface name string
- );
-
- // Assign font to DC
- SelectObject( DC, fontObj );
-
- // Free memory
- DeleteObject( fontObj );
-// GdkGC *gc = gdk_gc_new( DC );
-// gdk_gc_set_font( GFont, gc );
-}*/
-//---------------------------------------------------------------------------
void GTK2Font::AssignFont( Graphics *dest )
{
-/* GdkDrawable *DC = ( (GTK2Graphics *)dest )->GetImageHandle();
- AssignGTK2Font( DC );*/
}
//---------------------------------------------------------------------------
void GTK2Font::GetSize( string text, int &w, int &h )
void GTK2Font::GenericPrint( Graphics *dest, string text, int x, int y,
int w, int h, int align, int color )
{
+ // Get handles
GdkDrawable *drawable = ( (GTK2Graphics *)dest )->GetImage();
GdkGC *gc = ( (GTK2Graphics *)dest )->GetGC();
-/* HDC DC = ( (GTK2Graphics *)dest )->GetImageHandle();
- // Set boundaries
- LPRECT r = new RECT;
- r->left = x;
- r->top = y;
- r->right = x + w;
- r->bottom = y + h;
-
- // Get desktop Device Context
- SetBkMode( DC, TRANSPARENT );
-
- // Modify desktop attributes
- AssignFont( dest );
- // Change text color
- SetTextColor( DC, color );
-
- // Draw text on screen
- DrawText( DC, text.c_str(), text.length(), r, align );
+ // Set text
+ pango_layout_set_text( Layout, text.c_str(), text.length() );
+ pango_layout_set_width( Layout, w * PANGO_SCALE );
- // Set text color to black to avoid graphic bugs
- SetTextColor( DC, 0 );
+ // Set attributes
+ pango_layout_set_alignment( Layout, (PangoAlignment)align );
+ gdk_rgb_gc_set_foreground( gc, color );
- // Free memory
- delete r;*/
- pango_layout_set_text( Layout, text.c_str(), text.length() );
+ // Render text
gdk_draw_layout( drawable, gc, x, y, Layout );
}
* wrappers.cpp: Wrappers around C++ objects
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: wrappers.cpp,v 1.7 2003/04/16 21:40:07 ipkiss Exp $
+ * $Id: wrappers.cpp,v 1.8 2003/04/17 15:43:30 karibu Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
#include "../src/banks.h"
#include "../controls/controls.h"
#include "../src/font.h"
+#include "../os_font.h"
#include "../src/window.h"
#include "../src/theme.h"
#include "../src/skin_common.h"
static int ConvertAlign( char *align )
{
if( strcmp( align, "left" ) == 0 )
- return DT_LEFT;
+ return VLC_FONT_ALIGN_LEFT;
else if( strcmp( align, "right" ) == 0 )
- return DT_RIGHT;
+ return VLC_FONT_ALIGN_RIGHT;
else if( strcmp( align, "center" ) == 0 )
- return DT_CENTER;
+ return VLC_FONT_ALIGN_CENTER;
else
- return DT_LEFT;
+ return VLC_FONT_ALIGN_LEFT;
}
//---------------------------------------------------------------------------