Upload tizen 2.0 beta source
[framework/graphics/freetype.git] / src / cff / cffdrivr.c
index 39f04ee..eb4c14e 100644 (file)
@@ -4,8 +4,7 @@
 /*                                                                         */
 /*    OpenType font driver implementation (body).                          */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,   */
-/*            2010 by                                                      */
+/*  Copyright 1996-2012 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    Load_Glyph                                                         */
+  /*    cff_glyph_load                                                     */
   /*                                                                       */
   /* <Description>                                                         */
   /*    A driver method used to load a glyph within a given glyph slot.    */
   /*    FreeType error code.  0 means success.                             */
   /*                                                                       */
   FT_CALLBACK_DEF( FT_Error )
-  Load_Glyph( FT_GlyphSlot  cffslot,        /* CFF_GlyphSlot */
-              FT_Size       cffsize,        /* CFF_Size      */
-              FT_UInt       glyph_index,
-              FT_Int32      load_flags )
+  cff_glyph_load( FT_GlyphSlot  cffslot,      /* CFF_GlyphSlot */
+                  FT_Size       cffsize,      /* CFF_Size      */
+                  FT_UInt       glyph_index,
+                  FT_Int32      load_flags )
   {
     FT_Error       error;
     CFF_GlyphSlot  slot = (CFF_GlyphSlot)cffslot;
 
     for ( nn = 0; nn < count; nn++ )
     {
-      error = Load_Glyph( slot, face->size, start + nn, flags );
+      error = cff_glyph_load( slot, face->size, start + nn, flags );
       if ( error )
         break;
 
                  " cannot get glyph name from CFF & CEF fonts\n"
                  "                   "
                  " without the `PSNames' module\n" ));
-      error = CFF_Err_Unknown_File_Format;
+      error = CFF_Err_Missing_Module;
       goto Exit;
     }
 
     if ( cff && cff->font_info == NULL )
     {
       CFF_FontRecDict  dict   = &cff->top_font.font_dict;
-      PS_FontInfoRec  *font_info;
+      PS_FontInfoRec  *font_info = NULL;
       FT_Memory        memory = face->root.memory;
 
 
     (PS_GetFontInfoFunc)   cff_ps_get_font_info,
     (PS_GetFontExtraFunc)  NULL,
     (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names,
-    (PS_GetFontPrivateFunc)NULL         /* unsupported with CFF fonts */
+    (PS_GetFontPrivateFunc)NULL,        /* unsupported with CFF fonts */
+    (PS_GetFontValueFunc)  NULL         /* not implemented            */
   )
 
 
                                                     dict->cid_registry );
         *registry = cff->registry;
       }
-      
+
       if ( ordering )
       {
         if ( cff->ordering == NULL )
         *supplement = (FT_Int)dict->cid_supplement;
       }
     }
-      
+
   Fail:
     return error;
   }
   cff_get_interface( FT_Module    driver,       /* CFF_Driver */
                      const char*  module_interface )
   {
+    FT_Library           library;
     FT_Module            sfnt;
     FT_Module_Interface  result;
 
 
+    /* FT_CFF_SERVICES_GET derefers `library' in PIC mode */
+#ifdef FT_CONFIG_OPTION_PIC
+    if ( !driver )
+      return NULL;
+    library = driver->library;
+    if ( !library )
+      return NULL;
+#endif
+
     result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
     if ( result != NULL )
-      return  result;
+      return result;
 
+    /* `driver' is not yet evaluated in non-PIC mode */
+#ifndef FT_CONFIG_OPTION_PIC
     if ( !driver )
       return NULL;
+    library = driver->library;
+    if ( !library )
+      return NULL;
+#endif
 
     /* we pass our request to the `sfnt' module */
-    sfnt = FT_Get_Module( driver->library, "sfnt" );
+    sfnt = FT_Get_Module( library, "sfnt" );
 
     return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;
   }
 #define CFF_SIZE_SELECT 0
 #endif
 
-  FT_DEFINE_DRIVER(cff_driver_class,
+  FT_DEFINE_DRIVER( cff_driver_class,
+
       FT_MODULE_FONT_DRIVER       |
       FT_MODULE_DRIVER_SCALABLE   |
       FT_MODULE_DRIVER_HAS_HINTER,
 
-      sizeof( CFF_DriverRec ),
+      sizeof ( CFF_DriverRec ),
       "cff",
       0x10000L,
       0x20000L,
       cff_get_interface,
 
     /* now the specific driver fields */
-    sizeof( TT_FaceRec ),
-    sizeof( CFF_SizeRec ),
-    sizeof( CFF_GlyphSlotRec ),
+    sizeof ( TT_FaceRec ),
+    sizeof ( CFF_SizeRec ),
+    sizeof ( CFF_GlyphSlotRec ),
 
     cff_face_init,
     cff_face_done,
     cff_slot_init,
     cff_slot_done,
 
-    ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
+    ft_stub_set_char_sizes,  /* FT_CONFIG_OPTION_OLD_INTERNALS */
     ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
 
-    Load_Glyph,
+    cff_glyph_load,
 
     cff_get_kerning,
-    0,                      /* FT_Face_AttachFunc      */
-    cff_get_advances,       /* FT_Face_GetAdvancesFunc */
+    0,                       /* FT_Face_AttachFunc */
+    cff_get_advances,
 
     cff_size_request,