|
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. The following is the testing code. --- 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 |
[Prev in Thread] | Current Thread | [Next in Thread] |