ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 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

cffcmap.c
Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  cffcmap.c                                                              */
00004 /*                                                                         */
00005 /*    CFF character mapping table (cmap) support (body).                   */
00006 /*                                                                         */
00007 /*  Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2010 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 "cffcmap.h"
00020 #include "cffload.h"
00021 
00022 #include "cfferrs.h"
00023 
00024 
00025   /*************************************************************************/
00026   /*************************************************************************/
00027   /*****                                                               *****/
00028   /*****           CFF STANDARD (AND EXPERT) ENCODING CMAPS            *****/
00029   /*****                                                               *****/
00030   /*************************************************************************/
00031   /*************************************************************************/
00032 
00033   FT_CALLBACK_DEF( FT_Error )
00034   cff_cmap_encoding_init( CFF_CMapStd  cmap )
00035   {
00036     TT_Face       face     = (TT_Face)FT_CMAP_FACE( cmap );
00037     CFF_Font      cff      = (CFF_Font)face->extra.data;
00038     CFF_Encoding  encoding = &cff->encoding;
00039 
00040 
00041     cmap->gids  = encoding->codes;
00042 
00043     return 0;
00044   }
00045 
00046 
00047   FT_CALLBACK_DEF( void )
00048   cff_cmap_encoding_done( CFF_CMapStd  cmap )
00049   {
00050     cmap->gids  = NULL;
00051   }
00052 
00053 
00054   FT_CALLBACK_DEF( FT_UInt )
00055   cff_cmap_encoding_char_index( CFF_CMapStd  cmap,
00056                                 FT_UInt32    char_code )
00057   {
00058     FT_UInt  result = 0;
00059 
00060 
00061     if ( char_code < 256 )
00062       result = cmap->gids[char_code];
00063 
00064     return result;
00065   }
00066 
00067 
00068   FT_CALLBACK_DEF( FT_UInt32 )
00069   cff_cmap_encoding_char_next( CFF_CMapStd   cmap,
00070                                FT_UInt32    *pchar_code )
00071   {
00072     FT_UInt    result    = 0;
00073     FT_UInt32  char_code = *pchar_code;
00074 
00075 
00076     *pchar_code = 0;
00077 
00078     if ( char_code < 255 )
00079     {
00080       FT_UInt  code = (FT_UInt)(char_code + 1);
00081 
00082 
00083       for (;;)
00084       {
00085         if ( code >= 256 )
00086           break;
00087 
00088         result = cmap->gids[code];
00089         if ( result != 0 )
00090         {
00091           *pchar_code = code;
00092           break;
00093         }
00094 
00095         code++;
00096       }
00097     }
00098     return result;
00099   }
00100 
00101 
00102   FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec,
00103     sizeof ( CFF_CMapStdRec ),
00104 
00105     (FT_CMap_InitFunc)     cff_cmap_encoding_init,
00106     (FT_CMap_DoneFunc)     cff_cmap_encoding_done,
00107     (FT_CMap_CharIndexFunc)cff_cmap_encoding_char_index,
00108     (FT_CMap_CharNextFunc) cff_cmap_encoding_char_next,
00109 
00110     NULL, NULL, NULL, NULL, NULL
00111   )
00112 
00113 
00114   /*************************************************************************/
00115   /*************************************************************************/
00116   /*****                                                               *****/
00117   /*****              CFF SYNTHETIC UNICODE ENCODING CMAP              *****/
00118   /*****                                                               *****/
00119   /*************************************************************************/
00120   /*************************************************************************/
00121 
00122   FT_CALLBACK_DEF( const char* )
00123   cff_sid_to_glyph_name( TT_Face  face,
00124                          FT_UInt  idx )
00125   {
00126     CFF_Font     cff     = (CFF_Font)face->extra.data;
00127     CFF_Charset  charset = &cff->charset;
00128     FT_UInt      sid     = charset->sids[idx];
00129 
00130 
00131     return cff_index_get_sid_string( cff, sid );
00132   }
00133 
00134 
00135   FT_CALLBACK_DEF( FT_Error )
00136   cff_cmap_unicode_init( PS_Unicodes  unicodes )
00137   {
00138     TT_Face             face    = (TT_Face)FT_CMAP_FACE( unicodes );
00139     FT_Memory           memory  = FT_FACE_MEMORY( face );
00140     CFF_Font            cff     = (CFF_Font)face->extra.data;
00141     CFF_Charset         charset = &cff->charset;
00142     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)cff->psnames;
00143 
00144 
00145     /* can't build Unicode map for CID-keyed font */
00146     /* because we don't know glyph names.         */
00147     if ( !charset->sids )
00148       return CFF_Err_No_Unicode_Glyph_Name;
00149 
00150     return psnames->unicodes_init( memory,
00151                                    unicodes,
00152                                    cff->num_glyphs,
00153                                    (PS_GetGlyphNameFunc)&cff_sid_to_glyph_name,
00154                                    (PS_FreeGlyphNameFunc)NULL,
00155                                    (FT_Pointer)face );
00156   }
00157 
00158 
00159   FT_CALLBACK_DEF( void )
00160   cff_cmap_unicode_done( PS_Unicodes  unicodes )
00161   {
00162     FT_Face    face   = FT_CMAP_FACE( unicodes );
00163     FT_Memory  memory = FT_FACE_MEMORY( face );
00164 
00165 
00166     FT_FREE( unicodes->maps );
00167     unicodes->num_maps = 0;
00168   }
00169 
00170 
00171   FT_CALLBACK_DEF( FT_UInt )
00172   cff_cmap_unicode_char_index( PS_Unicodes  unicodes,
00173                                FT_UInt32    char_code )
00174   {
00175     TT_Face             face    = (TT_Face)FT_CMAP_FACE( unicodes );
00176     CFF_Font            cff     = (CFF_Font)face->extra.data;
00177     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)cff->psnames;
00178 
00179 
00180     return psnames->unicodes_char_index( unicodes, char_code );
00181   }
00182 
00183 
00184   FT_CALLBACK_DEF( FT_UInt32 )
00185   cff_cmap_unicode_char_next( PS_Unicodes  unicodes,
00186                               FT_UInt32   *pchar_code )
00187   {
00188     TT_Face             face    = (TT_Face)FT_CMAP_FACE( unicodes );
00189     CFF_Font            cff     = (CFF_Font)face->extra.data;
00190     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)cff->psnames;
00191 
00192 
00193     return psnames->unicodes_char_next( unicodes, pchar_code );
00194   }
00195 
00196 
00197   FT_DEFINE_CMAP_CLASS(cff_cmap_unicode_class_rec,
00198     sizeof ( PS_UnicodesRec ),
00199 
00200     (FT_CMap_InitFunc)     cff_cmap_unicode_init,
00201     (FT_CMap_DoneFunc)     cff_cmap_unicode_done,
00202     (FT_CMap_CharIndexFunc)cff_cmap_unicode_char_index,
00203     (FT_CMap_CharNextFunc) cff_cmap_unicode_char_next,
00204 
00205     NULL, NULL, NULL, NULL, NULL
00206   )
00207 
00208 /* END */

Generated on Fri May 25 2012 04:32:15 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.