gsd_fonts.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*!
  2. \file lib/ogsf/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/ogsf.h>
  17. #include "rgbpack.h"
  18. /*!
  19. \brief Get text width
  20. \param s text string
  21. \param size size
  22. \return text width
  23. */
  24. int gsd_get_txtwidth(const char *s, int size)
  25. {
  26. int width, len;
  27. len = strlen(s);
  28. width = (size * len) / 2;
  29. return (width);
  30. }
  31. /*!
  32. \brief Get text height
  33. \param size size
  34. \return text height
  35. */
  36. int gsd_get_txtheight(int size)
  37. {
  38. unsigned long height;
  39. height = size / 2;
  40. return (height);
  41. }
  42. /*!
  43. \brief Get text descender
  44. yorig ??
  45. Is this defined somewhere ?
  46. \return 2
  47. */
  48. int get_txtdescender(void)
  49. {
  50. return (2);
  51. }
  52. /*!
  53. \brief Get text offset
  54. xorig ??
  55. Is this defined somewhere ?
  56. \return 0
  57. */
  58. int get_txtxoffset(void)
  59. {
  60. return (0);
  61. }
  62. /*!
  63. \brief Display label
  64. \param fontbase font-base
  65. \param lab_pos label position
  66. \param txt text string
  67. */
  68. void do_label_display(GLuint fontbase, float *lab_pos, const char *txt)
  69. {
  70. glRasterPos2f(lab_pos[X], lab_pos[Y]);
  71. glListBase(fontbase);
  72. glCallLists(strlen(txt), GL_UNSIGNED_BYTE, (const GLvoid *)txt);
  73. return;
  74. }