1 /***************************************************************************/
5 /* FreeType PFR cmap handling (body). */
7 /* Copyright 2002, 2007, 2009, 2013 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
20 #include FT_INTERNAL_DEBUG_H
27 FT_CALLBACK_DEF( FT_Error )
28 pfr_cmap_init( PFR_CMap cmap,
31 FT_Error error = FT_Err_Ok;
32 PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap );
37 cmap->num_chars = face->phy_font.num_chars;
38 cmap->chars = face->phy_font.chars;
40 /* just for safety, check that the character entries are correctly */
41 /* sorted in increasing character code order */
46 for ( n = 1; n < cmap->num_chars; n++ )
48 if ( cmap->chars[n - 1].char_code >= cmap->chars[n].char_code )
50 error = FT_THROW( Invalid_Table );
61 FT_CALLBACK_DEF( void )
62 pfr_cmap_done( PFR_CMap cmap )
69 FT_CALLBACK_DEF( FT_UInt )
70 pfr_cmap_char_index( PFR_CMap cmap,
74 FT_UInt max = cmap->num_chars;
83 mid = min + ( max - min ) / 2;
84 gchar = cmap->chars + mid;
86 if ( gchar->char_code == char_code )
89 if ( gchar->char_code < char_code )
98 FT_CALLBACK_DEF( FT_UInt32 )
99 pfr_cmap_char_next( PFR_CMap cmap,
100 FT_UInt32 *pchar_code )
103 FT_UInt32 char_code = *pchar_code + 1;
109 FT_UInt max = cmap->num_chars;
116 mid = min + ( ( max - min ) >> 1 );
117 gchar = cmap->chars + mid;
119 if ( gchar->char_code == char_code )
132 if ( gchar->char_code < char_code )
138 /* we didn't find it, but we have a pair just above it */
141 if ( min < cmap->num_chars )
143 gchar = cmap->chars + min;
148 char_code = gchar->char_code;
154 *pchar_code = char_code;
159 FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
162 sizeof ( PFR_CMapRec ),
164 (FT_CMap_InitFunc) pfr_cmap_init,
165 (FT_CMap_DoneFunc) pfr_cmap_done,
166 (FT_CMap_CharIndexFunc)pfr_cmap_char_index,
167 (FT_CMap_CharNextFunc) pfr_cmap_char_next,
169 NULL, NULL, NULL, NULL, NULL