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