Gnash  0.8.10
FreetypeGlyphsProvider.h
Go to the documentation of this file.
00001 // FreetypeGlyphsProvider.h:  Freetype glyphs manager
00002 // 
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00004 //   Free Software Foundation, Inc
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef GNASH_FREETYPE_H
00021 #define GNASH_FREETYPE_H
00022 
00023 #include <string>
00024 #include <memory> // for auto_ptr
00025 #include <boost/thread/mutex.hpp>
00026 #include <boost/cstdint.hpp>
00027 
00028 #ifdef USE_FREETYPE 
00029 # include <ft2build.h>
00030 # include FT_FREETYPE_H
00031 # include FT_GLYPH_H
00032 #endif
00033 
00034 // Forward declarations
00035 namespace gnash {
00036     namespace SWF {
00037         class ShapeRecord;
00038     }
00039 }
00040 
00041 
00042 namespace gnash {
00043 
00045 //
00056 class FreetypeGlyphsProvider 
00057 {
00058 
00059 public:
00060 
00062     //
00076     static std::auto_ptr<FreetypeGlyphsProvider> createFace(
00077             const std::string& name, bool bold, bool italic);
00078 
00080     //
00083     ~FreetypeGlyphsProvider();
00084 
00085 
00089     //
00104     std::auto_ptr<SWF::ShapeRecord> getGlyph(boost::uint16_t code,
00105             float& advance);
00106 
00108     float ascent() const;
00109     
00111     float descent() const;
00112 
00114     //
00118     unsigned short unitsPerEM() const;
00119 
00120 private:
00121 
00123     //
00126     FreetypeGlyphsProvider(const std::string& fontname, bool bold, bool italic);
00127 
00128 #ifdef USE_FREETYPE 
00129 
00134     float scale;
00135 
00137     //
00155     bool getFontFilename(const std::string& name, bool bold, bool italic,
00156             std::string& filename);
00157 
00159     static void init();
00160 
00161     static void close();
00162 
00164     static boost::mutex    m_lib_mutex;
00165 
00167     static FT_Library    m_lib;
00168 
00169     FT_Face    _face;
00170 
00171 #endif // USE_FREETYPE
00172 
00173 };
00174 
00175 } // namespace gnash
00176 
00177 
00178 #endif    // GNASH_FREETYPE_H