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

📄 winfnt.c

📁 qt-embedded-2.3.8.tar.gz源码
💻 C
📖 第 1 页 / 共 2 页
字号:
                           FNT_Face       face,                           FT_Int         face_index,                           FT_Int         num_params,                           FT_Parameter*  params )  {    FT_Error   error;    FT_Memory  memory = FT_FACE_MEMORY( face );    FT_UNUSED( num_params );    FT_UNUSED( params );    FT_UNUSED( face_index );    /* try to load several fonts from a DLL */    error = fnt_get_dll_fonts( face );    if ( error )    {      /* this didn't work, now try to load a single FNT font */      FNT_Font*  font;      if ( ALLOC( face->fonts, sizeof ( *face->fonts ) ) )        goto Exit;      face->num_fonts = 1;      font            = face->fonts;      font->offset   = 0;      font->fnt_size = stream->size;      error = fnt_load_font( stream, font );      if ( error )        goto Fail;    }    /* all right, one or more fonts were loaded; we now need to */    /* fill the root FT_Face fields with relevant information   */    {      FT_Face    root  = FT_FACE( face );      FNT_Font*  fonts = face->fonts;      FNT_Font*  limit = fonts + face->num_fonts;      FNT_Font*  cur;      root->num_faces  = 1;      root->face_flags = FT_FACE_FLAG_FIXED_SIZES |                         FT_FACE_FLAG_HORIZONTAL;      if ( fonts->header.avg_width == fonts->header.max_width )        root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;      if ( fonts->header.italic )        root->style_flags |= FT_STYLE_FLAG_ITALIC;      if ( fonts->header.weight >= 800 )        root->style_flags |= FT_STYLE_FLAG_BOLD;      /* Setup the `fixed_sizes' array */      if ( ALLOC_ARRAY( root->available_sizes, face->num_fonts,                        FT_Bitmap_Size ) )        goto Fail;      root->num_fixed_sizes = face->num_fonts;      {        FT_Bitmap_Size*  size = root->available_sizes;        for ( cur = fonts; cur < limit; cur++, size++ )        {          size->width  = cur->header.pixel_width;          size->height = cur->header.pixel_height;        }      }      /* Setup the `charmaps' array */      root->charmaps     = &face->charmap_handle;      root->num_charmaps = 1;      face->charmap.encoding    = ft_encoding_unicode;      face->charmap.platform_id = 3;      face->charmap.encoding_id = 1;      face->charmap.face        = root;      face->charmap_handle = &face->charmap;      root->charmap = face->charmap_handle;      /* setup remaining flags */      root->num_glyphs = fonts->header.last_char -                         fonts->header.first_char + 1;      root->family_name = (FT_String*)fonts->fnt_frame +                          fonts->header.face_name_offset;      root->style_name  = (char *)"Regular";      if ( root->style_flags & FT_STYLE_FLAG_BOLD )      {        if ( root->style_flags & FT_STYLE_FLAG_ITALIC )          root->style_name = (char *)"Bold Italic";        else          root->style_name = (char *)"Bold";      }      else if ( root->style_flags & FT_STYLE_FLAG_ITALIC )        root->style_name = (char *)"Italic";    }  Fail:    if ( error )      FNT_Done_Face( face );  Exit:    return error;  }  static  FT_Error  FNT_Set_Pixel_Size( FNT_Size  size )  {    /* look up a font corresponding to the current pixel size */    FNT_Face   face  = (FNT_Face)FT_SIZE_FACE( size );    FNT_Font*  cur   = face->fonts;    FNT_Font*  limit = cur + face->num_fonts;    size->font = 0;    for ( ; cur < limit; cur++ )    {      /* we only compare the character height, as fonts used some strange */      /* values                                                           */      if ( cur->header.pixel_height == size->root.metrics.y_ppem )      {        size->font = cur;        size->root.metrics.ascender  = cur->header.ascent * 64;        size->root.metrics.descender = ( cur->header.pixel_height -                                           cur->header.ascent ) * 64;        size->root.metrics.height    = cur->header.pixel_height * 64;        break;      }    }    return ( size->font ? FT_Err_Ok : FT_Err_Invalid_Pixel_Size );  }  static  FT_UInt  FNT_Get_Char_Index( FT_CharMap  charmap,                               FT_ULong    char_code )  {    FT_UInt  result = char_code;    if ( charmap )    {      FNT_Font*  font  = ((FNT_Face)charmap->face)->fonts;      FT_UInt    first = font->header.first_char;      FT_UInt    count = font->header.last_char - first + 1;      char_code -= first;      if ( char_code < count )        result = char_code + 1;      else        result = 0;    }    return result;  }  static  FT_Error  FNT_Load_Glyph( FT_GlyphSlot  slot,                            FNT_Size      size,                            FT_UInt       glyph_index,                            FT_Int        load_flags )  {    FNT_Font*   font  = size->font;    FT_Error    error = 0;    FT_Byte*    p;    FT_Int      len;    FT_Bitmap*  bitmap = &slot->bitmap;    FT_ULong    offset;    FT_Bool     new_format;    FT_UNUSED( slot );    FT_UNUSED( load_flags );    if ( !font )    {      error = FT_Err_Invalid_Argument;      goto Exit;    }    if ( glyph_index > 0 )      glyph_index--;    else      glyph_index = font->header.default_char - font->header.first_char;    new_format = font->header.version == 0x300;    len        = new_format ? 6 : 4;    /* jump to glyph entry */    p = font->fnt_frame + 118 + len * glyph_index;    bitmap->width = NEXT_ShortLE(p);    if ( new_format )      offset = NEXT_ULongLE(p);    else      offset = NEXT_UShortLE(p);    /* jump to glyph data */    p = font->fnt_frame + /* font->header.bits_offset */ + offset;    /* allocate and build bitmap */    {      FT_Memory  memory = FT_FACE_MEMORY( slot->face );      FT_Int     pitch  = ( bitmap->width + 7 ) >> 3;      FT_Byte*   column;      FT_Byte*   write;      bitmap->pitch      = pitch;      bitmap->rows       = font->header.pixel_height;      bitmap->pixel_mode = ft_pixel_mode_mono;      if ( ALLOC( bitmap->buffer, pitch * bitmap->rows ) )        goto Exit;      column = (FT_Byte*)bitmap->buffer;      for ( ; pitch > 0; pitch--, column++ )      {        FT_Byte*  limit = p + bitmap->rows;        for ( write = column; p < limit; p++, write += bitmap->pitch )          write[0] = p[0];      }    }    slot->flags       = ft_glyph_own_bitmap;    slot->bitmap_left = 0;    slot->bitmap_top  = font->header.ascent;    slot->format      = ft_glyph_format_bitmap;    /* now set up metrics */    slot->metrics.horiAdvance  = bitmap->width << 6;    slot->metrics.horiBearingX = 0;    slot->metrics.horiBearingY = slot->bitmap_top << 6;    slot->linearHoriAdvance    = (FT_Fixed)bitmap->width << 16;  Exit:    return error;  }  FT_CALLBACK_TABLE_DEF  const FT_Driver_Class  winfnt_driver_class =  {    {      ft_module_font_driver,      sizeof ( FT_DriverRec ),      "winfonts",      0x10000L,      0x20000L,      0,      (FT_Module_Constructor)0,      (FT_Module_Destructor) 0,      (FT_Module_Requester)  0    },    sizeof( FNT_FaceRec ),    sizeof( FNT_SizeRec ),    sizeof( FT_GlyphSlotRec ),    (FTDriver_initFace)     FNT_Init_Face,    (FTDriver_doneFace)     FNT_Done_Face,    (FTDriver_initSize)     0,    (FTDriver_doneSize)     0,    (FTDriver_initGlyphSlot)0,    (FTDriver_doneGlyphSlot)0,    (FTDriver_setCharSizes) FNT_Set_Pixel_Size,    (FTDriver_setPixelSizes)FNT_Set_Pixel_Size,    (FTDriver_loadGlyph)    FNT_Load_Glyph,    (FTDriver_getCharIndex) FNT_Get_Char_Index,    (FTDriver_getKerning)   0,    (FTDriver_attachFile)   0,    (FTDriver_getAdvances)  0  };#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    getDriverClass                                                     */  /*                                                                       */  /* <Description>                                                         */  /*    This function is used when compiling the TrueType driver as a      */  /*    shared library (`.DLL' or `.so').  It will be used by the          */  /*    high-level library of FreeType to retrieve the address of the      */  /*    driver's generic interface.                                        */  /*                                                                       */  /*    It shouldn't be implemented in a static build, as each driver must */  /*    have the same function as an exported entry point.                 */  /*                                                                       */  /* <Return>                                                              */  /*    The address of the TrueType's driver generic interface.  The       */  /*    format-specific interface can then be retrieved through the method */  /*    interface->get_format_interface.                                   */  /*                                                                       */  FT_EXPORT_DEF( const FT_Driver_Class* )  getDriverClass( void )  {    return &winfnt_driver_class;  }#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS *//* END */

⌨️ 快捷键说明

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