⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t42objs.c

📁 a very goog book
💻 C
📖 第 1 页 / 共 2 页
字号:
      FT_FREE( face->ttf_data );#if 0      /* release afm data if present */      if ( face->afm_data )        T1_Done_AFM( memory, (T1_AFM*)face->afm_data );#endif      /* release unicode map, if any */      FT_FREE( face->unicode_map.maps );      face->unicode_map.num_maps = 0;      face->root.family_name = 0;      face->root.style_name  = 0;    }  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    T42_Driver_Init                                                    */  /*                                                                       */  /* <Description>                                                         */  /*    Initializes a given Type 42 driver object.                         */  /*                                                                       */  /* <Input>                                                               */  /*    driver :: A handle to the target driver object.                    */  /*                                                                       */  /* <Return>                                                              */  /*    FreeType error code.  0 means success.                             */  /*                                                                       */  FT_LOCAL_DEF( FT_Error )  T42_Driver_Init( T42_Driver  driver )  {    FT_Module  ttmodule;    ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" );    driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;    return T42_Err_Ok;  }  FT_LOCAL_DEF( void )  T42_Driver_Done( T42_Driver  driver )  {    FT_UNUSED( driver );  }  FT_LOCAL_DEF( FT_UInt )  T42_CMap_CharIndex( FT_CharMap  charmap,                      FT_Long     charcode )  {    T42_Face         face;    FT_UInt          result = 0;    PSNames_Service  psnames;    face    = (T42_Face)charmap->face;    psnames = (PSNames_Service)face->psnames;    if (!psnames )      goto Exit;    switch ( charmap->encoding )    {      /*******************************************************************/      /*                                                                 */      /* Unicode encoding support                                        */      /*                                                                 */    case ft_encoding_unicode:      /* if this charmap is used, we ignore the encoding of the font and */      /* use the `PSNames' module to synthetize the Unicode charmap      */      result = psnames->lookup_unicode( &face->unicode_map,                                        (FT_ULong)charcode );      /* the function returns 0xFFFF if the Unicode charcode has */      /* no corresponding glyph                                  */      if ( result == 0xFFFFU )        result = 0;      /* The result returned is the index (position)in the CharStrings */      /* array.  This must be used now to get the value associated to  */      /* that glyph_name, which is the real index within the truetype  */      /* structure.                                                    */      result = ft_atoi( (const char*)face->type1.charstrings[result] );      goto Exit;      /*******************************************************************/      /*                                                                 */      /* ISOLatin1 encoding support                                      */      /*                                                                 */    case ft_encoding_latin_1:      /* ISOLatin1 is the first page of Unicode */      if ( charcode < 256 && psnames->unicode_value )      {        result = psnames->lookup_unicode( &face->unicode_map,                                          (FT_ULong)charcode );        /* the function returns 0xFFFF if the Unicode charcode has */        /* no corresponding glyph                                  */        if ( result == 0xFFFFU )          result = 0;      }      goto Exit;      /*******************************************************************/      /*                                                                 */      /* Custom Type 1 encoding                                          */      /*                                                                 */    case ft_encoding_adobe_custom:      {        T1_Encoding  encoding = &face->type1.encoding;        if ( charcode >= encoding->code_first &&             charcode <= encoding->code_last  )        {          FT_UInt idx = encoding->char_index[charcode];          result = ft_atoi( (const char *)face->type1.charstrings[idx] );        }        goto Exit;      }      /*******************************************************************/      /*                                                                 */      /* Adobe Standard & Expert encoding support                        */      /*                                                                 */    default:      if ( charcode < 256 )      {        FT_UInt      code;        FT_Int       n;        const char*  glyph_name;        code = psnames->adobe_std_encoding[charcode];        if ( charmap->encoding == ft_encoding_adobe_expert )          code = psnames->adobe_expert_encoding[charcode];        glyph_name = psnames->adobe_std_strings( code );        if ( !glyph_name )          break;        for ( n = 0; n < face->type1.num_glyphs; n++ )        {          const char*  gname = face->type1.glyph_names[n];          if ( gname && ( ft_strcmp( gname, glyph_name ) == 0 ) )          {            result = ft_atoi( (const char *)face->type1.charstrings[n] );            break;          }        }      }    }  Exit:    return result;  }  FT_LOCAL_DEF( FT_Error )  T42_Size_Init( T42_Size  size )  {    FT_Face   face = size->root.face;    T42_Face  t42face = (T42_Face)face;    FT_Size   ttsize;    FT_Error  error   = T42_Err_Ok;    error = FT_New_Size( t42face->ttf_face, &ttsize );    size->ttsize = ttsize;    FT_Activate_Size( ttsize );    return error;  }  FT_LOCAL_DEF( void )  T42_Size_Done( T42_Size  size )  {    FT_Face      face    = size->root.face;    T42_Face     t42face = (T42_Face)face;    FT_ListNode  node;    node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize );    if ( node )    {      FT_Done_Size( size->ttsize );      size->ttsize = NULL;    }  }  FT_LOCAL_DEF( FT_Error )  T42_GlyphSlot_Init( T42_GlyphSlot  slot )  {    FT_Face       face    = slot->root.face;    T42_Face      t42face = (T42_Face)face;    FT_GlyphSlot  ttslot;    FT_Error      error   = T42_Err_Ok;    if ( face->glyph == NULL )    {      /* First glyph slot for this face */      slot->ttslot = t42face->ttf_face->glyph;    }    else    {      error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot );      slot->ttslot = ttslot;    }    return error;  }  FT_LOCAL_DEF( void )  T42_GlyphSlot_Done( T42_GlyphSlot slot )  {    FT_Face       face    = slot->root.face;    T42_Face      t42face = (T42_Face)face;    FT_GlyphSlot  cur     = t42face->ttf_face->glyph;    while ( cur )    {      if ( cur == slot->ttslot )      {        FT_Done_GlyphSlot( slot->ttslot );        break;      }      cur = cur->next;    }  }  FT_LOCAL_DEF( FT_Error )  T42_Size_SetChars( T42_Size    size,                     FT_F26Dot6  char_width,                     FT_F26Dot6  char_height,                     FT_UInt     horz_resolution,                     FT_UInt     vert_resolution )  {    FT_Face   face    = size->root.face;    T42_Face  t42face = (T42_Face)face;    FT_Activate_Size(size->ttsize);        return FT_Set_Char_Size( t42face->ttf_face,                             char_width,                             char_height,                             horz_resolution,                             vert_resolution );  }  FT_LOCAL_DEF( FT_Error )  T42_Size_SetPixels( T42_Size  size,                      FT_UInt   pixel_width,                      FT_UInt   pixel_height )  {    FT_Face   face    = size->root.face;    T42_Face  t42face = (T42_Face)face;    FT_Activate_Size(size->ttsize);        return FT_Set_Pixel_Sizes( t42face->ttf_face,                               pixel_width,                               pixel_height );  }  static void  ft_glyphslot_clear( FT_GlyphSlot  slot )  {    /* free bitmap if needed */    if ( slot->flags & FT_GLYPH_OWN_BITMAP )    {      FT_Memory  memory = FT_FACE_MEMORY( slot->face );      FT_FREE( slot->bitmap.buffer );      slot->flags &= ~FT_GLYPH_OWN_BITMAP;    }    /* clear all public fields in the glyph slot */    FT_ZERO( &slot->metrics );    FT_ZERO( &slot->outline );    FT_ZERO( &slot->bitmap );    slot->bitmap_left   = 0;    slot->bitmap_top    = 0;    slot->num_subglyphs = 0;    slot->subglyphs     = 0;    slot->control_data  = 0;    slot->control_len   = 0;    slot->other         = 0;    slot->format        = ft_glyph_format_none;    slot->linearHoriAdvance = 0;    slot->linearVertAdvance = 0;  }  FT_LOCAL_DEF( FT_Error )  T42_GlyphSlot_Load( FT_GlyphSlot  glyph,                      FT_Size       size,                      FT_Int        glyph_index,                      FT_Int        load_flags )  {    FT_Error         error;    T42_GlyphSlot    t42slot = (T42_GlyphSlot)glyph;    T42_Size         t42size = (T42_Size)size;    FT_Driver_Class  ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz;    ft_glyphslot_clear( t42slot->ttslot );    error = ttclazz->load_glyph( t42slot->ttslot,                                 t42size->ttsize,                                 glyph_index,                                 load_flags | FT_LOAD_NO_BITMAP );    if ( !error )    {      glyph->metrics = t42slot->ttslot->metrics;      glyph->linearHoriAdvance = t42slot->ttslot->linearHoriAdvance;      glyph->linearVertAdvance = t42slot->ttslot->linearVertAdvance;      glyph->format  = t42slot->ttslot->format;      glyph->outline = t42slot->ttslot->outline;      glyph->bitmap      = t42slot->ttslot->bitmap;      glyph->bitmap_left = t42slot->ttslot->bitmap_left;      glyph->bitmap_top  = t42slot->ttslot->bitmap_top;            glyph->num_subglyphs = t42slot->ttslot->num_subglyphs;      glyph->subglyphs     = t42slot->ttslot->subglyphs;            glyph->control_data  = t42slot->ttslot->control_data;      glyph->control_len   = t42slot->ttslot->control_len;    }    return error;  }  FT_LOCAL_DEF( FT_Long )  T42_CMap_CharNext( FT_CharMap  charmap,                     FT_Long     charcode )  {    T42_Face         face;    PSNames_Service  psnames;    face    = (T42_Face)charmap->face;    psnames = (PSNames_Service)face->psnames;    if ( psnames )      switch ( charmap->encoding )      {        /*******************************************************************/        /*                                                                 */        /* Unicode encoding support                                        */        /*                                                                 */      case ft_encoding_unicode:        /* use the `PSNames' module to synthetize the Unicode charmap */        return psnames->next_unicode( &face->unicode_map,                                      (FT_ULong)charcode );        /*******************************************************************/        /*                                                                 */        /* ISOLatin1 encoding support                                      */        /*                                                                 */      case ft_encoding_latin_1:        {          FT_ULong code;          /* use the `PSNames' module to synthetize the Unicode charmap */          code = psnames->next_unicode( &face->unicode_map,                                        (FT_ULong)charcode );          if ( code < 256 )            return code;          break;        }        /*******************************************************************/        /*                                                                 */        /* Custom Type 1 encoding                                          */        /*                                                                 */      case ft_encoding_adobe_custom:        {          T1_Encoding  encoding = &face->type1.encoding;          charcode++;          if ( charcode < encoding->code_first )            charcode = encoding->code_first;          while ( charcode <= encoding->code_last  ) {            if ( encoding->char_index[charcode] )              return charcode;            charcode++;          }        }        /*******************************************************************/        /*                                                                 */        /* Adobe Standard & Expert encoding support                        */        /*                                                                 */      default:        while ( ++charcode < 256 )        {          FT_UInt      code;          FT_Int       n;          const char*  glyph_name;          code = psnames->adobe_std_encoding[charcode];          if ( charmap->encoding == ft_encoding_adobe_expert )            code = psnames->adobe_expert_encoding[charcode];          glyph_name = psnames->adobe_std_strings( code );          if ( !glyph_name )            continue;          for ( n = 0; n < face->type1.num_glyphs; n++ )          {            const char*  gname = face->type1.glyph_names[n];            if ( gname && gname[0] == glyph_name[0]  &&                 ft_strcmp( gname, glyph_name ) == 0 )              return charcode;          }        }      }    return 0;  }/* END */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -