[Top][All Lists]

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

Re: [ft-devel] does the face cache really work ?

From: Steve Hartwell
Subject: Re: [ft-devel] does the face cache really work ?
Date: Thu, 02 Jun 2005 06:09:05 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Anstinus Anstinus wrote:

Consider the situation: I looked up a FT_Face by myFaceID1 at first, then at a later time, I want to get the same FT_Face. Should I find the myFaceID1 in my list and use it to lookup a FT_Face , or create a new myFaceID2 with the same content as myFaceID1 ?

You should always pass the same FTC_FaceID (i.e. a pointer to a FTC_FaceIDRec_) to FTC_Manager_LookupFace(), not a (pointer to an) equivalent copy. You can use an equivalent copy to compare against the ones you have in your list, but once you find a match, you must pass the one saved in your list to FTC_Manager_LookupFace() in order to get the same FT_Face back.

Note that FreeType does not define what a FTC_FaceIDRec_ is, only that it is a struct, and a FTC_FaceID is a pointer to it. So, instead of having your own struct My_FaceID_Rec, you can declare in your program:

struct FTC_FaceIDRec_
   const char * file_path;
   int          face_index;

This eliminates a lot of unnecessary casting.

So to use a font face, you can write a function which takes a const char *file_path and an int face_index parameter and returns a FTC_FaceID. Use the two parameters to search your list for a match, and if found, return a pointer to it, else malloc a new struct FTC_FaceIDRec_, initialize it with a copy of the params, add it to the end of the list, and return a pointer to it.

Then whenever you want to access a FT_Face, you can call your function which maps a (file_path, face_index) to a FTC_FaceID, or use a FTC_FaceID that you have stored somewhere, to call FTC_Manager_LookupFace().

Another question: The chars freetype rendered are all "solid". Can freetype render only the outline without fill it ? I didn't find such interface in documents.

Here's an example. If it's not documented, I must have read the header file.

#include FT_STROKER_H

   FT_Stroker stroker;
   FT_Stroker_New(ftFace->memory, &stroker);
FT_Stroker_Set(stroker, 32, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0); FT_Glyph_Stroke(&ftCachedGlyph, stroker, false); // false=don't destroy orig glyph


Steve Hartwell

reply via email to

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