예제 #1
0
파일: Shape.php 프로젝트: yoya/IO_SWF
 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);
     }
 }
예제 #2
0
파일: Text.php 프로젝트: yoya/IO_SWF
 function parseContent($tagCode, $content, $opts = array())
 {
     $opts['tagCode'] = $tagCode;
     $reader = new IO_Bit();
     $reader->input($content);
     $this->_CharacterID = $reader->getUI16LE();
     $this->_TextBounds = IO_SWF_TYPE_RECT::parse($reader);
     $this->_TextMatrix = IO_SWF_Type_MATRIX::parse($reader);
     $glyphBits = $reader->getUI8();
     $advanceBits = $reader->getUI8();
     $this->_GlyphBits = $glyphBits;
     $this->_AdvanceBits = $advanceBits;
     $textRecords = array();
     $opts['GlyphBits'] = $glyphBits;
     $opts['AdvanceBits'] = $advanceBits;
     while ($reader->getUI8() != 0) {
         $reader->incrementOffset(-1, 0);
         // 1 byte back
         $textRecords[] = IO_SWF_Type_TEXTRECORD::parse($reader, $opts);
     }
     $this->_TextRecords = $textRecords;
 }
예제 #3
0
파일: Font.php 프로젝트: yoya/IO_SWF
 function parseContent($tagCode, $content, $opts = array())
 {
     $reader = new IO_Bit();
     $reader->input($content);
     $this->FontID = $reader->getUI16LE();
     $fontFlagsHasLayout = $reader->getUIBit();
     $this->FontFlagsShiftJIS = $reader->getUIBit();
     $this->FontFlagsSmallText = $reader->getUIBit();
     $this->FontFlagsANSI = $reader->getUIBit();
     $this->FontFlagsWideOffsets = $reader->getUIBit();
     $this->FontFlagsWideCodes = $reader->getUIBit();
     $this->FontFlagsItalic = $reader->getUIBit();
     $this->FontFlagsBold = $reader->getUIBit();
     $this->LanguageCode = IO_SWF_Type_LANGCODE::parse($reader);
     $fontNameLen = $reader->getUI8();
     $this->FontName = $reader->getData($fontNameLen);
     $numGlyphs = $reader->getUI16LE();
     if ($numGlyphs === 0) {
         return;
         // no glyphs field.
     }
     list($startOfOffsetTable, $dummy) = $reader->getOffset();
     if ($this->FontFlagsWideOffsets) {
         for ($i = 0; $i < $numGlyphs; $i++) {
             $this->OffsetTable[] = $reader->getUI32LE();
         }
     } else {
         for ($i = 0; $i < $numGlyphs; $i++) {
             $this->OffsetTable[] = $reader->getUI16LE();
         }
     }
     if ($this->FontFlagsWideOffsets) {
         $codeTableOffset = $reader->getUI32LE();
     } else {
         $codeTableOffset = $reader->getUI16LE();
     }
     for ($i = 0; $i < $numGlyphs; $i++) {
         $reader->setOffset($startOfOffsetTable + $this->OffsetTable[$i], 0);
         $this->GlyphShapeTable[] = IO_SWF_Type_SHAPE::parse($reader, $opts);
         $reader->byteAlign();
     }
     list($startOfOffsetCodeTable, $dummy) = $reader->getOffset();
     if ($startOfOffsetCodeTable != $startOfOffsetTable + $codeTableOffset) {
         trigger_error("startOfOffsetCodeTable:{$startOfOffsetCodeTable} != startOfOffsetTable:{$startOfOffsetTable} + codeTableOffset:{$codeTableOffset}", E_USER_WARNING);
     }
     $reader->setOffset($startOfOffsetTable + $codeTableOffset, 0);
     if ($this->FontFlagsWideCodes) {
         for ($i = 0; $i < $numGlyphs; $i++) {
             $this->CodeTable[] = $reader->getUI16LE();
         }
     } else {
         for ($i = 0; $i < $numGlyphs; $i++) {
             $this->CodeTable[] = $reader->getUI8();
         }
     }
     if ($fontFlagsHasLayout) {
         $this->FontAscent = $reader->getSI16LE();
         $this->FontDescent = $reader->getSI16LE();
         $this->FontLeading = $reader->getSI16LE();
         $this->FontAdvanceTable = array();
         for ($i = 0; $i < $numGlyphs; $i++) {
             $this->FontAdvanceTable[] = $reader->getSI16LE();
         }
         $this->FontBoundsTable = array();
         for ($i = 0; $i < $numGlyphs; $i++) {
             $this->FontBoundsTable[] = IO_SWF_TYPE_RECT::parse($reader);
         }
         $kerningCount = $reader->getUI16LE();
         if ($kerningCount > 0) {
             $this->FontKerningTable = array();
             $opts['FontFlagsWideCodes'] = $this->FontFlagsWideCodes;
             for ($i = 0; $i < $kerningCount; $i++) {
                 $this->FontKerningTable[] = IO_SWF_TYPE_KERNINGRECORD::parse($reader, $opts);
             }
         }
     }
 }