Added anti-aliasing and printing in Unicode to wxX11.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17781 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-11-09 17:35:40 +00:00
parent f17fb6a086
commit d76fec130d
5 changed files with 68 additions and 37 deletions

View File

@@ -185,6 +185,13 @@ Unix (Base/GUI):
- don't include -I/usr/include nor -I/usr/local/include in wx-config output
- shared library symbols are now versioned on platforms that support it (Linux)
wxGTK:
- Further work for GTK 2.0 and Unicode support.
- Addition of native frame site grip.
wxX11:
- Unicode support through Pango library.
wxMSW:
- fixed crashes in wxListCtrl under XP

View File

@@ -204,7 +204,8 @@ static const char *wxPostScriptHeaderColourImage = "\
} ifelse %% end of 'false' case\n\
";
#ifndef __WXGTK20__
#if wxUSE_PANGO
#else
static char wxPostScriptHeaderReencodeISO1[] =
"\n/reencodeISO {\n"
"dup dup findfont dup length dict begin\n"
@@ -886,7 +887,8 @@ void wxPostScriptDC::SetFont( const wxFont& font )
m_font = font;
#ifndef __WXGTK20__
#if wxUSE_PANGO
#else
int Style = m_font.GetStyle();
int Weight = m_font.GetWeight();
@@ -1117,13 +1119,18 @@ void wxPostScriptDC::SetBrush( const wxBrush& brush )
}
}
#ifdef __WXGTK20__
#if wxUSE_PANGO
#define PANGO_ENABLE_ENGINE
#ifdef __WXGTK20__
#include "wx/gtk/private.h"
#include "wx/fontutil.h"
#include "gtk/gtk.h"
#else
#include "wx/x11/private.h"
#endif
#include "wx/fontutil.h"
#include <pango/pangoft2.h>
#include <freetype/ftglyph.h>
@@ -1233,7 +1240,7 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
{
wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
#ifdef __WXGTK20__
#if wxUSE_PANGO
int dpi = GetResolution();
dpi = 300;
PangoContext *context = pango_ft2_get_context ( dpi, dpi );
@@ -1754,7 +1761,8 @@ bool wxPostScriptDC::StartDoc( const wxString& message )
fprintf( m_pstream, wxPostScriptHeaderEllipse );
fprintf( m_pstream, wxPostScriptHeaderEllipticArc );
fprintf( m_pstream, wxPostScriptHeaderColourImage );
#ifndef __WXGTK20__
#if wxUSE_PANGO
#else
fprintf( m_pstream, wxPostScriptHeaderReencodeISO1 );
fprintf( m_pstream, wxPostScriptHeaderReencodeISO2 );
#endif
@@ -1972,7 +1980,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string,
return;
}
#ifdef __WXGTK20__
#if wxUSE_PANGO
int dpi = GetResolution();
PangoContext *context = pango_ft2_get_context ( dpi, dpi );

View File

