txt-eng-ft.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2009-2012 Michael Goffioul
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if ! defined (txt_eng_ft_h)
00024 #define txt_eng_ft_h 1
00025 
00026 #if HAVE_FREETYPE
00027 
00028 #include <vector>
00029 
00030 #include <ft2build.h>
00031 #include FT_FREETYPE_H
00032 
00033 #include <dMatrix.h>
00034 #include <uint8NDArray.h>
00035 #include "txt-eng.h"
00036 
00037 class
00038 OCTINTERP_API
00039 ft_render : public text_processor
00040 {
00041 public:
00042   enum {
00043       MODE_BBOX   = 0,
00044       MODE_RENDER = 1
00045   };
00046 
00047   enum {
00048       ROTATION_0   = 0,
00049       ROTATION_90  = 1,
00050       ROTATION_180 = 2,
00051       ROTATION_270 = 3
00052   };
00053 
00054 public:
00055   ft_render (void);
00056 
00057   ~ft_render (void);
00058 
00059   void visit (text_element_string& e);
00060 
00061   void reset (void);
00062 
00063   uint8NDArray get_pixels (void) const { return pixels; }
00064 
00065   Matrix get_boundingbox (void) const { return bbox; }
00066 
00067   uint8NDArray render (text_element* elt, Matrix& box,
00068                        int rotation = ROTATION_0);
00069 
00070   Matrix get_extent (text_element *elt, double rotation = 0.0);
00071   Matrix get_extent (const std::string& txt, double rotation = 0.0);
00072 
00073   void set_font (const std::string& name, const std::string& weight,
00074                  const std::string& angle, double size);
00075 
00076   void set_color (Matrix c);
00077 
00078   void set_mode (int m);
00079 
00080   void text_to_pixels (const std::string& txt,
00081                        uint8NDArray& pixels_, Matrix& bbox,
00082                        int halign, int valign, double rotation);
00083 
00084 private:
00085   int rotation_to_mode (double rotation) const;
00086 
00087   // No copying!
00088 
00089   ft_render (const ft_render&);
00090 
00091   ft_render& operator = (const ft_render&);
00092 
00093 private:
00094   FT_Face face;
00095   Matrix bbox;
00096   uint8NDArray pixels;
00097   int xoffset;
00098   int yoffset;
00099   int multiline_halign;
00100   std::vector<int> multiline_align_xoffsets;
00101   int mode;
00102   uint8_t red, green, blue;
00103 };
00104 
00105 #endif // HAVE_FREETYPE
00106 
00107 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines