1 /*****************************************************************************
2 * x11_font.cpp: X11 implementation of the Font class
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: x11_font.cpp,v 1.3 2003/05/19 21:39:34 asmax Exp $
7 * Authors: Cyril Deguet <asmax@videolan.org>
8 * Emmanuel Puig <karibu@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
24 *****************************************************************************/
28 //--- X11 -----------------------------------------------------------------
31 //--- VLC -------------------------------------------------------------------
34 //--- SKIN ------------------------------------------------------------------
35 #include "../src/graphics.h"
36 #include "../os_graphics.h"
37 #include "../src/font.h"
38 #include "../os_font.h"
42 //---------------------------------------------------------------------------
44 //---------------------------------------------------------------------------
45 X11Font::X11Font( intf_thread_t *_p_intf, string fontname, int size,
46 int color, int weight, bool italic, bool underline )
47 : SkinFont( _p_intf, fontname, size, color, weight, italic, underline )
49 /* Context = gdk_pango_context_get();
50 Layout = pango_layout_new( Context );
52 // Text properties setting
53 FontDesc = pango_font_description_new();
55 pango_font_description_set_family( FontDesc, fontname.c_str() );
57 pango_font_description_set_size( FontDesc, size * PANGO_SCALE );
61 pango_font_description_set_style( FontDesc, PANGO_STYLE_ITALIC );
65 pango_font_description_set_style( FontDesc, PANGO_STYLE_NORMAL );
68 pango_font_description_set_weight( FontDesc, (PangoWeight)weight );
70 //pango_context_set_font_description( Context, FontDesc );
71 pango_layout_set_font_description( Layout, FontDesc );
74 PangoAttrList *attrs = pango_attr_list_new();
75 // FIXME: doesn't work
78 pango_attr_list_insert( attrs,
79 pango_attr_underline_new( PANGO_UNDERLINE_SINGLE ) );
81 pango_layout_set_attributes( Layout, attrs );*/
83 //---------------------------------------------------------------------------
87 //---------------------------------------------------------------------------
88 void X11Font::AssignFont( Graphics *dest )
91 //---------------------------------------------------------------------------
92 void X11Font::GetSize( string text, int &w, int &h )
96 /* pango_layout_set_text( Layout, text.c_str(), text.length() );
97 pango_layout_get_pixel_size( Layout, &w, &h );*/
99 //---------------------------------------------------------------------------
100 void X11Font::GenericPrint( Graphics *dest, string text, int x, int y,
101 int w, int h, int align, int color )
104 pango_layout_set_text( Layout, text.c_str(), -1 );
107 pango_layout_set_width( Layout, -1 );
110 // Create buffer image
111 Graphics* cov = (Graphics *)new OSGraphics( w, h );
112 cov->CopyFrom( 0, 0, w, h, dest, x, y, SRC_COPY );
115 GdkDrawable *drawable = ( (X11Graphics *)cov )->GetImage();
116 GdkGC *gc = ( (X11Graphics *)cov )->GetGC();
119 pango_layout_set_width( Layout, w * PANGO_SCALE );
122 pango_layout_set_alignment( Layout, (PangoAlignment)align );
124 // Avoid transârency for black text
125 if( color == 0 ) color = 10;
126 gdk_rgb_gc_set_foreground( gc, color );
128 // Render text on buffer
129 gdk_draw_layout( drawable, gc, 0, 0, Layout );
131 // Copy buffer on dest graphics
132 dest->CopyFrom( x, y, w, h, cov, 0, 0, SRC_COPY );
135 delete (OSGraphics *)cov;*/
138 //---------------------------------------------------------------------------
139 void X11Font::Print( Graphics *dest, string text, int x, int y, int w,
142 GenericPrint( dest, text, x, y, w, h, align, Color );
144 //---------------------------------------------------------------------------
145 void X11Font::PrintColor( Graphics *dest, string text, int x, int y, int w,
146 int h, int align, int color )
148 GenericPrint( dest, text, x, y, w, h, align, color );
150 //---------------------------------------------------------------------------