@@ -1110,6 +1110,14 @@ bool wxApp::OnInitGui()
PangoContext* wxApp::GetPangoContext()
{
static PangoContext *ret = NULL;
if (ret)
return ret;
Display *xdisplay = (Display*) wxApp::GetDisplay();
#if 1
int xscreen = DefaultScreen(xdisplay);
static int use_xft = -1;
if (use_xft == -1)
{
@@ -1117,12 +1125,6 @@ PangoContext* wxApp::GetPangoContext()
use_xft = (val == L"1");
}
Display *xdisplay = (Display*) wxApp::GetDisplay();
int xscreen = DefaultScreen(xdisplay);
PangoContext *ret = NULL;
#if 0
if (use_xft)
ret = pango_xft_get_context( xdisplay, xscreen );
else

View File

@@ -1405,7 +1405,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
wxCoord height = h;
// Draw layout.
x11_draw_layout( (Drawable) m_window, (GC) m_textGC, x, y, layout );
x11_draw_layout( (Drawable) m_window, (GC) m_textGC, x, y, layout, m_textForegroundColour );
g_object_unref( G_OBJECT( layout ) );

View File

@@ -12,7 +12,8 @@ x11_draw_glyphs( Drawable drawable,
PangoFont *font,
int x,
int y,
PangoGlyphString *glyphs);
PangoGlyphString *glyphs,
wxColour &colour );
void
x11_draw_layout_line_with_colors( Drawable drawable,
@@ -20,8 +21,7 @@ x11_draw_layout_line_with_colors( Drawable drawable,
int x,
int y,
PangoLayoutLine *line,
XColor *foreground,
XColor *background);
wxColour &colour );
void
x11_draw_layout_with_colors( Drawable drawable,
@@ -29,15 +29,15 @@ x11_draw_layout_with_colors( Drawable drawable,
int x,
int y,
PangoLayout *layout,
XColor *foreground,
XColor *background);
wxColour &colour );
void
x11_draw_layout( Drawable drawable,
GC gc,
int x,
int y,
PangoLayout *layout);
PangoLayout *layout,
wxColour &colour);
void
x11_pango_get_item_properties( PangoItem *item,
@@ -55,16 +55,32 @@ x11_pango_get_item_properties( PangoItem *item,
/* Implementation */
void
x11_draw_glyphs( Drawable drawable,
GC gc,
PangoFont *font,
int x,
int y,
PangoGlyphString *glyphs)
x11_draw_glyphs( Drawable drawable,
GC gc,
PangoFont *font,
int x,
int y,
PangoGlyphString *glyphs,
wxColour &colour )
{
if (PANGO_XFT_IS_FONT (font))
{
pango_xft_picture_render( wxGlobalDisplay(), drawable, drawable, font, glyphs, x, y );
Display* xdisplay = wxGlobalDisplay();
int xscreen = DefaultScreen( xdisplay );
Visual* xvisual = DefaultVisual( xdisplay, xscreen );
Colormap xcolormap = DefaultColormapOfScreen( XScreenOfDisplay( xdisplay, xscreen ) );
XftDraw *draw = XftDrawCreate( xdisplay, drawable, xvisual, xcolormap );
XftColor color;
color.pixel = 0;
color.color.red = colour.Red() << 8;
color.color.green = colour.Green() << 8;
color.color.blue = colour.Blue() << 8;
color.color.alpha = 65000;
pango_xft_render( draw, &color, font, glyphs, x, y );
XftDrawDestroy( draw );
}
else
{
@@ -77,9 +93,8 @@ x11_draw_layout_line_with_colors( Drawable drawable,
GC gc,
int x,
int y,
PangoLayoutLine *line,
XColor *foreground,
XColor *background)
PangoLayoutLine *line,
wxColour &colour )
{
PangoRectangle overall_rect;
PangoRectangle logical_rect;
@@ -131,7 +146,7 @@ x11_draw_layout_line_with_colors( Drawable drawable,
int gx = x + x_off / PANGO_SCALE;
int gy = risen_y;
x11_draw_glyphs( drawable, gc, run->item->analysis.font, gx, gy, run->glyphs);
x11_draw_glyphs( drawable, gc, run->item->analysis.font, gx, gy, run->glyphs, colour );
}
if (uline == PANGO_UNDERLINE_SINGLE)
@@ -153,8 +168,7 @@ x11_draw_layout_with_colors( Drawable drawable,
int x,
int y,
PangoLayout *layout,
XColor *foreground,
XColor *background)
wxColour &colour )
{
PangoLayoutIter *iter = pango_layout_get_iter (layout);
@@ -171,8 +185,7 @@ x11_draw_layout_with_colors( Drawable drawable,
x + logical_rect.x / PANGO_SCALE,
y + baseline / PANGO_SCALE,
line,
foreground,
background);
colour );
} while (pango_layout_iter_next_line (iter));
@@ -184,11 +197,12 @@ x11_draw_layout( Drawable drawable,
GC gc,
int x,
int y,
PangoLayout *layout)
PangoLayout *layout,
wxColour &colour)
{
wxCHECK_RET( layout, wxT("No layout") );
x11_draw_layout_with_colors (drawable, gc, x, y, layout, NULL, NULL);
x11_draw_layout_with_colors (drawable, gc, x, y, layout, colour );
}
void