ftxf86.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #include <ft2build.h>
  18. #include FT_XFREE86_H
  19. #include FT_INTERNAL_OBJECTS_H
  20. /* XXX: This really is a sad hack, but I didn't want to change every */
  21. /* driver just to support this at the moment, since other important */
  22. /* changes are coming anyway. */
  23. typedef struct FT_FontFormatRec_
  24. {
  25. const char* driver_name;
  26. const char* format_name;
  27. } FT_FontFormatRec;
  28. FT_EXPORT_DEF( const char* )
  29. FT_Get_X11_Font_Format( FT_Face face )
  30. {
  31. static const FT_FontFormatRec font_formats[] =
  32. {
  33. { "type1", "Type 1" },
  34. { "truetype", "TrueType" },
  35. { "bdf", "BDF" },
  36. { "pcf", "PCF" },
  37. { "type42", "Type 42" },
  38. { "cidtype1", "CID Type 1" },
  39. { "cff", "CFF" },
  40. { "pfr", "PFR" },
  41. { "winfonts", "Windows FNT" }
  42. };
  43. const char* result = NULL;
  44. if ( face && face->driver )
  45. {
  46. FT_Module driver = (FT_Module)face->driver;
  47. if ( driver->clazz && driver->clazz->module_name )
  48. {
  49. FT_Int n;
  50. FT_Int count = sizeof( font_formats ) / sizeof ( font_formats[0] );
  51. result = driver->clazz->module_name;
  52. for ( n = 0; n < count; n++ )
  53. if ( ft_strcmp( result, font_formats[n].driver_name ) == 0 )
  54. {
  55. result = font_formats[n].format_name;
  56. break;
  57. }
  58. }
  59. }
  60. return result;
  61. }
  62. /* END */