From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / texfont.h
1 /* texfonts, Copyright (c) 2005-2016 Jamie Zawinski <jwz@jwz.org>
2  * Loads X11 fonts into textures for use with OpenGL.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation.  No representations are made about the suitability of this
9  * software for any purpose.  It is provided "as is" without express or 
10  * implied warranty.
11  */
12
13 #ifndef __TEXTURE_FONT_H__
14 #define __TEXTURE_FONT_H__
15
16 typedef struct texture_font_data texture_font_data;
17
18 /* Loads the font named by the X resource "res" and returns
19    a texture-font object.
20 */
21 extern texture_font_data *load_texture_font (Display *, char *res);
22
23 /* Bounding box of the multi-line string, in pixels,
24    and overall ascent/descent of the font.
25  */
26 extern void texture_string_metrics (texture_font_data *, const char *,
27                                     XCharStruct *metrics_ret,
28                                     int *ascent_ret, int *descent_ret);
29
30 /* Draws the string in the scene at the origin.
31    Newlines and tab stops are honored.
32    Any numbers inside [] will be rendered as a subscript.
33    Assumes the font has been loaded as with load_texture_font().
34  */
35 extern void print_texture_string (texture_font_data *, const char *);
36
37 /* Draws the string on the window at the given pixel position.
38    Newlines and tab stops are honored.
39    Any numbers inside [] will be rendered as a subscript.
40    Assumes the font has been loaded as with load_texture_font().
41
42    Position is 0 for center, 1 for top left, 2 for bottom left.
43  */
44 void print_texture_label (Display *, texture_font_data *,
45                           int window_width, int window_height,
46                           int position, const char *string);
47
48 /* Renders the given string into the prevailing texture.
49    Returns the metrics of the text, and size of the texture.
50  */
51 void string_to_texture (texture_font_data *, const char *,
52                         XCharStruct *extents_ret,
53                         int *tex_width_ret, int *tex_height_ret);
54
55 /* Set the various OpenGL parameters for properly rendering things
56    with a texture generated by string_to_texture().
57  */
58 void enable_texture_string_parameters (void);
59
60
61 /* Releases the texture font.
62  */
63 extern void free_texture_font (texture_font_data *);
64
65
66 #ifdef HAVE_JWXYZ
67 extern char *texfont_unicode_character_name (texture_font_data *,
68                                              unsigned long uc);
69 #endif
70
71
72 #endif /* __TEXTURE_FONT_H__ */