Thank you Klaas and Süleyman

I have tried both of ways that you mentioned before, but they don't have any 
effect.
I tried to share the loaded font but I don't know why function 
a2dFontFreetypeData::SetFilename called again when I trying to new an a2dText, 
and report me error at this line :


error = FT_New_Face( g_freetypeLibrary, fname.mb_str(), m_faceindex, &m_face );
    if ( error )
    {
        a2dGeneralGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _( "file %s 
contains wrong font" ), m_filename.c_str() );
        m_face = NULL;
        return;
    }

In the error message the font name and also the path are correct. I attached a 
very simple example of this problem. In my actual program I have a console that 
writes FT_Stream_Open: could not open file : 'C:\Windows\Fonts\arial.ttf'.
Interesting part is it works for lower number of instances.



Thank you again.

Cheers,
Hojjat.
#include "a2dprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include <wx/canvas/canvas.h>
#include <wx/aggdrawer/aggdrawer.h>

//----------------------------------------------------------------------------
// MyFrame
//----------------------------------------------------------------------------

class MyFrame: public wxFrame
{
public:

    MyFrame( wxWindow* parent, wxWindowID id, const wxString& title,
             const wxPoint& pos = wxDefaultPosition,
             const wxSize& size = wxDefaultSize,
             long style = wxDEFAULT_FRAME_STYLE );

private:

private:

    a2dCanvas*         m_canvas;

private:

};

//----------------------------------------------------------------------------
// MyApp
//----------------------------------------------------------------------------

class MyApp: public wxApp
{
public:

        MyApp();

    virtual bool OnInit();
    virtual int OnExit();

    MyFrame* m_frame;
};


//------------------------------------------------------------------------------
// MyFrame
//------------------------------------------------------------------------------

MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title,
                  const wxPoint& position, const wxSize& size, long style ) :
    wxFrame( parent, id, title, position, size, style )
{

        a2dAggDrawer *drawer2d = new a2dAggDrawer( 0, 0 );
    m_canvas = new a2dCanvas( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
wxTAB_TRAVERSAL, drawer2d);
        

    a2dCanvasDocument* root = m_canvas->GetCanvasDocument();

        int maxText = 509;              // crashes if you set maxText to 510, 
zoom it!
        for (int i = 0; i < maxText; ++i)
        {
                a2dText* text = new a2dText( wxT( "test text" ), 2*i, 2*i, 
a2dFont( wxT("arial.ttf"), 50.0) );
                root->Prepend( text );
        }

        m_canvas->SetMappingUpp(0, 0, 1, 1);
}

//------------------------------------------------------------------------------
// MyApp
//------------------------------------------------------------------------------

IMPLEMENT_APP( MyApp )

MyApp::MyApp()
{
}

bool MyApp::OnInit()
{
    m_frame = new MyFrame( NULL, -1, wxT( "SuperApp" ), wxPoint( 20, 30 ), 
wxSize( 800, 800 ) );
    m_frame->Show( true );

    return true;
}

int MyApp::OnExit()
{
    return 0;
}


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Wxart2d-users_dev mailing list
Wxart2d-users_dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev

Reply via email to