gsd_fonts.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*!
  2. \file gsd_fonts.c
  3. \brief OGSF library - loading and manipulating surfaces
  4. GRASS OpenGL gsurf OGSF Library
  5. \todo This file needs to be re-written in OpenGL
  6. (C) 1999-2008 by the GRASS Development Team
  7. This program is free software under the
  8. GNU General Public License (>=v2).
  9. Read the file COPYING that comes with GRASS
  10. for details.
  11. \author Bill Brown USACERL, GMSL/University of Illinois
  12. \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
  13. */
  14. #include <string.h>
  15. #include <assert.h>
  16. #include <grass/gstypes.h>
  17. #include <grass/ogsf_proto.h>
  18. #include "rgbpack.h"
  19. /*!
  20. \brief Get text width
  21. \param s text string
  22. \param size size
  23. \return text width
  24. */
  25. int gsd_get_txtwidth(const char *s, int size)
  26. {
  27. int width, len;
  28. len = strlen(s);
  29. width = (size * len) / 2;
  30. return (width);
  31. }
  32. /*!
  33. \brief Get text height
  34. \param size size
  35. \return text height
  36. */
  37. int gsd_get_txtheight(int size)
  38. {
  39. unsigned long height;
  40. height = size / 2;
  41. return (height);
  42. }
  43. /*!
  44. \brief Get text descender
  45. yorig ??
  46. Is this defined somewhere ?
  47. \return 2
  48. */
  49. int get_txtdescender(void)
  50. {
  51. return (2);
  52. }
  53. /*!
  54. \brief Get text offset
  55. xorig ??
  56. Is this defined somewhere ?
  57. \return 0
  58. */
  59. int get_txtxoffset(void)
  60. {
  61. return (0);
  62. }
  63. /*!
  64. \brief Display label
  65. \param fontbase font-base
  66. \param lab_pos label position
  67. \param txt text string
  68. */
  69. void do_label_display(GLuint fontbase, float *lab_pos, const char *txt)
  70. {
  71. glRasterPos2f(lab_pos[X], lab_pos[Y]);
  72. glListBase(fontbase);
  73. glCallLists(strlen(txt), GL_UNSIGNED_BYTE, (const GLvoid *)txt);
  74. return;
  75. }