<?php include("sample_utils.php"); // provides some utils and using mk $swfFN = "sample04.swf"; // we'll look into this file $si = new MKswf_inspector($swfFN); // start working on $fcTag = $si->find_firstTagID(FONT2); $msg = "sorry, seems to be no font in this swf"; if($fcTag){ $fcTD = $fcTag->get_tagData(); // get font data $f = new MKfont_container($fcTD); // create new mk font object $fontName = $f->get_fontName(); // gets font name $fontPath = SERVER_MKFONTS .$fontName .".mkf"; $msg = "<br />font " .$fontName; $msg .= " grabbed successful, please look into " .SERVER_MKFONTS ."<br />"; } ?>
Font data extraction requires some additional info, the easiest way to do is get an xml report as seen in sample #04, here is the xml output:
<?xml version="1.0"?> <MKswf_report creationDate="2006.06.01" creationTime="10:41:37" > <swfHeader swfFileName="sample04.swf" swfFileSize="14459" swfVersion="6" stageWidth="550" stageHeight="100" fps="12" frameCount="1" backgroundColor="#FFFFFF" isCompressed="yes" /> <rootTimeline frameCount="1"> <frameItem number="1"> <tag code="2" type="DefineShape" id="1" byteLength="99" > </tag> <placeObject2 pfMove="0" depth="1" characterID="1" > <matrix> <translation /> </matrix> </placeObject2> <fontItem id="2" ffWideCodes="1" italic="1" langCode="1" fontName="Lithograph" glyphsUsed="224" > </fontItem> <textField id="3" wordWrap="0" multiline="0" password="0" readOnly="1" textColor="#FFFFFF" hasFont="1" autoSize="0" noSelect="0" border="0" html="0" useOutlines="1"> <tfRect xmin="-2px" xmax="467.6px" ymin="-2px" ymax="467.6px" /> <font ID="2" height="60px" /> <layout align="0" leftMargin="0" rightMargin="0" indent="0" leading="40" /> <text> LITOGRAPH </text> </textField> <placeObject2 pfMove="0" depth="2" characterID="3" name="Tf" > <matrix> <translation x="52.4px" y="12.65px" /> </matrix> </placeObject2> <textField id="4" wordWrap="0" multiline="0" password="0" readOnly="1" textColor="#000033" hasFont="1" autoSize="0" noSelect="0" border="0" html="0" useOutlines="1"> <tfRect xmin="-2px" xmax="467.6px" ymin="-2px" ymax="467.6px" /> <font ID="2" height="60px" /> <layout align="0" leftMargin="0" rightMargin="0" indent="0" leading="40" /> <text> LITOGRAPH </text> </textField> <placeObject2 pfMove="0" depth="3" characterID="4" name="Tf" > <matrix> <translation x="50.2px" y="10.45px" /> </matrix> </placeObject2> </frameItem> </rootTimeline> </MKswf_report>
row #16 contains the infos we need, we also know that font data are stored in frame #1, and most important font contains 224 glyphs, that is the whole table chars. This step is to know if swf contains valid font data or not. Mk can retrieve the first occourrence of a given tag type[id][name] all swf wide or in a specific frame. It is also possibile to collect tags with few additional code.
You may also extract font items with few symbols, but you have to know what they are mapped in character table, a good idea could be setting a string composed by all desired characters and then output using mk to see results, as we will see in sample #14.
Font data retrieved is stored in dir media/fonts mantaining its font name and adding .mkf extension. The data format is used only by mk, it is not intended for general purpose nor for conversion-to application.