function parseContent($tagCode, $content, $opts = array()) { // DefineMorphShape, DefineMorphShape2 $isMorph = $tagCode == 46 || $tagCode == 84; $reader = new IO_Bit(); $reader->input($content); $this->_shapeId = $reader->getUI16LE(); $opts = array('tagCode' => $tagCode, 'isMorph' => $isMorph); if ($isMorph === false) { // 描画スタイル $this->_shapeBounds = IO_SWF_TYPE_RECT::parse($reader); if ($tagCode == 83) { // DefineShape4 $this->_edgeBounds = IO_SWF_TYPE_RECT::parse($reader); $this->_reserved = $reader->getUIBits(6); $this->_usesNonScalingStrokes = $reader->getUIBit(); $this->_UsesScalingStrokes = $reader->getUIBit(); } $this->_fillStyles = IO_SWF_TYPE_FILLSTYLEARRAY::parse($reader, $opts); $this->_lineStyles = IO_SWF_TYPE_LINESTYLEARRAY::parse($reader, $opts); // 描画枠 $this->_shapeRecords = IO_SWF_Type_SHAPE::parse($reader, $opts); } else { $this->_startBounds = IO_SWF_TYPE_RECT::parse($reader); $this->_endBounds = IO_SWF_TYPE_RECT::parse($reader); list($offset_offset, $dummy) = $reader->getOffset(); $this->_offset = $reader->getUI32LE(); // 描画スタイル $this->_morphFillStyles = IO_SWF_TYPE_FILLSTYLEARRAY::parse($reader, $opts); $this->_morphLineStyles = IO_SWF_TYPE_LINESTYLEARRAY::parse($reader, $opts); // 描画枠 $this->_startEdge = IO_SWF_Type_SHAPE::parse($reader, $opts); list($end_edge_offset, $dummy) = $reader->getOffset(); if ($offset_offset + $this->_offset + 4 != $end_edge_offset) { trigger_error("offset_offset({$offset_offset}) + this->_offset({$this->_offset}) + 4 != end_edge_offset({$end_edge_offset})", E_USER_WARNING); $reader->setOffset($offset_offset + $this->_offset + 4, 0); } $this->_endEdge = IO_SWF_Type_SHAPE::parse($reader, $opts); } }
function buildContent($tagCode, $opts = array()) { $opts['tagCode'] = $tagCode; $writer = new IO_Bit(); $writer->putUI16LE($this->_CharacterID); IO_SWF_TYPE_RECT::build($writer, $this->_TextBounds); IO_SWF_Type_MATRIX::build($writer, $this->_TextMatrix); $glyphBits = $this->_GlyphBits; // XXX $advanceBits = $this->_AdvanceBits; // XXX $writer->putUI8($glyphBits); $writer->putUI8($advanceBits); $opts['GlyphBits'] = $glyphBits; $opts['AdvanceBits'] = $advanceBits; foreach ($this->_TextRecords as $textRecord) { IO_SWF_Type_TEXTRECORD::build($writer, $textRecord, $opts); } $writer->putUI8(0); // TEXTRECORD TERMINATER return $writer->output(); }
function buildContent($tagCode, $opts = array()) { $writer = new IO_Bit(); $writer->putUI16LE($this->FontID); // $fontFlagsHasLayout = is_null($this->FontAscent) ? 0 : 1; // $writer->putUIBit($fontFlagsHasLayout); $writer->putUIBit($this->FontFlagsShiftJIS); $writer->putUIBit($this->FontFlagsSmallText); $writer->putUIBit($this->FontFlagsANSI); $writer->putUIBit($this->FontFlagsWideOffsets); $writer->putUIBit($this->FontFlagsWideCodes); $writer->putUIBit($this->FontFlagsItalic); $writer->putUIBit($this->FontFlagsBold); IO_SWF_Type_LANGCODE::build($writer, $this->LanguageCode); $fontNameLen = strlen($this->FontName); $writer->putUI8($fontNameLen); $writer->putData($this->FontName); $numGlyphs = count($this->OffsetTable); $writer->putUI16LE($numGlyphs); if ($numGlyphs === 0) { return $writer->output(); // no glyphs field. } list($startOfOffsetTable, $dummy) = $writer->getOffset(); $startOfOffsetTable2 = array(); if ($this->FontFlagsWideOffsets) { foreach ($this->OffsetTable as $idx => $offset) { list($startOfOffsetTables[$idx], $dummy) = $writer->getOffset(); $writer->putUI32LE(0); // dummy } } else { foreach ($this->OffsetTable as $idx => $offset) { list($startOfOffsetTables[$idx], $dummy) = $writer->getOffset(); $writer->putUI16LE(0); // dummy } } list($startOfcodeTableOffset, $dummy) = $writer->getOffset(); if ($this->FontFlagsWideOffsets) { $writer->putUI32LE(0); // dummy } else { $writer->putUI16LE(0); // dummy } $opts['fillStyleCount'] = 1; $opts['lineStyleCount'] = 0; foreach ($this->GlyphShapeTable as $idx => $glyphShape) { list($startOfGlyphShape, $dummy) = $writer->getOffset(); if ($this->FontFlagsWideOffsets) { $writer->setUI32LE($startOfGlyphShape - $startOfOffsetTable, $startOfOffsetTables[$idx]); } else { $writer->setUI16LE($startOfGlyphShape - $startOfOffsetTable, $startOfOffsetTables[$idx]); } IO_SWF_Type_SHAPE::build($writer, $glyphShape, $opts); $writer->byteAlign(); } // list($startOfCodeTable, $dummy) = $writer->getOffset(); $codeTableOffset = $startOfCodeTable - $startOfOffsetTable; if ($this->FontFlagsWideOffsets) { $writer->setUI32LE($codeTableOffset, $startOfcodeTableOffset); } else { $writer->setUI16LE($codeTableOffset, $startOfcodeTableOffset); } if ($this->FontFlagsWideCodes) { foreach ($this->CodeTable as $c) { $writer->putUI16LE($c); } } else { foreach ($this->CodeTable as $c) { $writer->putUI8($c); } } if ($fontFlagsHasLayout) { $writer->putSI16LE($this->FontAscent); $writer->putSI16LE($this->FontDescent); $writer->putSI16LE($this->FontLeading); foreach ($this->FontAdvanceTable as $fontAdvance) { $writer->putSI16LE($fontAdvance); } foreach ($this->FontBoundsTable as $fontBounds) { IO_SWF_TYPE_RECT::build($writer, $fontBounds); } if (is_null($this->FontKerningTable)) { $writer->putUI16LE(0); } else { $kerningCount = count($this->FontKerningTable); $writer->putUI16LE($kerningCount); $opts['FontFlagsWideCodes'] = $this->FontFlagsWideCodes; foreach ($this->FontKerningTable as $fontKerning) { IO_SWF_TYPE_KERNINGRECORD::build($writer, $fontKerning, $opts); } } } return $writer->output(); }