X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Ftexfont.h;h=7fbdb786bc6b7e1b082903400c09384b44f8adb7;hb=d1ae2829ff0fd2a96c16a0c8c5420efaa47d7b30;hp=05c9219a292125ee345ed112a663fde44682750a;hpb=2d04c4f22466851aedb6ed0f2919d148f726b889;p=xscreensaver diff --git a/hacks/glx/texfont.h b/hacks/glx/texfont.h index 05c9219a..7fbdb786 100644 --- a/hacks/glx/texfont.h +++ b/hacks/glx/texfont.h @@ -1,4 +1,4 @@ -/* texfonts, Copyright (c) 2005 Jamie Zawinski +/* texfonts, Copyright (c) 2005-2015 Jamie Zawinski * Loads X11 fonts into textures for use with OpenGL. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -20,16 +20,44 @@ typedef struct texture_font_data texture_font_data; */ extern texture_font_data *load_texture_font (Display *, char *res); -/* Width of the string in pixels. +/* Bounding box of the multi-line string, in pixels, + and overall ascent/descent of the font. */ -extern int texture_string_width (texture_font_data *, const char *, - int *line_height_ret); +extern void texture_string_metrics (texture_font_data *, const char *, + XCharStruct *metrics_ret, + int *ascent_ret, int *descent_ret); /* Draws the string in the scene at the origin. Newlines and tab stops are honored. + Any numbers inside [] will be rendered as a subscript. + Assumes the font has been loaded as with load_texture_font(). */ extern void print_texture_string (texture_font_data *, const char *); +/* Draws the string on the window at the given pixel position. + Newlines and tab stops are honored. + Any numbers inside [] will be rendered as a subscript. + Assumes the font has been loaded as with load_texture_font(). + + Position is 0 for center, 1 for top left, 2 for bottom left. + */ +void print_texture_label (Display *, texture_font_data *, + int window_width, int window_height, + int position, const char *string); + +/* Renders the given string into the prevailing texture. + Returns the metrics of the text, and size of the texture. + */ +void string_to_texture (texture_font_data *, const char *, + XCharStruct *extents_ret, + int *tex_width_ret, int *tex_height_ret); + +/* Set the various OpenGL parameters for properly rendering things + with a texture generated by string_to_texture(). + */ +void enable_texture_string_parameters (void); + + /* Releases the texture font. */ extern void free_texture_font (texture_font_data *);