Gnash  0.8.11dev
DefineFontNameTag.h
Go to the documentation of this file.
1 // DefineFontNameTag.cpp: read a DefineFontName tag.
2 //
3 // Copyright (C) 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 #include "SWF.h"
22 #include "SWFStream.h"
23 #include "Font.h"
24 #include "RunResources.h"
25 #include "movie_definition.h"
26 
27 #ifndef GNASH_SWF_DEFINEFONTNAMETAG_H
28 #define GNASH_SWF_DEFINEFONTNAMETAG_H
29 
30 namespace gnash {
31 namespace SWF {
32 
34 //
38 {
39 public:
40 
41  // Set font name for a font.
42  static void loader(SWFStream& in, TagType tag, movie_definition& m,
43  const RunResources& /*r*/)
44  {
45  assert(tag == SWF::DEFINEFONTNAME);
46 
47  in.ensureBytes(2);
48  std::uint16_t fontID = in.read_u16();
49 
50  Font* f = m.get_font(fontID);
51  if (!f)
52  {
54  log_swferror(_("define_font_name_loader: can't find "
55  "font with id %d"), fontID);
56  );
57  return;
58  }
59 
60  Font::FontNameInfo fontName;
61  in.read_string(fontName.displayName);
62  in.read_string(fontName.copyrightName);
63 
64  f->addFontNameInfo(fontName);
65  }
66 
67 };
68 
69 }
70 }
71 
72 #endif
virtual Font * get_font(int) const
Return the font with given DisplayObject id.
Definition: movie_definition.h:253
std::uint16_t read_u16()
Read a aligned unsigned 16-bit value from the stream.
Definition: SWFStream.cpp:332
std::string copyrightName
Definition: Font.h:223
A pair of strings describing the font.
Definition: Font.h:220
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
A Font resource.
Definition: Font.h:89
Process a DefineFontName tag.
Definition: DefineFontNameTag.h:37
void read_string(std::string &to)
Reads a null-terminated string from the given file and assigns it to the given std::string, overriding any previous value of it.
Definition: SWFStream.cpp:395
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:30
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
Definition: GnashKey.h:152
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &)
Definition: DefineFontNameTag.h:42
#define _(String)
Definition: log.h:44
std::string displayName
Definition: Font.h:222
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:53
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
Definition: SWF.h:114
Definition: GnashKey.h:159
void addFontNameInfo(const FontNameInfo &fontName)
Add display name and copyright name for an embedded font.
Definition: Font.cpp:117
Definition: GnashKey.h:331
SWF stream wrapper class.
Definition: SWFStream.h:58
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