From 25faedaa980466a082a25055736b2c3c66d4675b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 23 Dec 2001 01:09:20 +0000 Subject: [PATCH] applied patch fixing some graphical glitches from Dimitri git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13165 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/font/font.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/samples/font/font.cpp b/samples/font/font.cpp index 8b526f403b..a88746d28e 100644 --- a/samples/font/font.cpp +++ b/samples/font/font.cpp @@ -644,24 +644,36 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) dc.DrawText(fontInfo, 5, 5 + dc.GetCharHeight()); } + // the origin for our table + int x = 5, + y = dc.GetCharHeight() * (2 + 1); + // prepare to draw the font dc.SetFont(m_font); dc.SetTextForeground(m_colour); - // the size of one cell (char + small margin) - int w = dc.GetCharWidth() + 5, - h = dc.GetCharHeight() + 4; + // the size of one cell (Normally biggest char + small margin) + long maxCharWidth, maxCharHeight; + dc.GetTextExtent(wxT("W"), &maxCharWidth, &maxCharHeight); + int w = maxCharWidth + 5, + h = maxCharHeight + 4; - // the origin for our table - int x = 5, - y = 2*h; // print all font symbols from 32 to 256 in 7 rows of 32 chars each - for ( int i = 1; i < 8; i++ ) + for ( int i = 0; i < 7; i++ ) { for ( int j = 0; j < 32; j++ ) { - dc.DrawText(wxChar(32*i + j), x + w*j, y + h*i); + wxChar c = 32 * (i + 1) + j; + + long charWidth, charHeight; + dc.GetTextExtent(c, &charWidth, &charHeight); + dc.DrawText + ( + c, + x + w*j + (maxCharWidth - charWidth) / 2 + 1, + y + h*i + (maxCharHeight - charHeight) / 2 + ); } } @@ -670,17 +682,16 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) int l; // horizontal - y += h; for ( l = 0; l < 8; l++ ) { int yl = y + h*l - 2; - dc.DrawLine(x - 2, yl, x + 32*w - 2, yl); + dc.DrawLine(x - 2, yl, x + 32*w - 1, yl); } // and vertical for ( l = 0; l < 33; l++ ) { int xl = x + w*l - 2; - dc.DrawLine(xl, y, xl, y + 7*h - 2); + dc.DrawLine(xl, y - 2, xl, y + 7*h - 1); } }