From: Robert Roebling Date: Thu, 14 Sep 2000 13:02:34 +0000 (+0000) Subject: Readded TrueType text. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/96f5fca9e4fbdea293199ddca960dabb127e270b Readded TrueType text. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8360 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/contrib/include/wx/canvas/canvas.h b/contrib/include/wx/canvas/canvas.h index 4c055e89e5..f1255760b3 100644 --- a/contrib/include/wx/canvas/canvas.h +++ b/contrib/include/wx/canvas/canvas.h @@ -114,10 +114,10 @@ public: void ExtendArea(double x, double y); - inline int GetXMin() { return m_minx; } - inline int GetYMin() { return m_miny; } - inline int GetXMax() { return m_maxx; } - inline int GetYMax() { return m_maxy; } + inline double GetXMin() { return m_minx; } + inline double GetYMin() { return m_miny; } + inline double GetXMax() { return m_maxx; } + inline double GetYMax() { return m_maxy; } protected: wxCanvas *m_owner; @@ -151,8 +151,8 @@ public: virtual bool IsHit( int x, int y, int margin ); void Move( int x, int y ); - inline int GetPosX() { return m_x; } - inline int GetPosY() { return m_y; } + inline double GetPosX() { return m_x; } + inline double GetPosY() { return m_y; } void ExtendArea(double x, double y); virtual wxCanvasObject* IsHitObject( int x, int y, int margin ); diff --git a/contrib/samples/canvas/test/test.cpp b/contrib/samples/canvas/test/test.cpp index 255d8e2e2a..d9e9199a98 100644 --- a/contrib/samples/canvas/test/test.cpp +++ b/contrib/samples/canvas/test/test.cpp @@ -229,8 +229,14 @@ MyFrame::MyFrame() wxButton *button = new wxButton( m_canvas, -1, "Hello", wxPoint(80,50) ); m_canvas->Append( new wxCanvasControl( button ) ); - m_canvas->Append( new wxCanvasText( "Hello", 180, 50, - wxGetApp().GetFontPath() + "/times.ttf", 20 ) ); + m_canvas->Append( new wxCanvasText( "How are you?", 180, 10, + wxGetApp().GetFontPath() + "/times.ttf", 8 ) ); + + m_canvas->Append( new wxCanvasText( "How are you?", 180, 20, + wxGetApp().GetFontPath() + "/times.ttf", 10 ) ); + + m_canvas->Append( new wxCanvasText( "How are you?", 180, 30, + wxGetApp().GetFontPath() + "/times.ttf", 12 ) ); m_sm3 = new wxCanvasImage( image, 0,210,32,32 ); m_canvas->Append( m_sm3 ); diff --git a/contrib/src/canvas/canvas.cpp b/contrib/src/canvas/canvas.cpp index 67935663df..1be997526a 100644 --- a/contrib/src/canvas/canvas.cpp +++ b/contrib/src/canvas/canvas.cpp @@ -368,8 +368,8 @@ void wxCanvasObjectGroupRef::Recreate() void wxCanvasObjectGroupRef::Render(int xabs, int yabs, int x, int y, int width, int height ) { - xabs += m_owner->GetDeviceX(m_x); - yabs += m_owner->GetDeviceY(m_y); + xabs += m_area.x; + yabs += m_area.y; int clip_x = xabs + m_group->GetXMin(); int clip_width = m_group->GetXMax()-m_group->GetXMin(); @@ -1011,10 +1011,11 @@ void wxCanvasText::Render(int xabs, int yabs, int clip_x, int clip_y, int clip_w { if (!m_alpha) return; -#if IMAGE_CANVAS - wxImage *image = m_owner->GetBuffer(); int buffer_x = m_owner->GetBufferX(); int buffer_y = m_owner->GetBufferY(); + +#if IMAGE_CANVAS + wxImage *image = m_owner->GetBuffer(); // local coordinates int start_x = clip_x - m_area.x; @@ -1050,6 +1051,52 @@ void wxCanvasText::Render(int xabs, int yabs, int clip_x, int clip_y, int clip_w image->SetRGB( image_x, image_y, red1+red2, green1+green2, blue1+blue2 ); } } +#else + wxBitmap *bitmap = m_owner->GetBuffer(); + wxRect sub_rect( clip_x-buffer_x, clip_y-buffer_y, clip_width, clip_height ); + wxBitmap sub_bitmap( bitmap->GetSubBitmap( sub_rect ) ); + + wxImage image( sub_bitmap ); + + // local coordinates + int start_x = clip_x - m_area.x; + int end_x = clip_width + start_x; + int start_y = clip_y - m_area.y; + int end_y = clip_height + start_y; + + for (int y = start_y; y < end_y; y++) + for (int x = start_x; x < end_x; x++) + { + int alpha = m_alpha[y*m_area.width + x]; + if (alpha) + { + int image_x = x - start_x; + int image_y = y - start_y; + if (alpha == 255) + { + image.SetRGB( image_x, image_y, m_red, m_green, m_blue ); + continue; + } + int red1 = (m_red * alpha) / 255; + int green1 = (m_green * alpha) / 255; + int blue1 = (m_blue * alpha) / 255; + + alpha = 255-alpha; + int red2 = image.GetRed( image_x, image_y ); + int green2 = image.GetGreen( image_x, image_y ); + int blue2 = image.GetBlue( image_x, image_y ); + red2 = (red2 * alpha) / 255; + green2 = (green2 * alpha) / 255; + blue2 = (blue2 * alpha) / 255; + + image.SetRGB( image_x, image_y, red1+red2, green1+green2, blue1+blue2 ); + } + } + + sub_bitmap = image.ConvertToBitmap(); + + wxMemoryDC *dc = m_owner->GetDC(); + dc->DrawBitmap( sub_bitmap, clip_x-buffer_x, clip_y-buffer_y ); #endif } @@ -1064,9 +1111,9 @@ void wxCanvasText::Recreate() m_area.x = m_owner->GetDeviceX( m_x ); m_area.y = m_owner->GetDeviceY( m_y ); - m_area.width = 100; // TODO, calculate length - m_area.height = m_size; - m_alpha = new unsigned char[100*m_size]; + m_area.width = 100; // TODO calculate length + m_area.height = m_size + (m_size/2); // TODO space for sub-baseline (pgypq) + m_alpha = new unsigned char[m_area.width*m_area.height]; memset( m_alpha, 0, m_area.width*m_area.height ); #if wxUSE_FREETYPE