ReactOS Fundraising Campaign 2012
 
€ 4,060 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

t1cmap.c
Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  t1cmap.c                                                               */
00004 /*                                                                         */
00005 /*    Type 1 character map support (body).                                 */
00006 /*                                                                         */
00007 /*  Copyright 2002, 2003, 2006, 2007 by                                    */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 
00019 #include "t1cmap.h"
00020 
00021 #include FT_INTERNAL_DEBUG_H
00022 
00023 #include "psauxerr.h"
00024 
00025 
00026   /*************************************************************************/
00027   /*************************************************************************/
00028   /*****                                                               *****/
00029   /*****          TYPE1 STANDARD (AND EXPERT) ENCODING CMAPS           *****/
00030   /*****                                                               *****/
00031   /*************************************************************************/
00032   /*************************************************************************/
00033 
00034   static void
00035   t1_cmap_std_init( T1_CMapStd  cmap,
00036                     FT_Int      is_expert )
00037   {
00038     T1_Face             face    = (T1_Face)FT_CMAP_FACE( cmap );
00039     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
00040 
00041 
00042     cmap->num_glyphs    = face->type1.num_glyphs;
00043     cmap->glyph_names   = (const char* const*)face->type1.glyph_names;
00044     cmap->sid_to_string = psnames->adobe_std_strings;
00045     cmap->code_to_sid   = is_expert ? psnames->adobe_expert_encoding
00046                                     : psnames->adobe_std_encoding;
00047 
00048     FT_ASSERT( cmap->code_to_sid != NULL );
00049   }
00050 
00051 
00052   FT_CALLBACK_DEF( void )
00053   t1_cmap_std_done( T1_CMapStd  cmap )
00054   {
00055     cmap->num_glyphs    = 0;
00056     cmap->glyph_names   = NULL;
00057     cmap->sid_to_string = NULL;
00058     cmap->code_to_sid   = NULL;
00059   }
00060 
00061 
00062   FT_CALLBACK_DEF( FT_UInt )
00063   t1_cmap_std_char_index( T1_CMapStd  cmap,
00064                           FT_UInt32   char_code )
00065   {
00066     FT_UInt  result = 0;
00067 
00068 
00069     if ( char_code < 256 )
00070     {
00071       FT_UInt      code, n;
00072       const char*  glyph_name;
00073 
00074 
00075       /* convert character code to Adobe SID string */
00076       code       = cmap->code_to_sid[char_code];
00077       glyph_name = cmap->sid_to_string( code );
00078 
00079       /* look for the corresponding glyph name */
00080       for ( n = 0; n < cmap->num_glyphs; n++ )
00081       {
00082         const char* gname = cmap->glyph_names[n];
00083 
00084 
00085         if ( gname && gname[0] == glyph_name[0]  &&
00086              ft_strcmp( gname, glyph_name ) == 0 )
00087         {
00088           result = n;
00089           break;
00090         }
00091       }
00092     }
00093 
00094     return result;
00095   }
00096 
00097 
00098   FT_CALLBACK_DEF( FT_UInt32 )
00099   t1_cmap_std_char_next( T1_CMapStd   cmap,
00100                          FT_UInt32   *pchar_code )
00101   {
00102     FT_UInt    result    = 0;
00103     FT_UInt32  char_code = *pchar_code + 1;
00104 
00105 
00106     while ( char_code < 256 )
00107     {
00108       result = t1_cmap_std_char_index( cmap, char_code );
00109       if ( result != 0 )
00110         goto Exit;
00111 
00112       char_code++;
00113     }
00114     char_code = 0;
00115 
00116   Exit:
00117     *pchar_code = char_code;
00118     return result;
00119   }
00120 
00121 
00122   FT_CALLBACK_DEF( FT_Error )
00123   t1_cmap_standard_init( T1_CMapStd  cmap )
00124   {
00125     t1_cmap_std_init( cmap, 0 );
00126     return 0;
00127   }
00128 
00129 
00130   FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
00131   t1_cmap_standard_class_rec =
00132   {
00133     sizeof ( T1_CMapStdRec ),
00134 
00135     (FT_CMap_InitFunc)     t1_cmap_standard_init,
00136     (FT_CMap_DoneFunc)     t1_cmap_std_done,
00137     (FT_CMap_CharIndexFunc)t1_cmap_std_char_index,
00138     (FT_CMap_CharNextFunc) t1_cmap_std_char_next,
00139 
00140     NULL, NULL, NULL, NULL, NULL
00141   };
00142 
00143 
00144   FT_CALLBACK_DEF( FT_Error )
00145   t1_cmap_expert_init( T1_CMapStd  cmap )
00146   {
00147     t1_cmap_std_init( cmap, 1 );
00148     return 0;
00149   }
00150 
00151   FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
00152   t1_cmap_expert_class_rec =
00153   {
00154     sizeof ( T1_CMapStdRec ),
00155 
00156     (FT_CMap_InitFunc)     t1_cmap_expert_init,
00157     (FT_CMap_DoneFunc)     t1_cmap_std_done,
00158     (FT_CMap_CharIndexFunc)t1_cmap_std_char_index,
00159     (FT_CMap_CharNextFunc) t1_cmap_std_char_next,
00160 
00161     NULL, NULL, NULL, NULL, NULL
00162   };
00163 
00164 
00165   /*************************************************************************/
00166   /*************************************************************************/
00167   /*****                                                               *****/
00168   /*****                    TYPE1 CUSTOM ENCODING CMAP                 *****/
00169   /*****                                                               *****/
00170   /*************************************************************************/
00171   /*************************************************************************/
00172 
00173 
00174   FT_CALLBACK_DEF( FT_Error )
00175   t1_cmap_custom_init( T1_CMapCustom  cmap )
00176   {
00177     T1_Face      face     = (T1_Face)FT_CMAP_FACE( cmap );
00178     T1_Encoding  encoding = &face->type1.encoding;
00179 
00180 
00181     cmap->first   = encoding->code_first;
00182     cmap->count   = (FT_UInt)( encoding->code_last - cmap->first );
00183     cmap->indices = encoding->char_index;
00184 
00185     FT_ASSERT( cmap->indices != NULL );
00186     FT_ASSERT( encoding->code_first <= encoding->code_last );
00187 
00188     return 0;
00189   }
00190 
00191 
00192   FT_CALLBACK_DEF( void )
00193   t1_cmap_custom_done( T1_CMapCustom  cmap )
00194   {
00195     cmap->indices = NULL;
00196     cmap->first   = 0;
00197     cmap->count   = 0;
00198   }
00199 
00200 
00201   FT_CALLBACK_DEF( FT_UInt )
00202   t1_cmap_custom_char_index( T1_CMapCustom  cmap,
00203                              FT_UInt32      char_code )
00204   {
00205     FT_UInt    result = 0;
00206 
00207 
00208     if ( ( char_code >= cmap->first )                  &&
00209          ( char_code < ( cmap->first + cmap->count ) ) )
00210       result = cmap->indices[char_code];
00211 
00212     return result;
00213   }
00214 
00215 
00216   FT_CALLBACK_DEF( FT_UInt32 )
00217   t1_cmap_custom_char_next( T1_CMapCustom  cmap,
00218                             FT_UInt32     *pchar_code )
00219   {
00220     FT_UInt    result = 0;
00221     FT_UInt32  char_code = *pchar_code;
00222 
00223 
00224     ++char_code;
00225 
00226     if ( char_code < cmap->first )
00227       char_code = cmap->first;
00228 
00229     for ( ; char_code < ( cmap->first + cmap->count ); char_code++ )
00230     {
00231       result = cmap->indices[char_code];
00232       if ( result != 0 )
00233         goto Exit;
00234     }
00235 
00236     char_code = 0;
00237 
00238   Exit:
00239     *pchar_code = char_code;
00240     return result;
00241   }
00242 
00243 
00244   FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
00245   t1_cmap_custom_class_rec =
00246   {
00247     sizeof ( T1_CMapCustomRec ),
00248 
00249     (FT_CMap_InitFunc)     t1_cmap_custom_init,
00250     (FT_CMap_DoneFunc)     t1_cmap_custom_done,
00251     (FT_CMap_CharIndexFunc)t1_cmap_custom_char_index,
00252     (FT_CMap_CharNextFunc) t1_cmap_custom_char_next,
00253 
00254     NULL, NULL, NULL, NULL, NULL
00255   };
00256 
00257 
00258   /*************************************************************************/
00259   /*************************************************************************/
00260   /*****                                                               *****/
00261   /*****            TYPE1 SYNTHETIC UNICODE ENCODING CMAP              *****/
00262   /*****                                                               *****/
00263   /*************************************************************************/
00264   /*************************************************************************/
00265 
00266   FT_CALLBACK_DEF( const char * )
00267   t1_get_glyph_name( T1_Face  face,
00268                      FT_UInt  idx )
00269   {
00270     return face->type1.glyph_names[idx];
00271   }
00272 
00273 
00274   FT_CALLBACK_DEF( FT_Error )
00275   t1_cmap_unicode_init( PS_Unicodes  unicodes )
00276   {
00277     T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
00278     FT_Memory           memory  = FT_FACE_MEMORY( face );
00279     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
00280 
00281 
00282     return psnames->unicodes_init( memory,
00283                                    unicodes,
00284                                    face->type1.num_glyphs,
00285                                    (PS_GetGlyphNameFunc)&t1_get_glyph_name,
00286                                    (PS_FreeGlyphNameFunc)NULL,
00287                                    (FT_Pointer)face );
00288   }
00289 
00290 
00291   FT_CALLBACK_DEF( void )
00292   t1_cmap_unicode_done( PS_Unicodes  unicodes )
00293   {
00294     FT_Face    face   = FT_CMAP_FACE( unicodes );
00295     FT_Memory  memory = FT_FACE_MEMORY( face );
00296 
00297 
00298     FT_FREE( unicodes->maps );
00299     unicodes->num_maps = 0;
00300   }
00301 
00302 
00303   FT_CALLBACK_DEF( FT_UInt )
00304   t1_cmap_unicode_char_index( PS_Unicodes  unicodes,
00305                               FT_UInt32    char_code )
00306   {
00307     T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
00308     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
00309 
00310 
00311     return psnames->unicodes_char_index( unicodes, char_code );
00312   }
00313 
00314 
00315   FT_CALLBACK_DEF( FT_UInt32 )
00316   t1_cmap_unicode_char_next( PS_Unicodes  unicodes,
00317                              FT_UInt32   *pchar_code )
00318   {
00319     T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
00320     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
00321 
00322 
00323     return psnames->unicodes_char_next( unicodes, pchar_code );
00324   }
00325 
00326 
00327   FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
00328   t1_cmap_unicode_class_rec =
00329   {
00330     sizeof ( PS_UnicodesRec ),
00331 
00332     (FT_CMap_InitFunc)     t1_cmap_unicode_init,
00333     (FT_CMap_DoneFunc)     t1_cmap_unicode_done,
00334     (FT_CMap_CharIndexFunc)t1_cmap_unicode_char_index,
00335     (FT_CMap_CharNextFunc) t1_cmap_unicode_char_next,
00336 
00337     NULL, NULL, NULL, NULL, NULL
00338   };
00339 
00340 
00341 /* END */

Generated on Tue May 22 2012 04:38:03 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.