1 // DefineFontAlignZonesTag.cpp:  for Gnash.
2 //
3 //   Copyright (C) 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 "DefineFontAlignZonesTag.h"
22 
23 #include <cstdint>
24 
25 #include "RunResources.h"
26 #include "Font.h"
27 #include "log.h"
28 #include "SWFStream.h"
29 #include "movie_definition.h"
30 
31 namespace gnash {
32 namespace SWF {
33 
DefineFontAlignZonesTag(movie_definition &,SWFStream &)34 DefineFontAlignZonesTag::DefineFontAlignZonesTag(movie_definition& /*m*/,
35 	SWFStream& /*in*/)
36 {
37 }
38 
39 void
loader(SWFStream & in,TagType tag,movie_definition & m,const RunResources &)40 DefineFontAlignZonesTag::loader(SWFStream& in, TagType tag,
41         movie_definition& m, const RunResources& /*r*/)
42 {
43 	assert(tag == SWF::DEFINEALIGNZONES);
44 
45 	in.ensureBytes(2);
46 
47     // must reference a valid DEFINEFONT3 tag
48     const std::uint16_t ref = in.read_u16();
49 	Font* referencedFont = m.get_font(ref);
50 	if (!referencedFont) {
51 		IF_VERBOSE_MALFORMED_SWF(
52 		log_swferror(_("DefineFontAlignZones tag references an undefined "
53                "font %d"), ref);
54 		);
55 		in.skip_to_tag_end();
56 		return;
57 	}
58 
59 	in.ensureBytes(1);
60     // 2bits are cms table, 6bits are reserved
61 	const std::uint8_t flags = in.read_u8();
62 
63     // What is this?
64 	const std::uint16_t csm_table_int = flags >> 6;
65 
66 	// TODO:
67     // The first thing to to is test what this does. According to some
68     // sources, the tag is ignored and merely turns on the player's
69     // font engine.
70 	IF_VERBOSE_PARSE (
71         log_parse(_("DefineFontAlignZones: font=%d, flags=%d, "
72                 "table int: %s"), ref, flags, csm_table_int);
73 	);
74 
75 	const Font::GlyphInfoRecords::size_type glyphs_count =
76         referencedFont->glyphCount();
77 
78 	for (size_t i = 0; i != glyphs_count; ++i) {
79 
80         in.ensureBytes(1);
81 
82         // What is this for?
83         in.read_u8();
84 
85         for (size_t j = 0; j != 2; ++j) {
86             in.ensureBytes(4);
87             const std::uint16_t zone_position = in.read_u16();
88             const std::uint16_t zone_size = in.read_u16();
89 
90             IF_VERBOSE_PARSE(
91                 log_parse("Zone position: %s, size: %s", zone_position,
92                     zone_size);
93             );
94         }
95 
96         in.ensureBytes(1);
97         // What is this?
98         const std::uint8_t u = in.read_u8();
99         const bool zone_x = u & 0x01;
100         const bool zone_y = (u >> 1) & 0x01;
101 
102         IF_VERBOSE_PARSE(
103             log_parse("Zone x: %s, y: %s", zone_x, zone_y);
104         );
105 
106     }
107 	in.skip_to_tag_end();
108 	LOG_ONCE(log_unimpl(_("DefineFontAlignZoneTag")));
109 
110 }
111 
112 
113 } // namespace gnash::SWF
114 } // namespace gnash
115 
116 // Local Variables:
117 // mode: C++
118 // indent-tabs-mode: t
119 // End
120