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

📄 pcfread.c

📁 奇趣公司比较新的qt/emd版本
💻 C
📖 第 1 页 / 共 3 页
字号:
    {      encoding[i].enc   = tmpEncoding[i].enc;      encoding[i].glyph = tmpEncoding[i].glyph;    }    face->nencodings = j;    face->encodings  = encoding;    FT_FREE( tmpEncoding );    return error;  Bail:    FT_FREE( encoding );    FT_FREE( tmpEncoding );    return error;  }  static  const FT_Frame_Field  pcf_accel_header[] =  {#undef  FT_STRUCTURE#define FT_STRUCTURE  PCF_AccelRec    FT_FRAME_START( 20 ),      FT_FRAME_BYTE      ( noOverlap ),      FT_FRAME_BYTE      ( constantMetrics ),      FT_FRAME_BYTE      ( terminalFont ),      FT_FRAME_BYTE      ( constantWidth ),      FT_FRAME_BYTE      ( inkInside ),      FT_FRAME_BYTE      ( inkMetrics ),      FT_FRAME_BYTE      ( drawDirection ),      FT_FRAME_SKIP_BYTES( 1 ),      FT_FRAME_LONG_LE   ( fontAscent ),      FT_FRAME_LONG_LE   ( fontDescent ),      FT_FRAME_LONG_LE   ( maxOverlap ),    FT_FRAME_END  };  static  const FT_Frame_Field  pcf_accel_msb_header[] =  {#undef  FT_STRUCTURE#define FT_STRUCTURE  PCF_AccelRec    FT_FRAME_START( 20 ),      FT_FRAME_BYTE      ( noOverlap ),      FT_FRAME_BYTE      ( constantMetrics ),      FT_FRAME_BYTE      ( terminalFont ),      FT_FRAME_BYTE      ( constantWidth ),      FT_FRAME_BYTE      ( inkInside ),      FT_FRAME_BYTE      ( inkMetrics ),      FT_FRAME_BYTE      ( drawDirection ),      FT_FRAME_SKIP_BYTES( 1 ),      FT_FRAME_LONG      ( fontAscent ),      FT_FRAME_LONG      ( fontDescent ),      FT_FRAME_LONG      ( maxOverlap ),    FT_FRAME_END  };  static FT_Error  pcf_get_accel( FT_Stream  stream,                 PCF_Face   face,                 FT_ULong   type )  {    FT_ULong   format, size;    FT_Error   error = PCF_Err_Ok;    PCF_Accel  accel = &face->accel;    error = pcf_seek_to_table_type( stream,                                    face->toc.tables,                                    face->toc.count,                                    type,                                    &format,                                    &size );    if ( error )      goto Bail;    if ( FT_READ_ULONG_LE( format ) )      goto Bail;    if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT )    &&         !PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )      goto Bail;    if ( PCF_BYTE_ORDER( format ) == MSBFirst )    {      if ( FT_STREAM_READ_FIELDS( pcf_accel_msb_header, accel ) )        goto Bail;    }    else    {      if ( FT_STREAM_READ_FIELDS( pcf_accel_header, accel ) )        goto Bail;    }    error = pcf_get_metric( stream,                            format & ( ~PCF_FORMAT_MASK ),                            &(accel->minbounds) );    if ( error )      goto Bail;    error = pcf_get_metric( stream,                            format & ( ~PCF_FORMAT_MASK ),                            &(accel->maxbounds) );    if ( error )      goto Bail;    if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )    {      error = pcf_get_metric( stream,                              format & ( ~PCF_FORMAT_MASK ),                              &(accel->ink_minbounds) );      if ( error )        goto Bail;      error = pcf_get_metric( stream,                              format & ( ~PCF_FORMAT_MASK ),                              &(accel->ink_maxbounds) );      if ( error )        goto Bail;    }    else    {      accel->ink_minbounds = accel->minbounds; /* I'm not sure about this */      accel->ink_maxbounds = accel->maxbounds;    }  Bail:    return error;  }  static FT_Error  pcf_interpret_style( PCF_Face  pcf )  {    FT_Error   error  = PCF_Err_Ok;    FT_Face    face   = FT_FACE( pcf );    FT_Memory  memory = face->memory;    PCF_Property  prop;    int    nn, len;    char*  strings[4] = { NULL, NULL, NULL, NULL };    int    lengths[4];    face->style_flags = 0;    prop = pcf_find_property( pcf, "SLANT" );    if ( prop && prop->isString                                       &&         ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ||           *(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )    {      face->style_flags |= FT_STYLE_FLAG_ITALIC;      strings[2] = ( *(prop->value.atom) == 'O' ||                     *(prop->value.atom) == 'o' ) ? (char *)"Oblique"                                                  : (char *)"Italic";    }    prop = pcf_find_property( pcf, "WEIGHT_NAME" );    if ( prop && prop->isString                                       &&         ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )    {      face->style_flags |= FT_STYLE_FLAG_BOLD;      strings[1] = (char *)"Bold";    }    prop = pcf_find_property( pcf, "SETWIDTH_NAME" );    if ( prop && prop->isString                                        &&         *(prop->value.atom)                                           &&         !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )      strings[3] = (char *)(prop->value.atom);    prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );    if ( prop && prop->isString                                        &&         *(prop->value.atom)                                           &&         !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )      strings[0] = (char *)(prop->value.atom);    for ( len = 0, nn = 0; nn < 4; nn++ )    {      lengths[nn] = 0;      if ( strings[nn] )      {        lengths[nn] = ft_strlen( strings[nn] );        len        += lengths[nn] + 1;      }    }    if ( len == 0 )    {      strings[0] = (char *)"Regular";      lengths[0] = ft_strlen( strings[0] );      len        = lengths[0] + 1;    }    {      char*  s;      if ( FT_ALLOC( face->style_name, len ) )        return error;      s = face->style_name;      for ( nn = 0; nn < 4; nn++ )      {        char*  src = strings[nn];        len = lengths[nn];        if ( src == NULL )          continue;        /* separate elements with a space */        if ( s != face->style_name )          *s++ = ' ';        ft_memcpy( s, src, len );        /* need to convert spaces to dashes for */        /* add_style_name and setwidth_name     */        if ( nn == 0 || nn == 3 )        {          int  mm;          for ( mm = 0; mm < len; mm++ )            if (s[mm] == ' ')              s[mm] = '-';        }        s += len;      }      *s = 0;    }    return error;  }  FT_LOCAL_DEF( FT_Error )  pcf_load_font( FT_Stream  stream,                 PCF_Face   face )  {    FT_Error   error  = PCF_Err_Ok;    FT_Memory  memory = FT_FACE(face)->memory;    FT_Bool    hasBDFAccelerators;    error = pcf_read_TOC( stream, face );    if ( error )      goto Exit;    error = pcf_get_properties( stream, face );    if ( error )      goto Exit;    /* Use the old accelerators if no BDF accelerators are in the file. */    hasBDFAccelerators = pcf_has_table_type( face->toc.tables,                                             face->toc.count,                                             PCF_BDF_ACCELERATORS );    if ( !hasBDFAccelerators )    {      error = pcf_get_accel( stream, face, PCF_ACCELERATORS );      if ( error )        goto Exit;    }    /* metrics */    error = pcf_get_metrics( stream, face );    if ( error )      goto Exit;    /* bitmaps */    error = pcf_get_bitmaps( stream, face );    if ( error )      goto Exit;    /* encodings */    error = pcf_get_encodings( stream, face );    if ( error )      goto Exit;    /* BDF style accelerators (i.e. bounds based on encoded glyphs) */    if ( hasBDFAccelerators )    {      error = pcf_get_accel( stream, face, PCF_BDF_ACCELERATORS );      if ( error )        goto Exit;    }    /* XXX: TO DO: inkmetrics and glyph_names are missing */    /* now construct the face object */    {      FT_Face       root = FT_FACE( face );      PCF_Property  prop;      root->num_faces  = 1;      root->face_index = 0;      root->face_flags = FT_FACE_FLAG_FIXED_SIZES |                         FT_FACE_FLAG_HORIZONTAL  |                         FT_FACE_FLAG_FAST_GLYPHS;      if ( face->accel.constantWidth )        root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;      if ( ( error = pcf_interpret_style( face ) ) != 0 )         goto Exit;      prop = pcf_find_property( face, "FAMILY_NAME" );      if ( prop && prop->isString )      {        if ( FT_STRDUP( root->family_name, prop->value.atom ) )          goto Exit;      }      else        root->family_name = NULL;      /*       * Note: We shift all glyph indices by +1 since we must       * respect the convention that glyph 0 always corresponds       * to the `missing glyph'.       *       * This implies bumping the number of `available' glyphs by 1.       */      root->num_glyphs = face->nmetrics + 1;      root->num_fixed_sizes = 1;      if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )        goto Exit;      {        FT_Bitmap_Size*  bsize = root->available_sizes;        FT_Short         resolution_x = 0, resolution_y = 0;        FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );#if 0        bsize->height = face->accel.maxbounds.ascent << 6;#endif        bsize->height = (FT_Short)( face->accel.fontAscent +                                    face->accel.fontDescent );        prop = pcf_find_property( face, "AVERAGE_WIDTH" );        if ( prop )          bsize->width = (FT_Short)( ( prop->value.integer + 5 ) / 10 );        else          bsize->width = (FT_Short)( bsize->height * 2/3 );        prop = pcf_find_property( face, "POINT_SIZE" );        if ( prop )          /* convert from 722.7 decipoints to 72 points per inch */          bsize->size =            (FT_Pos)( ( prop->value.integer * 64 * 7200 + 36135L ) / 72270L );        prop = pcf_find_property( face, "PIXEL_SIZE" );        if ( prop )          bsize->y_ppem = (FT_Short)prop->value.integer << 6;        prop = pcf_find_property( face, "RESOLUTION_X" );        if ( prop )          resolution_x = (FT_Short)prop->value.integer;        prop = pcf_find_property( face, "RESOLUTION_Y" );        if ( prop )          resolution_y = (FT_Short)prop->value.integer;        if ( bsize->y_ppem == 0 )        {          bsize->y_ppem = bsize->size;          if ( resolution_y )            bsize->y_ppem = bsize->y_ppem * resolution_y / 72;        }        if ( resolution_x && resolution_y )          bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y;        else          bsize->x_ppem = bsize->y_ppem;      }      /* set up charset */      {        PCF_Property  charset_registry = 0, charset_encoding = 0;        charset_registry = pcf_find_property( face, "CHARSET_REGISTRY" );        charset_encoding = pcf_find_property( face, "CHARSET_ENCODING" );        if ( charset_registry && charset_registry->isString &&             charset_encoding && charset_encoding->isString )        {          if ( FT_STRDUP( face->charset_encoding,                          charset_encoding->value.atom ) ||               FT_STRDUP( face->charset_registry,                          charset_registry->value.atom ) )            goto Exit;        }      }    }  Exit:    if ( error )    {      /* This is done to respect the behaviour of the original */      /* PCF font driver.                                      */      error = PCF_Err_Invalid_File_Format;    }    return error;  }/* END */

⌨️ 快捷键说明

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