1 /***************************************************************************/
5 /* FreeType PFR cmap handling (body). */
7 /* Copyright 2002 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 /***************************************************************************/
21 #include FT_INTERNAL_DEBUG_H
24 FT_CALLBACK_DEF( FT_Error )
25 pfr_cmap_init( PFR_CMap cmap )
27 PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap );
30 cmap->num_chars = face->phy_font.num_chars;
31 cmap->chars = face->phy_font.chars;
33 /* just for safety, check that the character entries are correctly */
34 /* sorted in increasing character code order */
39 for ( n = 1; n < cmap->num_chars; n++ )
41 if ( cmap->chars[n - 1].char_code >= cmap->chars[n].char_code )
50 FT_CALLBACK_DEF( void )
51 pfr_cmap_done( PFR_CMap cmap )
58 FT_CALLBACK_DEF( FT_UInt )
59 pfr_cmap_char_index( PFR_CMap cmap,
63 FT_UInt max = cmap->num_chars;
70 mid = min + ( max - min ) / 2;
71 gchar = cmap->chars + mid;
73 if ( gchar->char_code == char_code )
76 if ( gchar->char_code < char_code )
85 FT_CALLBACK_DEF( FT_UInt )
86 pfr_cmap_char_next( PFR_CMap cmap,
87 FT_UInt32 *pchar_code )
90 FT_UInt32 char_code = *pchar_code + 1;
96 FT_UInt max = cmap->num_chars;
103 mid = min + ( ( max - min ) >> 1 );
104 gchar = cmap->chars + mid;
106 if ( gchar->char_code == char_code )
119 if ( gchar->char_code < char_code )
125 /* we didn't find it, but we have a pair just above it */
128 if ( min < cmap->num_chars )
130 gchar = cmap->chars + min;
135 char_code = gchar->char_code;
141 *pchar_code = char_code;
146 FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
149 sizeof ( PFR_CMapRec ),
151 (FT_CMap_InitFunc) pfr_cmap_init,
152 (FT_CMap_DoneFunc) pfr_cmap_done,
153 (FT_CMap_CharIndexFunc)pfr_cmap_char_index,
154 (FT_CMap_CharNextFunc) pfr_cmap_char_next