Example #1
0
File: winfnt.c Project: 1tgr/mobius
static void
FNT_Face_Done( FNT_Face  face )
{
    FT_Memory  memory = FT_FACE_MEMORY( face );


    fnt_font_done( face );

    FT_FREE( face->root.available_sizes );
    face->root.num_fixed_sizes = 0;
}
Example #2
0
  static void
  fnt_face_done_fonts( FNT_Face  face )
  {
    FT_Memory  memory = FT_FACE(face)->memory;
    FT_Stream  stream = FT_FACE(face)->stream;
    FNT_Font*  cur    = face->fonts;
    FNT_Font*  limit  = cur + face->num_fonts;


    for ( ; cur < limit; cur++ )
      fnt_font_done( cur, stream );

    FREE( face->fonts );
    face->num_fonts = 0;
  }
Example #3
0
File: winfnt.c Project: 1tgr/mobius
static FT_Error
fnt_face_get_dll_font( FNT_Face  face,
                       FT_Int    face_index )
{
    FT_Error         error;
    FT_Stream        stream = FT_FACE( face )->stream;
    FT_Memory        memory = FT_FACE( face )->memory;
    WinMZ_HeaderRec  mz_header;


    face->font = 0;

    /* does it begin with an MZ header? */
    if ( FT_STREAM_SEEK( 0 )                                      ||
            FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
        goto Exit;

    error = FNT_Err_Unknown_File_Format;
    if ( mz_header.magic == WINFNT_MZ_MAGIC )
    {
        /* yes, now look for an NE header in the file */
        WinNE_HeaderRec  ne_header;


        if ( FT_STREAM_SEEK( mz_header.lfanew )                       ||
                FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )
            goto Exit;

        error = FNT_Err_Unknown_File_Format;
        if ( ne_header.magic == WINFNT_NE_MAGIC )
        {
            /* good, now look into the resource table for each FNT resource */
            FT_ULong   res_offset  = mz_header.lfanew +
                                     ne_header.resource_tab_offset;
            FT_UShort  size_shift;
            FT_UShort  font_count  = 0;
            FT_ULong   font_offset = 0;


            if ( FT_STREAM_SEEK( res_offset )                    ||
                    FT_FRAME_ENTER( ne_header.rname_tab_offset -
                                    ne_header.resource_tab_offset ) )
                goto Exit;

            size_shift = FT_GET_USHORT_LE();

            for (;;)
            {
                FT_UShort  type_id, count;


                type_id = FT_GET_USHORT_LE();
                if ( !type_id )
                    break;

                count = FT_GET_USHORT_LE();

                if ( type_id == 0x8008U )
                {
                    font_count  = count;
                    font_offset = (FT_ULong)( FT_STREAM_POS() + 4 +
                                              ( stream->cursor - stream->limit ) );
                    break;
                }

                stream->cursor += 4 + count * 12;
            }

            FT_FRAME_EXIT();

            if ( !font_count || !font_offset )
            {
                FT_TRACE2(( "this file doesn't contain any FNT resources!\n" ));
                error = FNT_Err_Unknown_File_Format;
                goto Exit;
            }

            face->root.num_faces = font_count;

            if ( face_index >= font_count )
            {
                error = FNT_Err_Bad_Argument;
                goto Exit;
            }

            if ( FT_NEW( face->font ) )
                goto Exit;

            if ( FT_STREAM_SEEK( font_offset + face_index * 12 ) ||
                    FT_FRAME_ENTER( 12 )                            )
                goto Fail;

            face->font->offset     = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
            face->font->fnt_size   = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
            face->font->size_shift = size_shift;

            stream->cursor += 8;

            FT_FRAME_EXIT();

            error = fnt_font_load( face->font, stream );
        }
    }

Fail:
    if ( error )
        fnt_font_done( face );

Exit:
    return error;
}