Created
January 12, 2011 13:03
-
-
Save jjgod/776136 to your computer and use it in GitHub Desktop.
Testing font unicode coverage info with FreeType OS/2 table, not very reliable though
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ft2build.h> | |
#include FT_FREETYPE_H | |
#include <freetype/tttables.h> | |
const char *rangeForBit(int i) | |
{ | |
switch (i) | |
{ | |
case 43: | |
return "Box Drawing"; | |
case 48: | |
return "CJK Symbols And Punctuation"; | |
case 49: | |
return "Hiragana"; | |
case 50: | |
return "Katakana"; | |
case 51: | |
return "Bopomofo"; | |
case 52: | |
return "Hangul Compatibility Jamo"; | |
case 54: | |
return "Enclosed CJK Letters And Months"; | |
case 55: | |
return "CJK Compatibility"; | |
case 56: | |
return "Hangul Syllables"; | |
case 57: | |
return "Non-Plane 0"; | |
case 59: | |
return "CJK Unified Ideographs"; | |
case 61: | |
return "CJK Strokes, CJK Compatibility Ideographs, CJK Compatibility Ideographs Supplement"; | |
case 63: | |
return "Arabic Presentation Forms-A"; | |
default: | |
return NULL; | |
} | |
} | |
int main(int argc, char *argv[]) | |
{ | |
FT_Library library; | |
FT_Face face; | |
int error, i; | |
if (argc < 2) | |
return 0; | |
FT_Init_FreeType( &library ); | |
error = FT_New_Face(library, argv[1], 0, &face); | |
if (error) { | |
printf("Cannot open file %s\n", argv[1]); | |
return error; | |
} | |
TT_OS2 *os2 = (TT_OS2*) FT_Get_Sfnt_Table(face, ft_sfnt_os2); | |
printf("glyphs: %ld\n", face->num_glyphs); | |
FT_ULong mask = 1L; | |
for (i = 32; i < 64; i++) { | |
if (os2->ulUnicodeRange2 & mask) { | |
const char *r = rangeForBit(i); | |
printf("bit %d = 1 (%s)\n", i, (r ? r : "")); | |
} | |
mask = mask << 1; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment