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 <cstdint>
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  std::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  std::int16_t leading() const {
97  return _leading;
98  }
99 
101  //
103  std::int16_t ascent() const {
104  return _ascent;
105  }
106 
108  //
110  std::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 _unicodeChars;
139  bool _shiftJISChars;
140  bool _ansiChars;
141  bool _italic;
142  bool _bold;
143 
144  std::int16_t _ascent;
145  std::int16_t _descent;
146  std::int16_t _leading;
147 
148  typedef std::map<kerning_pair, std::int16_t> KerningTable;
149  KerningTable _kerningPairs;
150 
151  std::shared_ptr<const Font::CodeTable> _codeTable;
152 };
153 
154 
156 {
157 public:
159  //
163  static void loader(SWFStream& in, TagType tag, movie_definition& m,
164  const RunResources& r);
165 };
166 
167 }
168 }
169 
170 #endif
gnash::SWF::DefineFontTag::descent
std::int16_t descent() const
The font descent value.
Definition: DefineFontTag.h:110
gnash::SWF::DefineFontTag::getCodeTable
std::shared_ptr< const Font::CodeTable > getCodeTable() const
Retrieve the tag's Font::CodeTable.
Definition: DefineFontTag.h:82
gnash::SWF::DefineFontTag::bold
bool bold() const
Definition: DefineFontTag.h:90
TypesParser.h
name
std::string name
Definition: LocalConnection_as.cpp:149
gnash::log_swferror
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
ShapeRecord.h
gnash::SWF::DefineFontInfoTag
Definition: DefineFontTag.h:156
gnash::SWF::DefineFontTag::italic
bool italic() const
Definition: DefineFontTag.h:89
gnash::SWF::TagType
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:31
gnash::key::i
@ i
Definition: GnashKey.h:155
gnash::SWF::DEFINEFONT2
@ DEFINEFONT2
Definition: SWF.h:78
LOG_ONCE
#define LOG_ONCE(x)
Definition: log.h:49
DefineFontTag.h
_
#define _(String)
Definition: log.h:44
gnash::SWF::DefineFontTag::shiftJISChars
bool shiftJISChars() const
Definition: DefineFontTag.h:87
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::SWF::DefineFontTag
Read and store DefineFont and DefineFont2 tag.
Definition: DefineFontTag.h:51
gnash::SWF::DefineFontTag::name
const std::string & name() const
Definition: DefineFontTag.h:114
gnash::SWF::DefineFontTag::leading
std::int16_t leading() const
The font leading value.
Definition: DefineFontTag.h:96
gnash::key::m
@ m
Definition: GnashKey.h:159
gnash::Font::GlyphInfoRecords
std::vector< GlyphInfo > GlyphInfoRecords
Definition: Font.h:242
gnash::SWF::DefineFontTag::ansiChars
bool ansiChars() const
Definition: DefineFontTag.h:86
gnash::SWF::DefineFontTag::ascent
std::int16_t ascent() const
The font ascent value.
Definition: DefineFontTag.h:103
gnash::SWF::DefineFontTag::glyphTable
const Font::GlyphInfoRecords & glyphTable() const
Return the glyphs read from the DefineFont tag.
Definition: DefineFontTag.h:61
gnash::movie_definition
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:96
gnash::SWF::DefineFontTag::hasCodeTable
bool hasCodeTable() const
Check for the existence of a Font::CodeTable.
Definition: DefineFontTag.h:70
gnash::key::k
@ k
Definition: GnashKey.h:157
IF_VERBOSE_MALFORMED_SWF
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
gnash::SWF::DefineFontTag::loader
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &r)
Load a DefineFont tag.
Definition: DefineFontTag.cpp:41
gnash::key::r
@ r
Definition: GnashKey.h:164
gnash::SWFStream::tell
unsigned long tell()
Return our current (byte) position in the input stream.
Definition: SWFStream.cpp:447
gnash::key::code
code
Definition: GnashKey.h:44
gnash::SWF::DefineFontInfoTag::loader
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &r)
Load a DefineFontInfo tag.
Definition: DefineFontTag.cpp:332
gnash::SWF::DEFINEFONTINFO
@ DEFINEFONTINFO
Definition: SWF.h:45
gnash::SWF::DEFINEFONTINFO2
@ DEFINEFONTINFO2
Definition: SWF.h:92
Font.h
gnash::RunResources
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
gnash::SWF::DEFINEFONT3
@ DEFINEFONT3
Definition: SWF.h:105
gnash::SWF::DefineFontTag::readCodeTable
static void readCodeTable(SWFStream &in, Font::CodeTable &table, bool wideCodes, size_t glyphCount)
Read Font::CodeTable, which maps glyph indices to DisplayObject codes.
Definition: DefineFontTag.cpp:56
IF_VERBOSE_PARSE
#define IF_VERBOSE_PARSE(x)
Definition: log.h:378
gnash::log_parse
void log_parse(StringType msg, Args... args)
Definition: log.h:313
log.h
gnash::key::f
@ f
Definition: GnashKey.h:152
gnash::Font
A Font resource.
Definition: Font.h:90
SWF.h
gnash::SWFStream::read_u16
std::uint16_t read_u16()
Read a aligned unsigned 16-bit value from the stream.
Definition: SWFStream.cpp:332
RunResources.h
gnash::SWFStream::read_u8
std::uint8_t read_u8()
Read a aligned unsigned 8-bit value from the stream.
Definition: SWFStream.cpp:319
movie_definition.h
gnash::SWFStream::read_string_with_length
void read_string_with_length(std::string &to)
Reads a sized string into a provided std::string.
Definition: SWFStream.cpp:411
gnash::SWF::DefineFontTag::subpixelFont
bool subpixelFont() const
Definition: DefineFontTag.h:91
gnash::SWFStream
SWF stream wrapper class.
Definition: SWFStream.h:59
gnash::readRect
SWFRect readRect(SWFStream &in)
Read a bit-packed rectangle from an SWF stream.
Definition: TypesParser.cpp:130
gnash::SWFStream::ensureBytes
void ensureBytes(unsigned long needed)
Ensure the requested number of bytes are available for an aligned read in the currently opened tag.
Definition: SWFStream.cpp:50
gnash::SWF::DefineFontTag::unicodeChars
bool unicodeChars() const
Definition: DefineFontTag.h:88
gnash::key::SWF
@ SWF
Definition: GnashKey.h:331
gnash::log_unimpl
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
gnash::Font::CodeTable
std::map< std::uint16_t, int > CodeTable
Definition: Font.h:94
SWFStream.h
gnash::SWF::DEFINEFONT
@ DEFINEFONT
Definition: SWF.h:42