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

📄 sfobjs.c

📁 qt-embedded-2.3.8.tar.gz源码
💻 C
📖 第 1 页 / 共 2 页
字号:
      else        goto Exit;    }#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */    if ( LOAD_( hdmx )    ||         LOAD_( gasp )    ||         LOAD_( kerning ) ||         LOAD_( pclt )    )      goto Exit;#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE    if ( ( error = TT_Extension_Create( face ) ) != TT_Err_Ok )      goto Exit;#endif    face->root.family_name = Get_Name( face, TT_NAME_ID_FONT_FAMILY );    face->root.style_name  = Get_Name( face, TT_NAME_ID_FONT_SUBFAMILY );    /* now set up root fields */    {      FT_Face     root = &face->root;      FT_Int      flags = 0;      TT_CharMap  charmap;      FT_Int      n;      FT_Memory   memory;      memory = root->memory;      /*********************************************************************/      /*                                                                   */      /* Compute face flags.                                               */      /*                                                                   */      if ( has_outline == TRUE )        flags = FT_FACE_FLAG_SCALABLE;    /* scalable outlines */      flags |= FT_FACE_FLAG_SFNT      |   /* SFNT file format  */               FT_FACE_FLAG_HORIZONTAL;   /* horizontal data   */#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES      /* might need more polish to detect the presence of a Postscript */      /* name table in the font                                        */      flags |= FT_FACE_FLAG_GLYPH_NAMES;#endif      /* fixed width font? */      if ( face->postscript.isFixedPitch )        flags |= FT_FACE_FLAG_FIXED_WIDTH;      /* vertical information? */      if ( face->vertical_info )        flags |= FT_FACE_FLAG_VERTICAL;      /* kerning available ? */      if ( face->kern_pairs )        flags |= FT_FACE_FLAG_KERNING;      root->face_flags = flags;      /*********************************************************************/      /*                                                                   */      /* Compute style flags.                                              */      /*                                                                   */      flags = 0;      if ( has_outline == TRUE && face->os2.version != 0xFFFF )      {        /* we have an OS/2 table; use the `fsSelection' field */        if ( face->os2.fsSelection & 1 )          flags |= FT_STYLE_FLAG_ITALIC;        if ( face->os2.fsSelection & 32 )          flags |= FT_STYLE_FLAG_BOLD;      }      else      {        /* this is an old Mac font, use the header field */        if ( face->header.Mac_Style & 1 )          flags |= FT_STYLE_FLAG_BOLD;        if ( face->header.Mac_Style & 2 )          flags |= FT_STYLE_FLAG_ITALIC;      }      root->style_flags = flags;      /*********************************************************************/      /*                                                                   */      /* Polish the charmaps.                                              */      /*                                                                   */      /*   Try to set the charmap encoding according to the platform &     */      /*   encoding ID of each charmap.                                    */      /*                                                                   */      charmap            = face->charmaps;      root->num_charmaps = face->num_charmaps;      /* allocate table of pointers */      if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) )        goto Exit;      for ( n = 0; n < root->num_charmaps; n++, charmap++ )      {        FT_Int  platform = charmap->cmap.platformID;        FT_Int  encoding = charmap->cmap.platformEncodingID;        charmap->root.face        = (FT_Face)face;        charmap->root.platform_id = platform;        charmap->root.encoding_id = encoding;        charmap->root.encoding    = find_encoding( platform, encoding );        /* now, set root->charmap with a unicode charmap */        /* wherever available                            */        if ( !root->charmap                                &&             charmap->root.encoding == ft_encoding_unicode )          root->charmap = (FT_CharMap)charmap;        root->charmaps[n] = (FT_CharMap)charmap;      }#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS      if ( face->num_sbit_strikes )      {        root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;#if 0        /* I don't know criteria whether layout is horizontal or vertical */        if ( has_outline.... )        {          ...          root->face_flags |= FT_FACE_FLAG_VERTICAL;        }#endif        root->num_fixed_sizes = face->num_sbit_strikes;        if ( ALLOC_ARRAY( root->available_sizes,                          face->num_sbit_strikes,                          FT_Bitmap_Size ) )          goto Exit;        for ( n = 0 ; n < face->num_sbit_strikes ; n++ )        {          root->available_sizes[n].width =            face->sbit_strikes[n].x_ppem;          root->available_sizes[n].height =            face->sbit_strikes[n].y_ppem;        }      }      else#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */      {        root->num_fixed_sizes = 0;        root->available_sizes = 0;      }      /*********************************************************************/      /*                                                                   */      /*  Set up metrics.                                                  */      /*                                                                   */      if ( has_outline == TRUE )      {        /* XXX What about if outline header is missing */        /*     (e.g. sfnt wrapped outline)?            */        root->bbox.xMin    = face->header.xMin;        root->bbox.yMin    = face->header.yMin;        root->bbox.xMax    = face->header.xMax;        root->bbox.yMax    = face->header.yMax;        root->units_per_EM = face->header.Units_Per_EM;        /* XXX: Computing the ascender/descender/height is very different */        /*      from what the specification tells you.  Apparently, we    */        /*      must be careful because                                   */        /*                                                                */        /*      - not all fonts have an OS/2 table; in this case, we take */        /*        the values in the horizontal header.  However, these    */        /*        values very often are not reliable.                     */        /*                                                                */        /*      - otherwise, the correct typographic values are in the    */        /*        sTypoAscender, sTypoDescender & sTypoLineGap fields.    */        /*                                                                */        /*        However, certains fonts have these fields set to 0.     */        /*        Rather, they have usWinAscent & usWinDescent correctly  */        /*        set (but with different values).                        */        /*                                                                */        /*      As an example, Arial Narrow is implemented through four   */        /*      files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */        /*                                                                */        /*      Strangely, all fonts have the same values in their        */        /*      sTypoXXX fields, except ARIALNB which sets them to 0.     */        /*                                                                */        /*      On the other hand, they all have different                */        /*      usWinAscent/Descent values -- as a conclusion, the OS/2   */        /*      table cannot be used to compute the text height reliably! */        /*                                                                */        /* The ascender/descender/height are computed from the OS/2 table */        /* when found.  Otherwise, they're taken from the horizontal      */        /* header.                                                        */        /*                                                                */        root->ascender  = face->horizontal.Ascender;        root->descender = face->horizontal.Descender;        root->height    = root->ascender - root->descender +                          face->horizontal.Line_Gap;        /* if the line_gap is 0, we add an extra 15% to the text height --  */        /* this computation is based on various versions of Times New Roman */        if ( face->horizontal.Line_Gap == 0 )          root->height = ( root->height * 115 + 50 ) / 100;#if 0        /* some fonts have the OS/2 "sTypoAscender", "sTypoDescender" & */        /* "sTypoLineGap" fields set to 0, like ARIALNB.TTF             */        if ( face->os2.version != 0xFFFF && root->ascender )        {          FT_Int  height;          root->ascender  =  face->os2.sTypoAscender;          root->descender = -face->os2.sTypoDescender;          height = root->ascender + root->descender + face->os2.sTypoLineGap;          if ( height > root->height )            root->height = height;        }#endif /* 0 */        root->max_advance_width   = face->horizontal.advance_Width_Max;        root->max_advance_height  = face->vertical_info                                      ? face->vertical.advance_Height_Max                                      : root->height;        root->underline_position  = face->postscript.underlinePosition;        root->underline_thickness = face->postscript.underlineThickness;        /* root->max_points   -- already set up */        /* root->max_contours -- already set up */      }    }  Exit:    return error;  }#undef LOAD_  FT_LOCAL_DEF  void  SFNT_Done_Face( TT_Face  face )  {    FT_Memory        memory = face->root.memory;    SFNT_Interface*  sfnt   = (SFNT_Interface*)face->sfnt;    if ( sfnt )    {      /* destroy the postscript names table if it is loaded */      if ( sfnt->free_psnames )        sfnt->free_psnames( face );      /* destroy the embedded bitmaps table if it is loaded */      if ( sfnt->free_sbits )        sfnt->free_sbits( face );    }    /* freeing the kerning table */    FREE( face->kern_pairs );    face->num_kern_pairs = 0;    /* freeing the collection table */    FREE( face->ttc_header.offsets );    face->ttc_header.count = 0;    /* freeing table directory */    FREE( face->dir_tables );    face->num_tables = 0;    /* freeing the character mapping tables */    if ( sfnt && sfnt->load_charmaps )    {      FT_UShort  n;      for ( n = 0; n < face->num_charmaps; n++ )        sfnt->free_charmap( face, &face->charmaps[n].cmap );    }    FREE( face->charmaps );    face->num_charmaps = 0;    FREE( face->root.charmaps );    face->root.num_charmaps = 0;    face->root.charmap      = 0;    /* freeing the horizontal metrics */    FREE( face->horizontal.long_metrics );    FREE( face->horizontal.short_metrics );    /* freeing the vertical ones, if any */    if ( face->vertical_info )    {      FREE( face->vertical.long_metrics  );      FREE( face->vertical.short_metrics );      face->vertical_info = 0;    }    /* freeing the gasp table */    FREE( face->gasp.gaspRanges );    face->gasp.numRanges = 0;    /* freeing the name table */    sfnt->free_names( face );    /* freeing the hdmx table */    sfnt->free_hdmx( face );    /* freeing family and style name */    FREE( face->root.family_name );    FREE( face->root.style_name );    /* freeing sbit size table */    face->root.num_fixed_sizes = 0;    if ( face->root.available_sizes )      FREE( face->root.available_sizes );    face->sfnt = 0;  }/* END */

⌨️ 快捷键说明

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