Name
OpenFont -- create FreeType2 font from memory buffer (V5.0)
Synopsis
FT_Face face = OpenFont(UBYTE *data, int datalen);
Function
This function has to create an FT_Face handle from the raw font data passed to it. You only need to implement this function if you build plugins for WarpOS or if the HWEXT_VECTOR_CUSTOMFT2 extension bit has been set. If neither is the case, your OpenFont() implementation can just return NULL because it will never be called.

The reason why this function is needed on WarpOS is that the WarpOS version of Hollywood contains two builds of FreeType2: one for 68020 and one for the PowerPC architecture. Plugins will always have to work with the PPC native version to avoid context switches. Hollywood itself, however, uses the 68020 build of FreeType2 because it's faster in most cases because Hollywood doesn't have to do any context switches. Using the FT_Face handle allocated by the 68020 version of FreeType2 is not going to work with the PowerPC version of FreeType2, though, due to different structure alignments, etc. That is why you need to use the PowerPC version of FreeType2 on WarpOS to create a compatible FT_Face handle which is then passed to CreateVectorFont().

Plugins that use their own FreeType2 version are in the same situation as with WarpOS (see above): Their FT_Face won't be compatible with Hollywood's FT_Face which is why they need to implement OpenFont() as well and they also need to set the HWEXT_VECTOR_CUSTOMFT2 extension bit to tell Hollywood that they use a custom implementation of FreeType2. See Extension plugins to learn how to use plugin extension bits.

Basically, all OpenFont() has to do is the following:

 
HW_EXPORT FT_Face OpenFont(UBYTE *data, int datalen)
{
    FT_Face face;

    if(FT_New_Memory_Face(freetype_library, data,
           datalen, 0, &face)) return NULL;

    return face;
}

HW_EXPORT void CloseFont(FT_Face face)
{
    FT_Done_Face(face);
}

Note that on WarpOS those functions needn't even use their own version of FreeType2 but they could just call into Hollywood's FreeType2 functions located in FT2Base.

Hollywood will call CloseFont() to free handles allocated by this function.

Inputs
data
pointer to raw font data (usually pointer to TrueType font data)
datalen
size of the data buffer in bytes
Results
face
handle to an FT_Face allocated by the custom version of FreeType2 or NULL in case of an error

Show TOC