Commit f3545179 authored by Emmanuel Puig's avatar Emmanuel Puig

* Improved font support for linux (just missing underline parameter )

parent 34964ed5
......@@ -2,7 +2,7 @@
* 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>
*
......@@ -32,9 +32,9 @@
//--- 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"
......@@ -47,45 +47,33 @@ GTK2Font::GTK2Font( intf_thread_t *_p_intf, string fontname, int size,
{
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 )
......@@ -97,34 +85,19 @@ 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 );
}
......
......@@ -2,7 +2,7 @@
* gtk2_font.h: GTK2 implementation of the Font class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2_font.h,v 1.4 2003/04/17 13:46:55 karibu Exp $
* $Id: gtk2_font.h,v 1.5 2003/04/17 15:43:29 karibu Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -41,8 +41,10 @@ class Graphics;
class GTK2Font : Font
{
private:
PangoContext *Context;
PangoLayout *Layout;
PangoContext *Context;
PangoLayout *Layout;
PangoFontDescription *FontDesc;
// Assign font to Device Context
virtual void AssignFont( Graphics *dest );
......
......@@ -2,7 +2,7 @@
* os_font.h: Wrapper for the OSFont class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_font.h,v 1.3 2003/04/16 21:40:07 ipkiss Exp $
* $Id: os_font.h,v 1.4 2003/04/17 15:43:29 karibu Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -27,7 +27,17 @@
#if defined( WIN32 )
#include "win32/win32_font.h"
#define OSFont Win32Font
#else
#define VLC_FONT_ALIGN_LEFT DT_LEFT
#define VLC_FONT_ALIGN_CENTER DT_CENTER
#define VLC_FONT_ALIGN_RIGHT DT_RIGHT
#else
#include "gtk2/gtk2_font.h"
#define OSFont GTK2Font
#define VLC_FONT_ALIGN_LEFT PANGO_ALIGN_LEFT
#define VLC_FONT_ALIGN_CENTER PANGO_ALIGN_CENTER
#define VLC_FONT_ALIGN_RIGHT PANGO_ALIGN_RIGHT
#endif
......@@ -2,7 +2,7 @@
* 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 Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -38,6 +38,7 @@ extern intf_thread_t *g_pIntf;
#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"
......@@ -385,12 +386,12 @@ static void ConvertCoords( char *coord, double *p_coord )
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;
}
//---------------------------------------------------------------------------
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment