Gnash  0.8.10
DefineFontTag.h
Go to the documentation of this file.
00001 // DefineFontTag.h   Read DefineFont and DefineFontInfo tags
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 
00021 // Based on the public domain work of Thatcher Ulrich <tu@tulrich.com> 2003
00022 
00025 //
00029 
00030 #ifndef GNASH_SWF_DEFINEFONTTAG_H
00031 #define GNASH_SWF_DEFINEFONTTAG_H
00032 
00033 #include "SWF.h"
00034 #include "Font.h"
00035 #include <map>
00036 #include <string>
00037 #include <boost/cstdint.hpp>
00038 
00039 // Forward declarations
00040 namespace gnash {
00041     class SWFStream;
00042     class movie_definition;
00043     class RunResources;
00044 }
00045 
00046 namespace gnash {
00047 namespace SWF {
00048 
00050 class DefineFontTag
00051 {
00052 public:
00053 
00055     //
00057     static void loader(SWFStream& in, TagType tag, movie_definition& m,
00058             const RunResources& r);
00059 
00061     const Font::GlyphInfoRecords& glyphTable() const {
00062         return _glyphTable;
00063     }
00064 
00066     //
00068     //
00070     bool hasCodeTable() const {
00071         return _codeTable.get();
00072     }
00073     
00075     //
00078     //
00082     boost::shared_ptr<const Font::CodeTable> getCodeTable() const {
00083         return _codeTable;
00084     }
00085 
00086     bool ansiChars() const { return _ansiChars; }
00087     bool shiftJISChars() const { return _shiftJISChars; }
00088     bool unicodeChars() const { return _unicodeChars; }
00089     bool italic() const { return _italic; }
00090     bool bold() const { return _bold; }
00091     bool subpixelFont() const { return _subpixelFont; }
00092 
00094     //
00096     boost::int16_t leading() const {
00097         return _leading;
00098     }
00099 
00101     //
00103     boost::int16_t ascent() const {
00104         return _ascent;
00105     }
00106 
00108     //
00110     boost::int16_t descent() const {
00111         return _descent;
00112     }
00113 
00114     const std::string& name() const { return _name; }
00115 
00117     static void readCodeTable(SWFStream& in, Font::CodeTable& table,
00118         bool wideCodes, size_t glyphCount);
00119 
00120 private:
00121 
00122     DefineFontTag(SWFStream& in, movie_definition& m, TagType tag,
00123             const RunResources& r);
00124 
00126     void readDefineFont(SWFStream& in, movie_definition& m,
00127             const RunResources& r);
00128 
00130     void readDefineFont2Or3(SWFStream& in, movie_definition& m,
00131             const RunResources& r);
00132 
00134     Font::GlyphInfoRecords _glyphTable;
00135 
00136     std::string _name;
00137     bool _subpixelFont;
00138         bool _hasLayout;
00139         bool _unicodeChars;
00140         bool _shiftJISChars;
00141         bool _ansiChars;
00142         bool _italic;
00143         bool _bold;
00144         bool _wideCodes;
00145 
00146     boost::int16_t _ascent;
00147     boost::int16_t _descent;
00148     boost::int16_t _leading;
00149 
00150         typedef std::map<kerning_pair, boost::int16_t> KerningTable;
00151         KerningTable _kerningPairs;
00152 
00153     boost::shared_ptr<const Font::CodeTable> _codeTable;
00154 };
00155 
00156 
00157 class DefineFontInfoTag
00158 {
00159 public:
00161     //
00165     static void loader(SWFStream& in, TagType tag, movie_definition& m,
00166             const RunResources& r);
00167 };
00168 
00169 }
00170 }
00171 
00172 #endif