[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Freetype] Saving Memory using the ROM - API suggestion
From: |
David Turner |
Subject: |
Re: [Freetype] Saving Memory using the ROM - API suggestion |
Date: |
Thu, 06 Dec 2001 20:59:32 +0100 |
Hello Dave,
Dave Williss a écrit :
>
> Should be fairly easy. There's a replacement module for file IO that
> replaces it with memory-mapped IO (using mmap). Start with that and
> modify it to just point to where the font is in ROM. (I'm assuming you
> have the actual ttf file burned in the ROM).
>
> In fact here's a suggestion for the team:
>
> Would it be possible to add an FT_Open_Face_In_Memory function
> that instead of trying to open the font took a pointer to something already
> read into memory?
>
Actually, FreeType 2 has provided FT_New_Memory_Face from the start :-)
Moreover, the engine is designed to actually _save_ memory when using
memory-mapped or ROM-based font files, since it will not duplicate
certain font file tables in the heap, since they're already directly
available..
the whole concept of "frames" used in the internal i/o FreeType routines
was designed specifically to take advantage of memory-based files.. and
it dates from FreeType 1 actually..
> This way reading a font in ROM would just be a simple function call and
> you wouldn't have to hack the library source to do it. It would have
> greatly
> simplified Mac OSX dfont rendering too, because it leaves the platform-
> specific find-the-font-embedded-in-this-file bit up to the caller.
> It would be up to the caller to free (if necessary) any memory after they
> close the face. Or perhaps have a way to register a free function that will
> get called on close.
>
You should start investigating this right now, everything is already built-in
in the library to support the feature !! :-)
On another note, with FreeType 1, you'll need to provide a custom stream
implementation however. I do believe that the memory-saving optimisations
are still more important in FT2 than in this version of the engine, though
I could be wrong (I haven't profiled the memory footprint of FT1 for a long
time now..). Also, not all drivers optimise memory-based i/o.
Regards,
- David