1 /***************************************************************************/ 2 /* */ 3 /* ftxf86.c */ 4 /* */ 5 /* FreeType utility file for X11 support (body). */ 6 /* */ 7 /* Copyright 2002 by */ 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 /* */ 10 /* This file is part of the FreeType project, and may only be used, */ 11 /* modified, and distributed under the terms of the FreeType project */ 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 /* this file you indicate that you have read the license and */ 14 /* understand and accept it fully. */ 15 /* */ 16 /***************************************************************************/ 17 18 19 #include <ft2build.h> 20 #include FT_XFREE86_H 21 #include FT_INTERNAL_OBJECTS_H 22 23 /* XXX: This really is a sad hack, but I didn't want to change every */ 24 /* driver just to support this at the moment, since other important */ 25 /* changes are coming anyway. */ 26 27 typedef struct FT_FontFormatRec_ 28 { 29 const char* driver_name; 30 const char* format_name; 31 32 } FT_FontFormatRec; 33 34 35 FT_EXPORT_DEF( const char* ) FT_Get_X11_Font_Format(FT_Face face)36 FT_Get_X11_Font_Format( FT_Face face ) 37 { 38 static const FT_FontFormatRec font_formats[] = 39 { 40 { "type1", "Type 1" }, 41 { "truetype", "TrueType" }, 42 { "bdf", "BDF" }, 43 { "pcf", "PCF" }, 44 { "type42", "Type 42" }, 45 { "cidtype1", "CID Type 1" }, 46 { "cff", "CFF" }, 47 { "pfr", "PFR" }, 48 { "winfonts", "Windows FNT" } 49 }; 50 51 const char* result = NULL; 52 53 54 if ( face && face->driver ) 55 { 56 FT_Module driver = (FT_Module)face->driver; 57 58 59 if ( driver->clazz && driver->clazz->module_name ) 60 { 61 FT_Int n; 62 FT_Int count = sizeof( font_formats ) / sizeof ( font_formats[0] ); 63 64 65 result = driver->clazz->module_name; 66 67 for ( n = 0; n < count; n++ ) 68 if ( ft_strcmp( result, font_formats[n].driver_name ) == 0 ) 69 { 70 result = font_formats[n].format_name; 71 break; 72 } 73 } 74 } 75 76 return result; 77 } 78 79 80 /* END */ 81