freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] FT_Init_FreeType allocating memory before I get a chance


From: Tom van Dijck
Subject: Re: [ft-devel] FT_Init_FreeType allocating memory before I get a chance to set the allocators.
Date: Mon, 22 Jun 2009 07:52:29 -0700



We have had no problem using FT2 with our own allocators (we work on systems were malloc() and free(), and possibly dynamic allocation entirely, are not present)

So either I am doing it wrong, or Tom van Dick is doing it wrong.
a totally unintentional spelling error ;) I like it.... 

Anyway, I guess you're right though, this simple yet elegant solution had simply not occurred to me, which is retarded....
The solution below seems to be exactly what I need and want to do, and I'm sorry for even asking the other thing.

Tom.


Here's what I do:
1) We have our own struct that contains both the ft library and an FT_Memory object.
2) We initialize the fields in the FT_Memory object so that our callbacks are called.
3) We call FT_New_Library and tell it to use our memory object. This is the first FT2 API call.

       // Initialize freetype2
       lib->ft_memory.alloc    = sf_FTalloc;
       lib->ft_memory.free     = sf_FTfree;
       lib->ft_memory.realloc  = sf_FTrealloc;
       lib->ft_memory.user     = lib;
       ft_err = FT_New_Library( &lib->ft_memory, &lib->ft_lib );

I've always felt that this is the way it's meant to be used! It doesn't look like a hack, and everything is documented. Also it works :)

Basically, if I understand correctly, what Tom asked is already there. There's no need to modify ft_system.c, or invent new API calls.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]