Gnash  0.8.11dev
DefineFontTag.h
Go to the documentation of this file.
1 // DefineFontTag.h Read DefineFont and DefineFontInfo tags
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 
21 // Based on the public domain work of Thatcher Ulrich <tu@tulrich.com> 2003
22 
25 //
29 
30 #ifndef GNASH_SWF_DEFINEFONTTAG_H
31 #define GNASH_SWF_DEFINEFONTTAG_H
32 
33 #include "SWF.h"
34 #include "Font.h"
35 #include <map>
36 #include <string>
37 #include <boost/cstdint.hpp>
38 
39 // Forward declarations
40 namespace gnash {
41  class SWFStream;
42  class movie_definition;
43  class RunResources;
44 }
45 
46 namespace gnash {
47 namespace SWF {
48 
51 {
52 public:
53 
55  //
57  static void loader(SWFStream& in, TagType tag, movie_definition& m,
58  const RunResources& r);
59 
62  return _glyphTable;
63  }
64 
66  //
68  //
70  bool hasCodeTable() const {
71  return _codeTable.get();
72  }
73 
75  //
78  //
82  boost::shared_ptr<const Font::CodeTable> getCodeTable() const {
83  return _codeTable;
84  }
85 
86  bool ansiChars() const { return _ansiChars; }
87  bool shiftJISChars() const { return _shiftJISChars; }
88  bool unicodeChars() const { return _unicodeChars; }
89  bool italic() const { return _italic; }
90  bool bold() const { return _bold; }
91  bool subpixelFont() const { return _subpixelFont; }
92 
94  //
96  boost::int16_t leading() const {
97  return _leading;
98  }
99 
101  //
103  boost::int16_t ascent() const {
104  return _ascent;
105  }
106 
108  //
110  boost::int16_t descent() const {
111  return _descent;
112  }
113 
114  const std::string& name() const { return _name; }
115 
117  static void readCodeTable(SWFStream& in, Font::CodeTable& table,
118  bool wideCodes, size_t glyphCount);
119 
120 private:
121 
123  const RunResources& r);
124 
126  void readDefineFont(SWFStream& in, movie_definition& m,
127  const RunResources& r);
128 
130  void readDefineFont2Or3(SWFStream& in, movie_definition& m,
131  const RunResources& r);
132 
134  Font::GlyphInfoRecords _glyphTable;
135 
136  std::string _name;
137  bool _subpixelFont;
138  bool _hasLayout;
139  bool _unicodeChars;
140  bool _shiftJISChars;
141  bool _ansiChars;
142  bool _italic;
143  bool _bold;
144  bool _wideCodes;
145 
146  boost::int16_t _ascent;
147  boost::int16_t _descent;
148  boost::int16_t _leading;
149 
150  typedef std::map<kerning_pair, boost::int16_t> KerningTable;
151  KerningTable _kerningPairs;
152 
153  boost::shared_ptr<const Font::CodeTable> _codeTable;
154 };
155 
156 
158 {
159 public:
161  //
165  static void loader(SWFStream& in, TagType tag, movie_definition& m,
166  const RunResources& r);
167 };
168 
169 }
170 }
171 
172 #endif