main.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /****************************************************************************
  2. *
  3. * MODULE: d.fontlist
  4. * AUTHOR(S): James Westervelt (CERL) (original contributor)
  5. * Markus Neteler <neteler itc.it>,
  6. * Bernhard Reiter <bernhard intevation.de>,
  7. * Huidae Cho <grass4u gmail.com>,
  8. * Eric G. Miller <egm2 jps.net>,
  9. * Glynn Clements <glynn gclements.plus.com>,
  10. * Jan-Oliver Wagner <jan intevation.de>
  11. * PURPOSE: user selection of font for graphics monitor text
  12. * COPYRIGHT: (C) 1999-2008 by the GRASS Development Team
  13. *
  14. * This program is free software under the GNU General Public
  15. * License (>=v2). Read the file COPYING that comes with GRASS
  16. * for details.
  17. *
  18. * Implementation:
  19. * d.fontlist gets the list via D_font_list(), which calls COM_Font_list(),
  20. * which first reads the fonts from the file specified by $GRASS_FONT_CAP
  21. * (falling back to $GISBASE/etc/fontcap), then adds any fonts obtained by
  22. * the driver's Font_list method if provided (currently, only the cairo
  23. * driver implements this method).
  24. *
  25. *****************************************************************************/
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <grass/gis.h>
  30. #include <grass/display.h>
  31. #include <grass/glocale.h>
  32. int main(int argc, char **argv)
  33. {
  34. struct GModule *module;
  35. struct Flag *flagl, *flagL;
  36. char **list;
  37. int count;
  38. int i;
  39. G_gisinit(argv[0]);
  40. module = G_define_module();
  41. G_add_keyword(_("display"));
  42. G_add_keyword(_("settings"));
  43. module->description = _("Lists the available fonts.");
  44. flagl = G_define_flag();
  45. flagl->key = 'l';
  46. flagl->description = _("List fonts (default; provided for compatibility with d.font)");
  47. flagL = G_define_flag();
  48. flagL->key = 'v';
  49. flagL->description = _("List fonts verbosely");
  50. if (G_parser(argc, argv))
  51. exit(EXIT_FAILURE);
  52. D_open_driver();
  53. if (flagL->answer)
  54. D_font_info(&list, &count);
  55. else
  56. D_font_list(&list, &count);
  57. for (i = 0; i < count; i++)
  58. fprintf(stdout, "%s\n", list[i]);
  59. D_close_driver();
  60. exit(EXIT_SUCCESS);
  61. }