sample #14
merging font data

* please run first sample #13, or replace Lithograph.mkf with Franklin Gothic Medium.mkf.

  1. <?php
  2. include("sample_utils.php"); // provides some utils and using mk
  3.  
  4. $swfFN = "test_mk_textfield01.swf"; // the file to generate
  5.  
  6. $tf = new MKtextField(); // create new textfield,
  7. // default itemID = 2, fontID = 1
  8. $tf->set_border(); // border
  9. $tf->set_multiline(); // multiline
  10. $tf->set_fontHeight(24); // 24px font height
  11. $tf->set_width(300); // 300px width
  12. $tf->set_height(200); // 200 px height
  13. $tf->set_useOutlines(); // use stored glyphs
  14. $tf->set_text(":) smile\ryou're on mk!'"); // write some text
  15. $tf->move(10, 40);
  16. $tfTag = $tf->update_tagData(); // refresh binary data
  17. $tfPB = $tf->update_place_tagData(); // refresh binary content
  18.  
  19. $fc = new MKfont_container(); // create "font" storage
  20. $fc->load_mkfont_from_file("Lithograph.mkf"); // load "font" from file, it must exists
  21. $fcTag = $fc->update_tagData(); // rebuild binary content
  22.  
  23. $swf = new MKswf($swfFN); // create new swf
  24. $swf->set_swfDir(SERVER_MKTMP); // set working directory in tmp
  25.  
  26. $swf->add_tagData($fcTag); // populate with font
  27. $swf->add_tagData($tfTag); // populate with textfield
  28. $swf->add_tagData($tfPB); // populate with placing settings
  29. $swf->swf_output(); // write to disk
  30.  
  31. $swfHeader = $swf->fetch_assoc(); // prepare to publish
  32.  
  33. $str = render_swf_box($swfHeader, $imgDir, false);
  34. $str .= "<br/><strong>" .$swfFN ." created in :<br />";
  35. $str .= SERVER_MKTMP ."</strong><p>please note that textfield is editable</p></td></tr>";
  36. echo show_content($str, basename(__FILE__));
  37. ?>

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. mikrokosmos