freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft] Possible Bug in FT_Get_FSType_Flags


From: Jun Dai
Subject: [ft] Possible Bug in FT_Get_FSType_Flags
Date: Wed, 17 Jun 2015 16:39:51 -0700

Deal FreeType Organization,

Thank you for this wonderful library. This is Jun Dai from Prevo Tech.

Currently I experience a strange behave from FT_Get_FSType_Flags call. I load a True Type font from system and use FT_Get_FSType_Flags call to check if this font is editable or not.  
According to FreeType document, the FT_GetFSType should return one of the FT_FSTYPE_XXX flag. But I receive a 1, which is not listed as any of those flags.
The test font is a restricted true type font. I was expecting a return of FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING flag.

 

The following is the testing code.
I am on windows 8.1 pro.
FreeType is 2.6 windows build.  

 

--- Start of Test Code ---

 

int _tmain(int argc, _TCHAR* argv[])

{

       //Free Type Library, it use to load font for library

       FT_Library _library = NULL;

 

       //initial Free Type library;

       FT_Error error = FT_Init_FreeType( &_library );

       if(error)

       {

             return 0;

       }

       //windows font, which is a restricted font

       const char* WINDOWSFONT = "C:\\Windows\\Fonts\\sanss___.ttf";

 

       //load file

       FILE* ffile = NULL;

       int errorcode = fopen_s(&ffile, WINDOWSFONT, "rb");

       if(errorcode == 0 && ffile != NULL)

       {

             //copy font file into memory

             fseek(ffile, 0, SEEK_END);

             int fontFileSize = ftell(ffile);

             fseek(ffile, 0, SEEK_SET);

             BYTE* fontFile = new BYTE[fontFileSize];

             int remain = fontFileSize;

             BYTE* tempbuff = fontFile;

             while(remain > 0)

             {

                    int rbyte = fread(tempbuff, 1, remain, ffile);

                    if(rbyte < 1) break;

                    remain -= rbyte;

                    tempbuff += remain;

             }

             fclose(ffile);

 

             //load font face.

             FT_Face fontface = NULL;

             error=FT_New_Memory_Face(_library, fontFile, fontFileSize, 0, &fontface);

             if (error || fontface ==NULL)

            

             {

                    return 0;

             }

             //check font type flag

             FT_UShort flag = FT_Get_FSType_Flags(fontface);

             switch(flag)

             {

                    case FT_FSTYPE_INSTALLABLE_EMBEDDING:

                    {//Fonts with no fsType bit set may be embedded and permanently installed on the remote system by an application.

                           printf("Font Type INSTALLABLE_EMBEDDING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING:

                    {//Fonts that have only this bit set must not be modified, embedded or exchanged in any manner without first obtaining

                     //permission of the font software copyright owner.

                           printf("Font Type RESTRICTED_LICENSE_EMBEDDING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING:

                    {//If this bit is set, the font may be embedded and temporarily loaded on the remote system. Documents

                     //containing Preview & Print fonts must be opened ‘read-only’; no edits can be applied to the document.

                           printf("Font Type PREVIEW_AND_PRINT_EMBEDDING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_EDITABLE_EMBEDDING:

                    {//If this bit is set, the font may be embedded but must only be installed temporarily on other systems.

                     //In contrast to Preview & Print fonts, documents containing editable fonts may be opened for reading,

                     //editing is permitted, and changes may be saved.

                           printf("Font Type EDITABLE_EMBEDDING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_NO_SUBSETTING:

                    {//If this bit is set, the font may not be subsetted prior to embedding.

                           printf("Font Type NO_SUBSETTING:  %d \n", flag);

                           break;

                    }

                    case FT_FSTYPE_BITMAP_EMBEDDING_ONLY:

                    {//If this bit is set, only bitmaps contained in the font may be embedded; no outline data may be embedded.

                    //If there are no bitmaps available in the font, then the font is unembeddable.

                           printf("Font Type BITMAP_EMBEDDING_ONLY:  %d \n", flag);

                           break;

                    }

                    default:

                    {

                           printf("Font Type unknow:  %d \n", flag);

                           break;

                    }

             }

 

             FT_Done_Face(fontface);

             fontface = NULL;

 

       }

 

       if(_library != NULL)

       {

             FT_Done_FreeType(_library);

             _library = NULL;

       }

       return 1;

}

 

--- End of Test Code ---

 

 

Thank you for your help

 

Jun Dai


reply via email to

[Prev in Thread] Current Thread [Next in Thread]