Gnash  0.8.10
DefineFontNameTag.h
Go to the documentation of this file.
00001 // DefineFontNameTag.cpp: read a DefineFontName tag.
00002 // 
00003 //   Copyright (C) 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 #include "SWF.h"
00022 #include "SWFStream.h"
00023 #include "Font.h"
00024 #include "RunResources.h"
00025 #include "movie_definition.h"
00026 
00027 #ifndef GNASH_SWF_DEFINEFONTNAMETAG_H
00028 #define GNASH_SWF_DEFINEFONTNAMETAG_H
00029 
00030 namespace gnash {
00031 namespace SWF {
00032 
00034 //
00037 class DefineFontNameTag
00038 {
00039 public:
00040 
00041     // Set font name for a font.
00042     static void loader(SWFStream& in, TagType tag, movie_definition& m,
00043             const RunResources& /*r*/)
00044     {
00045         assert(tag == SWF::DEFINEFONTNAME);
00046 
00047         in.ensureBytes(2);
00048         boost::uint16_t fontID = in.read_u16();
00049 
00050         Font* f = m.get_font(fontID);
00051         if (!f)
00052         {
00053             IF_VERBOSE_MALFORMED_SWF(
00054                 log_swferror(_("define_font_name_loader: can't find "
00055                         "font with id %d"), fontID);
00056             );
00057             return;
00058         }
00059 
00060         Font::FontNameInfo fontName;
00061         in.read_string(fontName.displayName);
00062         in.read_string(fontName.copyrightName);
00063 
00064         f->addFontNameInfo(fontName);
00065     }
00066 
00067 };
00068 
00069 }
00070 }
00071 
00072 #endif