Mercurial > hg > octave-lyh
diff src/gl-render.cc @ 9834:92d8f35ff217
compute bounding boxes for text in opengl graphics backend
author | Shai Ayal <shaiay@users.sourceforge.net> |
---|---|
date | Wed, 18 Nov 2009 23:14:09 -0500 |
parents | 2d6a5af744b6 |
children | fed4aad2cdca |
line wrap: on
line diff
--- a/src/gl-render.cc +++ b/src/gl-render.cc @@ -3140,18 +3140,16 @@ return ID; } -Matrix -opengl_renderer::render_text (const std::string& txt, - double x, double y, double z, - int halign, int valign, double rotation) +void +opengl_renderer::text_to_pixels (const std::string& txt, + double rotation, + uint8NDArray& pixels, + Matrix& bbox, + int& rot_mode) { -#if HAVE_FREETYPE - if (txt.empty ()) - return Matrix (1, 4, 0.0); - // FIXME: clip "rotation" between 0 and 360 - int rot_mode = ft_render::ROTATION_0; + rot_mode = ft_render::ROTATION_0; if (rotation == 90.0) rot_mode = ft_render::ROTATION_90; @@ -3161,8 +3159,24 @@ rot_mode = ft_render::ROTATION_270; text_element *elt = text_parser_none ().parse (txt); + pixels = text_renderer.render (elt, bbox, rot_mode); + delete elt; +} + +Matrix +opengl_renderer::render_text (const std::string& txt, + double x, double y, double z, + int halign, int valign, double rotation) +{ +#if HAVE_FREETYPE + if (txt.empty ()) + return Matrix (1, 4, 0.0); + Matrix bbox; - uint8NDArray pixels = text_renderer.render (elt, bbox, rot_mode); + uint8NDArray pixels; + int rot_mode; + text_to_pixels (txt, rotation, pixels, bbox, rot_mode); + int x0 = 0, y0 = 0; int w = bbox(2), h = bbox(3); @@ -3216,8 +3230,6 @@ if (! blend) glDisable (GL_BLEND); - delete elt; - return bbox; #else ::warning ("render_text: cannot render text, Freetype library not available");