sample #14
merging font data
* please run first sample #13, or replace Lithograph.mkf with Franklin Gothic Medium.mkf.
<?php include("sample_utils.php"); // provides some utils and using mk $swfFN = "test_mk_textfield01.swf"; // the file to generate $tf = new MKtextField(); // create new textfield, // default itemID = 2, fontID = 1 $tf->set_border(); // border $tf->set_multiline(); // multiline $tf->set_fontHeight(24); // 24px font height $tf->set_width(300); // 300px width $tf->set_height(200); // 200 px height $tf->set_useOutlines(); // use stored glyphs $tf->set_text(":) smile\ryou're on mk!'"); // write some text $tf->move(10, 40); $tfTag = $tf->update_tagData(); // refresh binary data $tfPB = $tf->update_place_tagData(); // refresh binary content $fc = new MKfont_container(); // create "font" storage $fc->load_mkfont_from_file("Lithograph.mkf"); // load "font" from file, it must exists $fcTag = $fc->update_tagData(); // rebuild binary content $swf = new MKswf($swfFN); // create new swf $swf->set_swfDir(SERVER_MKTMP); // set working directory in tmp $swf->add_tagData($fcTag); // populate with font $swf->add_tagData($tfTag); // populate with textfield $swf->add_tagData($tfPB); // populate with placing settings $swf->swf_output(); // write to disk $swfHeader = $swf->fetch_assoc(); // prepare to publish $str = render_swf_box($swfHeader, $imgDir, false); $str .= "<br/><strong>" .$swfFN ." created in :<br />"; $str .= SERVER_MKTMP ."</strong><p>please note that textfield is editable</p></td></tr>"; ?>
Font data stored in media/font, as seen in sample #13 can be reused in other swf, the merging process is quite simple, istantiate a textfield and then load from file from file. Mk generates editable/non-editable textboxes, in this sample we assign a default text value but it is not mandatory, it may be better to insert font as symbol with linkage to control with actionscript, you'll find a little reference in sample #17. ![]()