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

📄 ftglyph.c

📁 qt-embedded-2.3.8.tar.gz源码
💻 C
📖 第 1 页 / 共 2 页
字号:
    (FT_Glyph_Init_Func)     ft_outline_glyph_init,    (FT_Glyph_Done_Func)     ft_outline_glyph_done,    (FT_Glyph_Copy_Func)     ft_outline_glyph_copy,    (FT_Glyph_Transform_Func)ft_outline_glyph_transform,    (FT_Glyph_BBox_Func)     ft_outline_glyph_bbox,    (FT_Glyph_Prepare_Func)  ft_outline_glyph_prepare  };  /*************************************************************************/  /*************************************************************************/  /****                                                                 ****/  /****   FT_Glyph class and API                                        ****/  /****                                                                 ****/  /*************************************************************************/  /*************************************************************************/   static   FT_Error  ft_new_glyph( FT_Library             library,                           const FT_Glyph_Class*  clazz,                           FT_Glyph*              aglyph )   {     FT_Memory  memory = library->memory;     FT_Error   error;     FT_Glyph   glyph;     *aglyph = 0;     if ( !ALLOC( glyph, clazz->glyph_size ) )     {       glyph->library = library;       glyph->clazz   = clazz;       glyph->format  = clazz->glyph_format;       *aglyph = glyph;     }     return error;   }  /* documentation is in ftglyph.h */  FT_EXPORT_DEF( FT_Error )  FT_Glyph_Copy( FT_Glyph   source,                                            FT_Glyph  *target )  {    FT_Glyph               copy;    FT_Error               error;    const FT_Glyph_Class*  clazz;    /* check arguments */    if ( !target || !source || !source->clazz )    {      error = FT_Err_Invalid_Argument;      goto Exit;    }    *target = 0;    clazz = source->clazz;    error = ft_new_glyph( source->library, clazz, &copy );    if ( error )      goto Exit;    if ( clazz->glyph_copy )      error = clazz->glyph_copy( source, copy );    if ( error )      FT_Done_Glyph( copy );    else      *target = copy;  Exit:    return error;  }  /* documentation is in ftglyph.h */  FT_EXPORT_DEF( FT_Error )  FT_Get_Glyph( FT_GlyphSlot  slot,                                           FT_Glyph     *aglyph )  {    FT_Library  library = slot->library;    FT_Error    error;    FT_Glyph    glyph;    const FT_Glyph_Class*  clazz = 0;    if ( !slot )      return FT_Err_Invalid_Slot_Handle;    if ( !aglyph )      return FT_Err_Invalid_Argument;    /* if it is a bitmap, that's easy :-) */    if ( slot->format == ft_glyph_format_bitmap )      clazz = &ft_bitmap_glyph_class;    /* it it is an outline too */    else if ( slot->format == ft_glyph_format_outline )      clazz = &ft_outline_glyph_class;    else    {      /* try to find a renderer that supports the glyph image format */      FT_Renderer  render = FT_Lookup_Renderer( library, slot->format, 0 );      if ( render )        clazz = &render->glyph_class;    }    if ( !clazz )    {      error = FT_Err_Invalid_Glyph_Format;      goto Exit;    }    /* create FT_Glyph object */    error = ft_new_glyph( library, clazz, &glyph );    if ( error )      goto Exit;    /* copy advance while converting it to 16.16 format */    glyph->advance.x = slot->advance.x << 10;    glyph->advance.y = slot->advance.y << 10;    /* now import the image from the glyph slot */    error = clazz->glyph_init( glyph, slot );    /* if an error occurred, destroy the glyph */    if ( error )      FT_Done_Glyph( glyph );    else      *aglyph = glyph;  Exit:    return error;  }  /* documentation is in ftglyph.h */  FT_EXPORT_DEF( FT_Error )  FT_Glyph_Transform( FT_Glyph    glyph,                                                 FT_Matrix*  matrix,                                                 FT_Vector*  delta )  {    const FT_Glyph_Class*  clazz;    FT_Error               error = FT_Err_Ok;    if ( !glyph || !glyph->clazz )      error = FT_Err_Invalid_Argument;    else    {      clazz = glyph->clazz;      if ( clazz->glyph_transform )      {        /* transform glyph image */        clazz->glyph_transform( glyph, matrix, delta );        /* transform advance vector */        if ( matrix )          FT_Vector_Transform( &glyph->advance, matrix );      }      else        error = FT_Err_Invalid_Glyph_Format;    }    return error;  }  /* documentation is in ftglyph.h */  FT_EXPORT_DEF( void )  FT_Glyph_Get_CBox( FT_Glyph  glyph,                                            FT_UInt   bbox_mode,                                            FT_BBox  *acbox )  {    const FT_Glyph_Class*  clazz;    FT_Error               error = FT_Err_Ok;    if ( !acbox || !glyph || !glyph->clazz )      error = FT_Err_Invalid_Argument;    else    {      clazz = glyph->clazz;      if ( !clazz->glyph_bbox )        error = FT_Err_Invalid_Glyph_Format;      else      {        /* retrieve bbox in 26.6 coordinates */        clazz->glyph_bbox( glyph, acbox );        /* perform grid fitting if needed */        if ( bbox_mode & ft_glyph_bbox_gridfit )        {          acbox->xMin &= -64;          acbox->yMin &= -64;          acbox->xMax  = ( acbox->xMax + 63 ) & -64;          acbox->yMax  = ( acbox->yMax + 63 ) & -64;        }        /* convert to integer pixels if needed */        if ( bbox_mode & ft_glyph_bbox_truncate )        {          acbox->xMin >>= 6;          acbox->yMin >>= 6;          acbox->xMax >>= 6;          acbox->yMax >>= 6;        }      }    }    return;  }  /* documentation is in ftglyph.h */  FT_EXPORT_DEF( FT_Error )  FT_Glyph_To_Bitmap( FT_Glyph*   the_glyph,                                                 FT_ULong    render_mode,                                                 FT_Vector*  origin,                                                 FT_Bool     destroy )  {    FT_GlyphSlotRec  dummy;    FT_Error         error;    FT_Glyph         glyph;    FT_BitmapGlyph   bitmap;    const FT_Glyph_Class*  clazz;    /* check argument */    if ( !the_glyph )      goto Bad;    /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */    /* then calling FT_Render_Glyph_Internal()                            */    glyph = *the_glyph;    if ( !glyph )      goto Bad;    clazz = glyph->clazz;    if ( !clazz || !clazz->glyph_prepare )      goto Bad;    MEM_Set( &dummy, 0, sizeof ( dummy ) );    dummy.library = glyph->library;    dummy.format  = clazz->glyph_format;    /* if `origin' is set, translate the glyph image */    if ( origin )      FT_Glyph_Transform( glyph, 0, origin );    /* create result bitmap glyph */    error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class,                          (FT_Glyph*)&bitmap );    if ( error )      goto Exit;    /* prepare dummy slot for rendering */    error = clazz->glyph_prepare( glyph, &dummy );    if ( !error )      error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );    if ( !destroy && origin )    {      FT_Vector  v;      v.x = -origin->x;      v.y = -origin->y;      FT_Glyph_Transform( glyph, 0, &v );    }    /* in case of success, copy the bitmap to the glyph bitmap */    if ( !error )    {      error = ft_bitmap_glyph_init( bitmap, &dummy );      if ( error )      {        /* this should never happen, but let's be safe */        FT_Done_Glyph( FT_GLYPH( bitmap ) );        goto Exit;      }      /* copy advance */      bitmap->root.advance = glyph->advance;      if ( destroy )        FT_Done_Glyph( glyph );      *the_glyph = FT_GLYPH( bitmap );    }  Exit:    return error;  Bad:    error = FT_Err_Invalid_Argument;    goto Exit;  }  /* documentation is in ftglyph.h */  FT_EXPORT_DEF( void )  FT_Done_Glyph( FT_Glyph  glyph )  {    if ( glyph )    {      FT_Memory              memory = glyph->library->memory;      const FT_Glyph_Class*  clazz  = glyph->clazz;      if ( clazz->glyph_done )        clazz->glyph_done( glyph );      FREE( glyph );    }  }/* END */

⌨️ 快捷键说明

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