tenpoku1000/UEFI_FreeType_MSVC

__stdio_seek.c have a bug

Closed this issue · 1 comments

The __stdio_seek function need to implove,like this

off_t __stdio_seek(FILE *f, off_t off, int whence)
{
#if !defined(_DEBUG)
    if ((NULL == f) || (NULL == f->efi_file) ||
        ((SEEK_SET != whence) && (SEEK_CUR != whence) && (SEEK_END != whence))){

        errno = EINVAL;

        return -1;
    }

    EFI_FILE* efi_file = f->efi_file;

    EFI_STATUS status = EFI_SUCCESS;

    switch (whence){
    case SEEK_SET:
        status = efi_file->SetPosition(efi_file, off);
        break;
    case SEEK_CUR:
    {
        UINT64 nPos = 0;
        status = efi_file->GetPosition(efi_file, &nPos);
        if (!EFI_ERROR(status))
        {
            nPos += off;
            status = efi_file->SetPosition(efi_file, nPos);
        }
    }
    break;
    case SEEK_END:
    {
        //seek end
        status = efi_file->SetPosition(efi_file, 0xFFFFFFFFFFFFFFFF);
        if (off != 0)
        {
            UINT64 nPos = 0;
            EFI_STATUS status = efi_file->GetPosition(f->efi_file, &nPos);
            if (!EFI_ERROR(status))
            {
                nPos += off;
                status = efi_file->SetPosition(efi_file, nPos);
            }
        }

    }
    break;
    }

    if (EFI_ERROR(status)){

        errno = EBADF;

        return -1;
    }
#else
    if ((NULL == f) || (NULL == f->win64_file) ||
        ((SEEK_SET != whence) && (SEEK_CUR != whence) && (SEEK_END != whence))){

        errno = EINVAL;

        return -1;
    }

    int status = set_file_pointer_ex_seek(f->win64_file, off, whence);

    if (FALSE == status){

        errno = EBADF;

        return -1;
    }
#endif

    return 0;
}

So we can use FT_New_Face to initialize freetype library not FT_New_Memory_Face

FT_Error err = FT_New_Face(*library,"\\EFI\\BOOT\\FONTS\\SourceHanSans-Normal.ttc", 0, face);

We have fixed the bug you pointed out. Thank you for your cooperation.

The following is the original text in Japanese.

ご指摘のバグを修正しました。ご協力感謝いたします。