[Top][All Lists]

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

[ft-devel] How to correctly use the cache ?

From: Daniel Diaz
Subject: [ft-devel] How to correctly use the cache ?
Date: Sun, 08 Jul 2007 12:11:29 +0200
User-agent: Thunderbird (X11/20070530)


First of all thank you very much for this wonderful library.

I have searched the archive of this list, so I hope I don't ask neither
a trivial question nor an already answered question.

I'd like to use the cache subsystem for font faces but some points are
not clear enough. Here is what I have understood :

1) I have to manage my own data structure (e.g. hash-table) to always
   provide a unique FTC_FaceID  to the cache.

2) The relation between a FCT_FaceID and a FT_Face is done by a callback
   function (my face_requester function).

3) It is up to me to  obtain a face (with FT_New_Face) and to maintain
   the relation between a FCT_FaceID and a FT_Face.
4) I use FTC_Manager_LookupFace with a FTC_FaceID  to obtain a face from
   the cache, which acts as follows:
 4.1) if a FT_Face corresponding to FTC_FaceID is found it is
      returned, else
 4.2) if there is a free room the face is added to the cache, else
 4.3) the oldest entry is removed from the cache and the new one is
      added. The cache calls FT_Done_Face on the removed face.

Q1) Is this correct ? BTW: it would be great if a "skeleton" of a user
code could be added to the documentation.

Q2) There is an asymmetry: I create the face (FT_New_Face) but it is
destroyed by the cache (4.3). I conclude my face_requester function is
ONLY called in 4.3 and thus has to perform a FT_New_Face /
FT_New_Memory_Face. Is it ok ? I ask this because initially I tough I
could keep triplets <path_name, font_index, FT_Face> in my data
structure (and thus the face_requester simply returns the associated
FT_Face).  BTW: this also could be documented.

Q3) Is there a way to be informed when an entry is removed from the
cache (4.3) ?

Q4) Else, how can I remove useless entries from my own data structure ?
I mean if the cache only uses max_faces entries, I'd like to use tmore
or less he same amount for my own data structure (it is for an embedded
application where memory usage is crucial) ? From what I have understood
my data structure always grows... If true this is a serious
(un)limitation :-)

Thank you very much for your help.

reply via email to

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