From cba349dc6ef3443ad486fc4678d0f5c97d48b219 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Sep 2000 17:43:19 +0000 Subject: [PATCH] use TRUETYPE env var for the font location git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8237 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/samples/canvas/test/test.cpp | 31 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/contrib/samples/canvas/test/test.cpp b/contrib/samples/canvas/test/test.cpp index 7377a35b0e..e31de9ae4a 100644 --- a/contrib/samples/canvas/test/test.cpp +++ b/contrib/samples/canvas/test/test.cpp @@ -59,6 +59,11 @@ class MyApp: public wxApp { public: virtual bool OnInit(); + + const wxString& GetFontPath() const { return m_fontpath; } + +private: + wxString m_fontpath; }; // main program @@ -100,28 +105,29 @@ MyFrame::MyFrame() m_canvas->SetArea( 400, 600 ); m_canvas->SetColour( 255, 255, 255 ); - + wxBitmap bitmap( smile_xpm ); wxImage image( bitmap ); - + m_sm1 = new wxCanvasImage( image, 0, 70 ); m_canvas->Append( m_sm1 ); - + int i; for (i = 10; i < 300; i+=10) m_canvas->Append( new wxCanvasRect( i,50,3,140, 255,0,0 ) ); - + m_sm2 = new wxCanvasImage( image, 0, 140 ); m_canvas->Append( m_sm2 ); - + for (i = 15; i < 300; i+=10) m_canvas->Append( new wxCanvasRect( i,50,3,140, 255,0,0 ) ); - + 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, "/home/robert/TrueType/times.ttf", 20 ) ); - + m_canvas->Append( new wxCanvasText( "Hello", 180, 50, + wxGetApp().GetFontPath() + "/times.ttf", 20 ) ); + m_timer = new wxTimer( this ); m_timer->Start( 100, FALSE ); } @@ -156,6 +162,15 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) bool MyApp::OnInit() { + m_fontpath = getenv("TRUETYPE"); + if ( !m_fontpath ) + { + wxLogError("Please set env var TRUETYPE to the path where times.ttf lives."); + + return FALSE; + + } + #if wxUSE_LIBPNG wxImage::AddHandler( new wxPNGHandler ); #endif -- 2.45.2