Changeset 20b81062cbc8c4fdd68441adf6996bfad80a9af2
- Timestamp:
- 19/04/03 14:39:14
(6 years ago)
- Author:
- Emmanuel Puig <karibu@videolan.org>
- git-committer:
- Emmanuel Puig <karibu@videolan.org> 1050755954 +0000
- git-parent:
[b06e5e49714c119f5067eea816f6d2ac66d07c39]
- git-author:
- Emmanuel Puig <karibu@videolan.org> 1050755954 +0000
- Message:
* Font fixed
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r5ee0310 |
r20b8106 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2003 VideoLAN |
|---|
| 5 | | * $Id: gtk2_font.cpp,v 1.10 2003/04/19 02:34:47 karibu Exp $ |
|---|
| | 5 | * $Id: gtk2_font.cpp,v 1.11 2003/04/19 12:39:14 karibu Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Cyril Deguet <asmax@videolan.org> |
|---|
| … | … | |
| 51 | 51 | |
|---|
| 52 | 52 | // Text properties setting |
|---|
| 53 | | FontDesc = pango_font_description_new(); |
|---|
| | 53 | FontDesc = pango_font_description_new(); |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | pango_font_description_set_family( FontDesc, fontname.c_str() ); |
|---|
| … | … | |
| 58 | 58 | |
|---|
| 59 | 59 | if( italic ) |
|---|
| | 60 | { |
|---|
| 60 | 61 | pango_font_description_set_style( FontDesc, PANGO_STYLE_ITALIC ); |
|---|
| | 62 | } |
|---|
| 61 | 63 | else |
|---|
| | 64 | { |
|---|
| 62 | 65 | pango_font_description_set_style( FontDesc, PANGO_STYLE_NORMAL ); |
|---|
| | 66 | } |
|---|
| 63 | 67 | |
|---|
| 64 | 68 | pango_font_description_set_weight( FontDesc, (PangoWeight)weight ); |
|---|
| … | … | |
| 67 | 71 | |
|---|
| 68 | 72 | // Set attributes |
|---|
| | 73 | //PangoFont* font = pango_context_load_font( Context, FontDesc ); |
|---|
| | 74 | |
|---|
| | 75 | //pango_context_set_font_description( Context, FontDesc ); |
|---|
| 69 | 76 | pango_layout_set_font_description( Layout, FontDesc ); |
|---|
| 70 | 77 | } |
|---|
| … | … | |
| 87 | 94 | int w, int h, int align, int color ) |
|---|
| 88 | 95 | { |
|---|
| 89 | | // Get handles |
|---|
| 90 | | GdkDrawable *drawable = ( (GTK2Graphics *)dest )->GetImage(); |
|---|
| 91 | | GdkGC *gc = ( (GTK2Graphics *)dest )->GetGC(); |
|---|
| 92 | | |
|---|
| 93 | 96 | // Set text |
|---|
| 94 | | pango_layout_set_text( Layout, text.c_str(), text.length() ); |
|---|
| | 97 | pango_layout_set_text( Layout, text.c_str(), -1 ); |
|---|
| 95 | 98 | |
|---|
| 96 | 99 | // Set size |
|---|
| | 100 | pango_layout_set_width( Layout, -1 ); |
|---|
| 97 | 101 | int real_w, real_h; |
|---|
| 98 | | GetSize( text, real_w, real_h ); |
|---|
| 99 | | if( real_w > w ) |
|---|
| 100 | | { |
|---|
| 101 | | // Change clipping region |
|---|
| 102 | | Region *TextClipRgn = (Region *)new OSRegion( x, y, w, h ); |
|---|
| 103 | | dest->SetClipRegion( TextClipRgn ); |
|---|
| 104 | | delete TextClipRgn; |
|---|
| 105 | 102 | |
|---|
| 106 | | w = real_w; |
|---|
| 107 | | if( align == VLC_FONT_ALIGN_RIGHT ) |
|---|
| 108 | | x += w - real_w; |
|---|
| 109 | | else if( align == VLC_FONT_ALIGN_CENTER ) |
|---|
| 110 | | x += ( w - real_w ) / 2; |
|---|
| | 103 | // Create buffer image |
|---|
| | 104 | Graphics* cov = (Graphics *)new OSGraphics( w, h ); |
|---|
| | 105 | cov->CopyFrom( 0, 0, w, h, dest, x, y, SRC_COPY ); |
|---|
| 111 | 106 | |
|---|
| 112 | | // Put old clip region |
|---|
| 113 | | dest->ResetClipRegion(); |
|---|
| 114 | | } |
|---|
| 115 | | else |
|---|
| 116 | | { |
|---|
| 117 | | pango_layout_set_width( Layout, w * PANGO_SCALE ); |
|---|
| 118 | | } |
|---|
| | 107 | // Get handles |
|---|
| | 108 | GdkDrawable *drawable = ( (GTK2Graphics *)cov )->GetImage(); |
|---|
| | 109 | GdkGC *gc = ( (GTK2Graphics *)cov )->GetGC(); |
|---|
| | 110 | |
|---|
| | 111 | // Set width of text |
|---|
| | 112 | pango_layout_set_width( Layout, w * PANGO_SCALE ); |
|---|
| 119 | 113 | |
|---|
| 120 | 114 | // Set attributes |
|---|
| … | … | |
| 122 | 116 | gdk_rgb_gc_set_foreground( gc, color ); |
|---|
| 123 | 117 | |
|---|
| 124 | | // Render text |
|---|
| 125 | | gdk_draw_layout( drawable, gc, x, y, Layout ); |
|---|
| | 118 | // Render text on buffer |
|---|
| | 119 | gdk_draw_layout( drawable, gc, 0, 0, Layout ); |
|---|
| | 120 | |
|---|
| | 121 | // Copy buffer on dest graphics |
|---|
| | 122 | dest->CopyFrom( x, y, w, h, cov, 0, 0, SRC_COPY ); |
|---|
| | 123 | |
|---|
| | 124 | // Free memory |
|---|
| | 125 | delete (OSGraphics *)cov; |
|---|
| 126 | 126 | } |
|---|
| 127 | 127 | |
|---|
| r5ee0310 |
r20b8106 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2003 VideoLAN |
|---|
| 5 | | * $Id: gtk2_graphics.cpp,v 1.13 2003/04/19 02:34:47 karibu Exp $ |
|---|
| | 5 | * $Id: gtk2_graphics.cpp,v 1.14 2003/04/19 12:39:14 karibu Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Cyril Deguet <asmax@videolan.org> |
|---|
| … | … | |
| 51 | 51 | else |
|---|
| 52 | 52 | { |
|---|
| 53 | | Image = (GdkDrawable*) gdk_pixmap_new( NULL, w, h, 8 ); |
|---|
| | 53 | // FIXME: 8 -> screen depth |
|---|
| | 54 | Image = (GdkDrawable*) gdk_pixmap_new( NULL, w, h, 16 ); |
|---|
| 54 | 55 | gdk_drawable_set_colormap( Image, gdk_colormap_get_system() ); |
|---|
| 55 | 56 | Gc = gdk_gc_new( Image ); |
|---|
| … | … | |
| 75 | 76 | void GTK2Graphics::DrawRect( int x, int y, int w, int h, int color ) |
|---|
| 76 | 77 | { |
|---|
| | 78 | gdk_rgb_gc_set_foreground( Gc, color ); |
|---|
| 77 | 79 | gdk_draw_rectangle( Image, Gc, TRUE, x, y, w, h); |
|---|
| 78 | 80 | } |
|---|