1 /* texfonts, Copyright (c) 2005-2016 Jamie Zawinski <jwz@jwz.org>
2 * Loads X11 fonts into textures for use with OpenGL.
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
13 #ifndef __TEXTURE_FONT_H__
14 #define __TEXTURE_FONT_H__
16 typedef struct texture_font_data texture_font_data;
18 /* Loads the font named by the X resource "res" and returns
19 a texture-font object.
21 extern texture_font_data *load_texture_font (Display *, char *res);
23 /* Bounding box of the multi-line string, in pixels,
24 and overall ascent/descent of the font.
26 extern void texture_string_metrics (texture_font_data *, const char *,
27 XCharStruct *metrics_ret,
28 int *ascent_ret, int *descent_ret);
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().
35 extern void print_texture_string (texture_font_data *, const char *);
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().
42 Position is 0 for center, 1 for top left, 2 for bottom left.
44 void print_texture_label (Display *, texture_font_data *,
45 int window_width, int window_height,
46 int position, const char *string);
48 /* Renders the given string into the prevailing texture.
49 Returns the metrics of the text, and size of the texture.
51 void string_to_texture (texture_font_data *, const char *,
52 XCharStruct *extents_ret,
53 int *tex_width_ret, int *tex_height_ret);
55 /* Set the various OpenGL parameters for properly rendering things
56 with a texture generated by string_to_texture().
58 void enable_texture_string_parameters (void);
61 /* Releases the texture font.
63 extern void free_texture_font (texture_font_data *);
67 extern char *texfont_unicode_character_name (texture_font_data *,
72 #endif /* __TEXTURE_FONT_H__ */