freetype-devel
[Top][All Lists]
Advanced

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

Re: [ft-devel] Incomplete cmap table for platform 0 (Apple Unicode)


From: mpsuzuki
Subject: Re: [ft-devel] Incomplete cmap table for platform 0 (Apple Unicode)
Date: Mon, 1 Oct 2007 14:09:44 +0900

Dear Dmitry,

Following is a function whose API is similar to
FT_Select_Charmap() but ignores non-Microsoft
cmap subtables. Does it serve your purpose?


#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TRUETYPE_IDS_H

/* getting the first cmap subtable for Microsoft platform
 * matching specified encoding. If encoding is FT_ENCODING_UNICODE,
 * UCS4 is prioritized than UCS2.
 */
FT_Error
FT_Select_Charmap_Microsoft( FT_Face      face,
                             FT_Encoding  encoding )
{
    FT_Int  i, chosen_cmap_idx;


    chosen_cmap_idx = -1; /* -1 means not found */

    for ( i = 0; i < face->num_charmaps; i ++ )
    {
        if ( face->charmaps[ i ]->platform_id != TT_PLATFORM_MICROSOFT )
            continue;
        else if ( encoding != FT_ENCODING_UNICODE &&
                  face->charmaps[ i ]->encoding == encoding )
        {
            chosen_cmap_idx = i;
            break;
        }
        else if ( face->charmaps[ i ]->encoding_id == TT_MS_ID_UCS_4 )
        {
            chosen_cmap_idx = i;
            break;
        }
        else if ( face->charmaps[ i ]->encoding_id == TT_MS_ID_UNICODE_CS )
        {
            if ( chosen_cmap_idx < 0 )
                chosen_cmap_idx = i;
        }
    }

    if ( chosen_cmap_idx < 0 )
        return FT_Err_Invalid_CharMap_Handle;

    return FT_Set_Charmap( face, face->charmaps[ chosen_cmap_idx ] );
}




reply via email to

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